Add plan subcommand group frame

Change-Id: Ie90b88ed47fb0050b874eecadafeef3d3fc5f3b1
Relates-To: #395
Relates-To: #385
This commit is contained in:
Dmitry Ukov 2020-12-04 16:45:43 +04:00
parent a5c96cb430
commit 653a553d1c
16 changed files with 354 additions and 2 deletions

View File

@ -21,7 +21,7 @@ import (
) )
const ( const (
clusterLong = ` phaseLong = `
This command provides capabilities for interacting with phases, This command provides capabilities for interacting with phases,
such as getting list and applying specific one. such as getting list and applying specific one.
` `
@ -32,7 +32,7 @@ func NewPhaseCommand(cfgFactory config.Factory) *cobra.Command {
phaseRootCmd := &cobra.Command{ phaseRootCmd := &cobra.Command{
Use: "phase", Use: "phase",
Short: "Manage phases", Short: "Manage phases",
Long: clusterLong[1:], Long: phaseLong[1:],
} }
phaseRootCmd.AddCommand(NewRenderCommand(cfgFactory)) phaseRootCmd.AddCommand(NewRenderCommand(cfgFactory))

41
cmd/plan/list.go Normal file
View File

@ -0,0 +1,41 @@
/*
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
https://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 plan
import (
"github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/errors"
)
const (
listLong = `
List life-cycle plans which were defined in document model.
`
)
// NewListCommand creates a command which prints available phase plans
func NewListCommand(cfgFactory config.Factory) *cobra.Command {
listCmd := &cobra.Command{
Use: "list",
Short: "List plans",
Long: listLong[1:],
RunE: func(cmd *cobra.Command, args []string) error {
return errors.ErrNotImplemented{What: "airshipctl plan list"}
},
}
return listCmd
}

35
cmd/plan/list_test.go Normal file
View File

@ -0,0 +1,35 @@
/*
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
https://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 plan_test
import (
"testing"
"opendev.org/airship/airshipctl/cmd/plan"
"opendev.org/airship/airshipctl/testutil"
)
func TestNewListCommand(t *testing.T) {
tests := []*testutil.CmdTest{
{
Name: "plan-list-cmd-with-help",
CmdLine: "--help",
Cmd: plan.NewListCommand(nil),
},
}
for _, testcase := range tests {
testutil.RunTest(t, testcase)
}
}

42
cmd/plan/plan.go Normal file
View File

@ -0,0 +1,42 @@
/*
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
https://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 plan
import (
"github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config"
)
const (
planLong = `
This command provides capabilities for interacting with plan objects,
responsible for execution phases in groups
`
)
// NewPlanCommand creates a command for interacting with phases
func NewPlanCommand(cfgFactory config.Factory) *cobra.Command {
planRootCmd := &cobra.Command{
Use: "plan",
Short: "Manage plans",
Long: planLong[1:],
}
planRootCmd.AddCommand(NewListCommand(cfgFactory))
planRootCmd.AddCommand(NewRunCommand(cfgFactory))
return planRootCmd
}

35
cmd/plan/plan_test.go Normal file
View File

@ -0,0 +1,35 @@
/*
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
https://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 plan_test
import (
"testing"
"opendev.org/airship/airshipctl/cmd/plan"
"opendev.org/airship/airshipctl/testutil"
)
func TestNewPlanCommand(t *testing.T) {
tests := []*testutil.CmdTest{
{
Name: "plan-cmd-with-help",
CmdLine: "--help",
Cmd: plan.NewPlanCommand(nil),
},
}
for _, testcase := range tests {
testutil.RunTest(t, testcase)
}
}

42
cmd/plan/run.go Normal file
View File

@ -0,0 +1,42 @@
/*
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
https://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 plan
import (
"github.com/spf13/cobra"
"opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/errors"
)
const (
runLong = `
Run life-cycle phase plan which was defined in document model.
`
)
// NewRunCommand creates a command which execute a particular phase plan
func NewRunCommand(cfgFactory config.Factory) *cobra.Command {
listCmd := &cobra.Command{
Use: "run PLAN_NAME",
Short: "Run plan",
Long: runLong[1:],
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return errors.ErrNotImplemented{What: "airshipctl plan run"}
},
}
return listCmd
}

35
cmd/plan/run_test.go Normal file
View File

@ -0,0 +1,35 @@
/*
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
https://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 plan_test
import (
"testing"
"opendev.org/airship/airshipctl/cmd/plan"
"opendev.org/airship/airshipctl/testutil"
)
func TestNewRunCommand(t *testing.T) {
tests := []*testutil.CmdTest{
{
Name: "plan-run-with-help",
CmdLine: "--help",
Cmd: plan.NewRunCommand(nil),
},
}
for _, testcase := range tests {
testutil.RunTest(t, testcase)
}
}

View File

@ -0,0 +1,7 @@
List life-cycle plans which were defined in document model.
Usage:
list [flags]
Flags:
-h, --help help for list

View File

@ -0,0 +1,15 @@
This command provides capabilities for interacting with plan objects,
responsible for execution phases in groups
Usage:
plan [command]
Available Commands:
help Help about any command
list List plans
run Run plan
Flags:
-h, --help help for plan
Use "plan [command] --help" for more information about a command.

View File

@ -0,0 +1,7 @@
Run life-cycle phase plan which was defined in document model.
Usage:
run PLAN_NAME [flags]
Flags:
-h, --help help for run

View File

@ -29,6 +29,7 @@ import (
"opendev.org/airship/airshipctl/cmd/document" "opendev.org/airship/airshipctl/cmd/document"
"opendev.org/airship/airshipctl/cmd/image" "opendev.org/airship/airshipctl/cmd/image"
"opendev.org/airship/airshipctl/cmd/phase" "opendev.org/airship/airshipctl/cmd/phase"
"opendev.org/airship/airshipctl/cmd/plan"
"opendev.org/airship/airshipctl/cmd/secret" "opendev.org/airship/airshipctl/cmd/secret"
cfg "opendev.org/airship/airshipctl/pkg/config" cfg "opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/log" "opendev.org/airship/airshipctl/pkg/log"
@ -77,6 +78,7 @@ func AddDefaultAirshipCTLCommands(cmd *cobra.Command, factory cfg.Factory) *cobr
cmd.AddCommand(image.NewImageCommand(factory)) cmd.AddCommand(image.NewImageCommand(factory))
cmd.AddCommand(secret.NewSecretCommand(factory)) cmd.AddCommand(secret.NewSecretCommand(factory))
cmd.AddCommand(phase.NewPhaseCommand(factory)) cmd.AddCommand(phase.NewPhaseCommand(factory))
cmd.AddCommand(plan.NewPlanCommand(factory))
cmd.AddCommand(NewVersionCommand()) cmd.AddCommand(NewVersionCommand())
return cmd return cmd

View File

@ -12,6 +12,7 @@ Available Commands:
help Help about any command help Help about any command
image Manage ISO image creation image Manage ISO image creation
phase Manage phases phase Manage phases
plan Manage plans
secret Manage secrets secret Manage secrets
version Show the version number of airshipctl version Show the version number of airshipctl

View File

@ -23,6 +23,7 @@ A unified entrypoint to various airship components
* [airshipctl document](airshipctl_document.md) - Manage deployment documents * [airshipctl document](airshipctl_document.md) - Manage deployment documents
* [airshipctl image](airshipctl_image.md) - Manage ISO image creation * [airshipctl image](airshipctl_image.md) - Manage ISO image creation
* [airshipctl phase](airshipctl_phase.md) - Manage phases * [airshipctl phase](airshipctl_phase.md) - Manage phases
* [airshipctl plan](airshipctl_plan.md) - Manage plans
* [airshipctl secret](airshipctl_secret.md) - Manage secrets * [airshipctl secret](airshipctl_secret.md) - Manage secrets
* [airshipctl version](airshipctl_version.md) - Show the version number of airshipctl * [airshipctl version](airshipctl_version.md) - Show the version number of airshipctl

View File

@ -0,0 +1,29 @@
## airshipctl plan
Manage plans
### Synopsis
This command provides capabilities for interacting with plan objects,
responsible for execution phases in groups
### Options
```
-h, --help help for plan
```
### Options inherited from parent commands
```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output
```
### SEE ALSO
* [airshipctl](airshipctl.md) - A unified entrypoint to various airship components
* [airshipctl plan list](airshipctl_plan_list.md) - List plans
* [airshipctl plan run](airshipctl_plan_run.md) - Run plan

View File

@ -0,0 +1,30 @@
## airshipctl plan list
List plans
### Synopsis
List life-cycle plans which were defined in document model.
```
airshipctl plan list [flags]
```
### Options
```
-h, --help help for list
```
### Options inherited from parent commands
```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output
```
### SEE ALSO
* [airshipctl plan](airshipctl_plan.md) - Manage plans

View File

@ -0,0 +1,30 @@
## airshipctl plan run
Run plan
### Synopsis
Run life-cycle phase plan which was defined in document model.
```
airshipctl plan run PLAN_NAME [flags]
```
### Options
```
-h, --help help for run
```
### Options inherited from parent commands
```
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
--debug enable verbose output
```
### SEE ALSO
* [airshipctl plan](airshipctl_plan.md) - Manage plans