Skip to content

Commit e76aacd

Browse files
authored
[OCONF-166] coconut conf import command (#71)
* [OCONF-166] Add coconut import command * [OCONF-166] Refactor * [OCONF-166] Add extension check * [OCONF-166] Fix compilation issues * [OCONF-166] Add component & entry check for new entries * [OCONF-166] Add extension file logic * [OCONF-166] Change error messages * [OCONF-166] Syntax updates * [OCONF-166] Address comments on strings * [OCONF-166] Fix compilation issue * [OCONF-166] Update user message * [OCONF-166] Add component/entry format * [OCONF-166] Remove commented lines * [OCONF-166] Update documentation
1 parent 3e3d121 commit e76aacd

5 files changed

Lines changed: 403 additions & 160 deletions

File tree

coconut/cmd/configuration_history.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ coconut conf history <component>/<entry>`,
3939
Long: `The configuration history command returns all entries with
4040
all of their associated timestamps or returns all timestamps for a specified component and entry`,
4141
Run: configuration.WrapCall(configuration.History),
42-
Args: cobra.RangeArgs(0, 3),
42+
Args: cobra.RangeArgs(0, 3),
4343
}
4444

4545
func init() {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* === This file is part of ALICE O² ===
3+
*
4+
* Copyright 2019 CERN and copyright holders of ALICE O².
5+
* Author: George Raduta <george.raduta@cern.ch>
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*
20+
* In applying this license CERN does not waive the privileges and
21+
* immunities granted to it by virtue of its status as an
22+
* Intergovernmental Organization or submit itself to any jurisdiction.
23+
*/
24+
25+
package cmd
26+
27+
import (
28+
"github.com/AliceO2Group/Control/coconut/configuration"
29+
"github.com/spf13/cobra"
30+
)
31+
32+
var configurationImportCmd = &cobra.Command{
33+
Use: "import <component> <entry> <file_path>",
34+
Aliases: []string{"i", "imp"},
35+
Example: `coconut conf import <component> <entry> <file_path>
36+
coconut conf import <component>/<entry> <file_path>
37+
coconut conf import <component> <entry> <file_path> --new-component
38+
coconut conf import <component>/<entry> <file_path> --format=json
39+
coconut conf import <component> <entry> <file_path>.json
40+
`,
41+
Short: "Import a configuration file for the specified component and entry",
42+
Long: `The configuration import command generates a timestamp and saves
43+
the configuration file to Consul under the <component>/<entry>/<timestamp> path.
44+
Supported configuration file types are JSON, YAML, TOML and INI,
45+
and their file extensions are recognized automatically.`,
46+
Run: configuration.WrapCall(configuration.Import),
47+
Args: cobra.RangeArgs(1, 4),
48+
}
49+
50+
func init() {
51+
configurationCmd.AddCommand(configurationImportCmd)
52+
configurationImportCmd.Flags().BoolP("new-component", "n", false, "create a new configuration component while importing entry")
53+
configurationImportCmd.Flags().StringP("format", "f", "", "force a specific configuration file type, overriding any file extension")
54+
55+
}

coconut/cmd/configuration_show.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ coconut conf show <component>/<entry>
3838
coconut conf show <component>/<entry> -t <timestamp>
3939
coconut conf show <component>/<entry>@<timestamp>`,
4040
Short: "Show configuration for the component and entry specified",
41-
Long: `The configuration show command requests by default the latest
42-
configuration for the specified component and entry. It can request exact
43-
time configuration by specifying wanted timestamp as flag`,
41+
Long: `The configuration show command returns the most recent
42+
configuration revision for the specified component and entry.
43+
It can also return a specific revision, requested with the --timestamp/-t flag`,
4444
Run: configuration.WrapCall(configuration.Show),
4545
Args: cobra.RangeArgs(0, 3),
4646
}

0 commit comments

Comments
 (0)