Merge "Added new command for Image Build."
This commit is contained in:
commit
f05693a8bf
cmd
baremetal
image
root.gotestdata/TestRootGoldenOutput
docs/source/cli
roles/airshipctl-build-ephemeral-iso/tasks
@ -51,9 +51,6 @@ func NewBaremetalCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Co
|
||||
ejectMediaCmd := NewEjectMediaCommand(rootSettings)
|
||||
baremetalRootCmd.AddCommand(ejectMediaCmd)
|
||||
|
||||
isoGenCmd := NewISOGenCommand(rootSettings)
|
||||
baremetalRootCmd.AddCommand(isoGenCmd)
|
||||
|
||||
powerOffCmd := NewPowerOffCommand(rootSettings)
|
||||
baremetalRootCmd.AddCommand(powerOffCmd)
|
||||
|
||||
|
@ -35,11 +35,6 @@ func TestBaremetal(t *testing.T) {
|
||||
CmdLine: "-h",
|
||||
Cmd: baremetal.NewEjectMediaCommand(nil),
|
||||
},
|
||||
{
|
||||
Name: "baremetal-isogen-with-help",
|
||||
CmdLine: "-h",
|
||||
Cmd: baremetal.NewISOGenCommand(nil),
|
||||
},
|
||||
{
|
||||
Name: "baremetal-poweroff-with-help",
|
||||
CmdLine: "-h",
|
||||
|
@ -1,7 +0,0 @@
|
||||
Generate baremetal host ISO image
|
||||
|
||||
Usage:
|
||||
isogen [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for isogen
|
@ -6,7 +6,6 @@ Usage:
|
||||
Available Commands:
|
||||
ejectmedia Eject media attached to a baremetal host
|
||||
help Help about any command
|
||||
isogen Generate baremetal host ISO image
|
||||
poweroff Shutdown a baremetal host
|
||||
poweron Power on a host
|
||||
powerstatus Retrieve the power status of a baremetal host
|
||||
|
@ -12,7 +12,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package baremetal
|
||||
package image
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
@ -21,11 +21,11 @@ import (
|
||||
"opendev.org/airship/airshipctl/pkg/environment"
|
||||
)
|
||||
|
||||
// NewISOGenCommand creates a new command with the capability to generate the ephemeral node ISO image.
|
||||
func NewISOGenCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
// NewImageBuildCommand creates a new command with the capability to build an ISO image.
|
||||
func NewImageBuildCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "isogen",
|
||||
Short: "Generate baremetal host ISO image",
|
||||
Use: "build",
|
||||
Short: "Build ISO image",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return isogen.GenerateBootstrapIso(rootSettings)
|
||||
},
|
41
cmd/image/image.go
Normal file
41
cmd/image/image.go
Normal 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 image
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"opendev.org/airship/airshipctl/pkg/environment"
|
||||
"opendev.org/airship/airshipctl/pkg/log"
|
||||
)
|
||||
|
||||
// NewImageCommand creates a new command for managing ISO images using airshipctl.
|
||||
func NewImageCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
imageRootCmd := &cobra.Command{
|
||||
Use: "image",
|
||||
Short: "Manage ISO image creation",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
log.Init(rootSettings.Debug, cmd.OutOrStderr())
|
||||
|
||||
// Load or Initialize airship Config
|
||||
rootSettings.InitConfig()
|
||||
},
|
||||
}
|
||||
|
||||
imageBuildCmd := NewImageBuildCommand(rootSettings)
|
||||
imageRootCmd.AddCommand(imageBuildCmd)
|
||||
|
||||
return imageRootCmd
|
||||
}
|
36
cmd/image/image_test.go
Normal file
36
cmd/image/image_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
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 image_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"opendev.org/airship/airshipctl/cmd/image"
|
||||
"opendev.org/airship/airshipctl/testutil"
|
||||
)
|
||||
|
||||
func TestImage(t *testing.T) {
|
||||
tests := []*testutil.CmdTest{
|
||||
{
|
||||
Name: "image-with-help",
|
||||
CmdLine: "-h",
|
||||
Cmd: image.NewImageCommand(nil),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
testutil.RunTest(t, tt)
|
||||
}
|
||||
}
|
13
cmd/image/testdata/TestImageGoldenOutput/image-with-help.golden
vendored
Normal file
13
cmd/image/testdata/TestImageGoldenOutput/image-with-help.golden
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
Manage ISO image creation
|
||||
|
||||
Usage:
|
||||
image [command]
|
||||
|
||||
Available Commands:
|
||||
build Build ISO image
|
||||
help Help about any command
|
||||
|
||||
Flags:
|
||||
-h, --help help for image
|
||||
|
||||
Use "image [command] --help" for more information about a command.
|
@ -27,6 +27,7 @@ import (
|
||||
"opendev.org/airship/airshipctl/cmd/completion"
|
||||
"opendev.org/airship/airshipctl/cmd/config"
|
||||
"opendev.org/airship/airshipctl/cmd/document"
|
||||
"opendev.org/airship/airshipctl/cmd/image"
|
||||
"opendev.org/airship/airshipctl/cmd/phase"
|
||||
"opendev.org/airship/airshipctl/cmd/secret"
|
||||
"opendev.org/airship/airshipctl/pkg/environment"
|
||||
@ -64,6 +65,7 @@ func AddDefaultAirshipCTLCommands(cmd *cobra.Command, settings *environment.Airs
|
||||
cmd.AddCommand(completion.NewCompletionCommand())
|
||||
cmd.AddCommand(document.NewDocumentCommand(settings))
|
||||
cmd.AddCommand(config.NewConfigCommand(settings))
|
||||
cmd.AddCommand(image.NewImageCommand(settings))
|
||||
cmd.AddCommand(secret.NewSecretCommand())
|
||||
cmd.AddCommand(phase.NewPhaseCommand(settings))
|
||||
|
||||
|
@ -10,6 +10,7 @@ Available Commands:
|
||||
config Manage the airshipctl config file
|
||||
document Manage deployment documents
|
||||
help Help about any command
|
||||
image Manage ISO image creation
|
||||
phase Manage phases
|
||||
secret Manage secrets
|
||||
version Show the version number of airshipctl
|
||||
|
@ -22,6 +22,7 @@ A unified entrypoint to various airship components
|
||||
* [airshipctl completion](airshipctl_completion.md) - Generate completion script for the specified shell (bash or zsh)
|
||||
* [airshipctl config](airshipctl_config.md) - Manage the airshipctl config file
|
||||
* [airshipctl document](airshipctl_document.md) - Manage deployment documents
|
||||
* [airshipctl image](airshipctl_image.md) - Manage ISO image creation
|
||||
* [airshipctl phase](airshipctl_phase.md) - Manage phases
|
||||
* [airshipctl secret](airshipctl_secret.md) - Manage secrets
|
||||
* [airshipctl version](airshipctl_version.md) - Show the version number of airshipctl
|
||||
|
@ -24,7 +24,6 @@ Perform actions on baremetal hosts
|
||||
|
||||
* [airshipctl](airshipctl.md) - A unified entrypoint to various airship components
|
||||
* [airshipctl baremetal ejectmedia](airshipctl_baremetal_ejectmedia.md) - Eject media attached to a baremetal host
|
||||
* [airshipctl baremetal isogen](airshipctl_baremetal_isogen.md) - Generate baremetal host ISO image
|
||||
* [airshipctl baremetal poweroff](airshipctl_baremetal_poweroff.md) - Shutdown a baremetal host
|
||||
* [airshipctl baremetal poweron](airshipctl_baremetal_poweron.md) - Power on a host
|
||||
* [airshipctl baremetal powerstatus](airshipctl_baremetal_powerstatus.md) - Retrieve the power status of a baremetal host
|
||||
|
27
docs/source/cli/airshipctl_image.md
Normal file
27
docs/source/cli/airshipctl_image.md
Normal file
@ -0,0 +1,27 @@
|
||||
## airshipctl image
|
||||
|
||||
Manage ISO image creation
|
||||
|
||||
### Synopsis
|
||||
|
||||
Manage ISO image creation
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for image
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
|
||||
--debug enable verbose output
|
||||
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [airshipctl](airshipctl.md) - A unified entrypoint to various airship components
|
||||
* [airshipctl image build](airshipctl_image_build.md) - Build ISO image
|
||||
|
30
docs/source/cli/airshipctl_image_build.md
Normal file
30
docs/source/cli/airshipctl_image_build.md
Normal file
@ -0,0 +1,30 @@
|
||||
## airshipctl image build
|
||||
|
||||
Build ISO image
|
||||
|
||||
### Synopsis
|
||||
|
||||
Build ISO image
|
||||
|
||||
```
|
||||
airshipctl image build [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for build
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config")
|
||||
--debug enable verbose output
|
||||
--kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [airshipctl image](airshipctl_image.md) - Manage ISO image creation
|
||||
|
@ -19,7 +19,7 @@
|
||||
become: yes
|
||||
|
||||
- name: build ephemeral node iso
|
||||
command: airshipctl baremetal isogen
|
||||
command: airshipctl image build
|
||||
environment:
|
||||
http_proxy: "{{ proxy.http }}"
|
||||
https_proxy: "{{ proxy.http }}"
|
||||
|
Loading…
Reference in New Issue
Block a user