[AIR-203] add airshipctl config init subcommand

This commit is only base for future implementation

Change-Id: I3cfb3508de04d0a717245a75b5b197fda68fd01c
This commit is contained in:
Kostiantyn Kalynovskyi 2020-01-28 17:16:11 +00:00
parent 0528b76b9c
commit 8c6ebb66d9
6 changed files with 90 additions and 0 deletions

View File

@ -19,6 +19,7 @@ like "airshipctl config set-current-context my-context" `),
configRootCmd.AddCommand(NewCmdConfigGetCluster(rootSettings))
configRootCmd.AddCommand(NewCmdConfigSetContext(rootSettings))
configRootCmd.AddCommand(NewCmdConfigGetContext(rootSettings))
configRootCmd.AddCommand(NewCmdConfigInit(rootSettings))
return configRootCmd
}

41
cmd/config/init.go Normal file
View File

@ -0,0 +1,41 @@
/*l
Copyright 2014 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package config
import (
"github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/environment"
"opendev.org/airship/airshipctl/pkg/errors"
)
var (
configInitLong = (`Generate initial configuration files for airshipctl`)
)
// NewCmdConfigInit returns a Command instance for 'config init' sub command
func NewCmdConfigInit(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
configInitCmd := &cobra.Command{
Use: "init",
Short: configInitLong,
RunE: func(cmd *cobra.Command, args []string) error {
return errors.ErrNotImplemented{}
},
}
return configInitCmd
}

39
cmd/config/init_test.go Normal file
View File

@ -0,0 +1,39 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package config
import (
"testing"
"opendev.org/airship/airshipctl/pkg/errors"
"opendev.org/airship/airshipctl/testutil"
)
func TestConfigInit(t *testing.T) {
cmdTests := []*testutil.CmdTest{
{
Name: "config-init",
CmdLine: "",
Cmd: NewCmdConfigInit(nil),
Error: errors.ErrNotImplemented{},
},
}
for _, tt := range cmdTests {
testutil.RunTest(t, tt)
}
}

View File

@ -8,6 +8,7 @@ Available Commands:
get-cluster Display a specific cluster or all defined clusters if no name is provided
get-context Display a specific context, the current-context or all defined contexts if no name is provided
help Help about any command
init Generate initial configuration files for airshipctl
set-cluster Sets a cluster entry in the airshipctl config
set-context Sets a context entry or updates current-context in the airshipctl config

View File

@ -8,6 +8,7 @@ Available Commands:
get-cluster Display a specific cluster or all defined clusters if no name is provided
get-context Display a specific context, the current-context or all defined contexts if no name is provided
help Help about any command
init Generate initial configuration files for airshipctl
set-cluster Sets a cluster entry in the airshipctl config
set-context Sets a context entry or updates current-context in the airshipctl config

View File

@ -0,0 +1,7 @@
Error: Not implemented
Usage:
init [flags]
Flags:
-h, --help help for init