Merge "Phase Validation: cmd changes to support Phase Validation sub command"
This commit is contained in:
commit
12d4b63a3d
@ -39,6 +39,7 @@ func NewPhaseCommand(cfgFactory config.Factory) *cobra.Command {
|
|||||||
phaseRootCmd.AddCommand(NewListCommand(cfgFactory))
|
phaseRootCmd.AddCommand(NewListCommand(cfgFactory))
|
||||||
phaseRootCmd.AddCommand(NewRunCommand(cfgFactory))
|
phaseRootCmd.AddCommand(NewRunCommand(cfgFactory))
|
||||||
phaseRootCmd.AddCommand(NewTreeCommand(cfgFactory))
|
phaseRootCmd.AddCommand(NewTreeCommand(cfgFactory))
|
||||||
|
phaseRootCmd.AddCommand(NewValidateCommand(cfgFactory))
|
||||||
|
|
||||||
return phaseRootCmd
|
return phaseRootCmd
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ Available Commands:
|
|||||||
render Render phase documents from model
|
render Render phase documents from model
|
||||||
run Run phase
|
run Run phase
|
||||||
tree Tree view of kustomize entrypoints of phase
|
tree Tree view of kustomize entrypoints of phase
|
||||||
|
validate Assert that a phase is valid
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for phase
|
-h, --help help for phase
|
||||||
|
13
cmd/phase/testdata/TestValidateGoldenOutput/validate-with-help.golden
vendored
Normal file
13
cmd/phase/testdata/TestValidateGoldenOutput/validate-with-help.golden
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Command which would validate that the phase contains the required documents to run the phase.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
validate PHASE_NAME [flags]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
# validate initinfra phase
|
||||||
|
airshipctl phase validate initinfra
|
||||||
|
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
-h, --help help for validate
|
54
cmd/phase/validate.go
Normal file
54
cmd/phase/validate.go
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
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 phase
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"opendev.org/airship/airshipctl/pkg/config"
|
||||||
|
"opendev.org/airship/airshipctl/pkg/phase"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
validLong = `Command which would validate that the phase contains ` +
|
||||||
|
`the required documents to run the phase.
|
||||||
|
`
|
||||||
|
|
||||||
|
validExample = `
|
||||||
|
# validate initinfra phase
|
||||||
|
airshipctl phase validate initinfra
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewValidateCommand creates a command to assert that a phase is valid is to actually run the phase.
|
||||||
|
func NewValidateCommand(cfgFactory config.Factory) *cobra.Command {
|
||||||
|
p := &phase.ValidateCommand{
|
||||||
|
Options: phase.ValidateFlags{},
|
||||||
|
Factory: cfgFactory,
|
||||||
|
}
|
||||||
|
validCmd := &cobra.Command{
|
||||||
|
Use: "validate PHASE_NAME",
|
||||||
|
Short: "Assert that a phase is valid",
|
||||||
|
Long: validLong,
|
||||||
|
Args: cobra.ExactArgs(1),
|
||||||
|
Example: validExample,
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
p.Options.PhaseID.Name = args[0]
|
||||||
|
return p.RunE()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return validCmd
|
||||||
|
}
|
35
cmd/phase/validate_test.go
Normal file
35
cmd/phase/validate_test.go
Normal 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 phase_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"opendev.org/airship/airshipctl/cmd/phase"
|
||||||
|
"opendev.org/airship/airshipctl/testutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestValidate(t *testing.T) {
|
||||||
|
tests := []*testutil.CmdTest{
|
||||||
|
{
|
||||||
|
Name: "validate-with-help",
|
||||||
|
CmdLine: "-h",
|
||||||
|
Cmd: phase.NewValidateCommand(nil),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
testutil.RunTest(t, tt)
|
||||||
|
}
|
||||||
|
}
|
@ -28,4 +28,5 @@ such as getting list and applying specific one.
|
|||||||
* [airshipctl phase render](airshipctl_phase_render.md) - Render phase documents from model
|
* [airshipctl phase render](airshipctl_phase_render.md) - Render phase documents from model
|
||||||
* [airshipctl phase run](airshipctl_phase_run.md) - Run phase
|
* [airshipctl phase run](airshipctl_phase_run.md) - Run phase
|
||||||
* [airshipctl phase tree](airshipctl_phase_tree.md) - Tree view of kustomize entrypoints of phase
|
* [airshipctl phase tree](airshipctl_phase_tree.md) - Tree view of kustomize entrypoints of phase
|
||||||
|
* [airshipctl phase validate](airshipctl_phase_validate.md) - Validate phase
|
||||||
|
|
||||||
|
38
docs/source/cli/airshipctl_phase_validate.md
Normal file
38
docs/source/cli/airshipctl_phase_validate.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
## airshipctl phase validate
|
||||||
|
|
||||||
|
Assert that a phase is valid
|
||||||
|
|
||||||
|
### Synopsis
|
||||||
|
|
||||||
|
Command which would validate that the phase contains the required documents to run the phase
|
||||||
|
|
||||||
|
```
|
||||||
|
airshipctl phase validate PHASE_NAME [flags]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
# validate initinfra phase
|
||||||
|
airshipctl phase validate initinfra
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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 phase](airshipctl_phase.md) - Manage phases
|
||||||
|
|
Loading…
Reference in New Issue
Block a user