From d25c22a5386730c776ee6a61d7e7506bafc4893d Mon Sep 17 00:00:00 2001 From: Drew Walters Date: Wed, 18 Mar 2020 18:56:13 +0000 Subject: [PATCH] Add remote command This change introduces the remote command. The remote command will be used to control the power of remote nodes and eventually include the "bootstrap remotedirect" functionality. This change is merely an outline of the command. No functionality is included in this change. Closes #117 Change-Id: I3291405f36d6a7acc5c8c1f07bd90ad9c2986cd3 Signed-off-by: Drew Walters --- cmd/remote/remote.go | 33 +++++++++++++++++ cmd/remote/remote_test.go | 35 +++++++++++++++++++ .../remote-error-not-implemented.golden | 7 ++++ cmd/root.go | 2 ++ .../rootCmd-with-defaults.golden | 1 + 5 files changed, 78 insertions(+) create mode 100644 cmd/remote/remote.go create mode 100644 cmd/remote/remote_test.go create mode 100644 cmd/remote/testdata/TestRemoteCommandGoldenOutput/remote-error-not-implemented.golden diff --git a/cmd/remote/remote.go b/cmd/remote/remote.go new file mode 100644 index 000000000..eb5c67429 --- /dev/null +++ b/cmd/remote/remote.go @@ -0,0 +1,33 @@ +// 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 remote + +import ( + "github.com/spf13/cobra" + + "opendev.org/airship/airshipctl/pkg/environment" + "opendev.org/airship/airshipctl/pkg/errors" +) + +// NewRemoteCommand creates a new command that provides functionality to control remote entities. +func NewRemoteCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command { + remoteRootCmd := &cobra.Command{ + Use: "remote", + Short: "Control remote entities, i.e. hosts.", + RunE: func(cmd *cobra.Command, args []string) error { + return errors.ErrNotImplemented{} + }, + } + + return remoteRootCmd +} diff --git a/cmd/remote/remote_test.go b/cmd/remote/remote_test.go new file mode 100644 index 000000000..50bc40ff9 --- /dev/null +++ b/cmd/remote/remote_test.go @@ -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 remote + +import ( + "testing" + + "opendev.org/airship/airshipctl/pkg/errors" + "opendev.org/airship/airshipctl/testutil" +) + +func TestRemoteCommand(t *testing.T) { + tests := []*testutil.CmdTest{ + { + Name: "remote-error-not-implemented", + CmdLine: "", + Cmd: NewRemoteCommand(nil), + Error: errors.ErrNotImplemented{}, + }, + } + + for _, tt := range tests { + testutil.RunTest(t, tt) + } +} diff --git a/cmd/remote/testdata/TestRemoteCommandGoldenOutput/remote-error-not-implemented.golden b/cmd/remote/testdata/TestRemoteCommandGoldenOutput/remote-error-not-implemented.golden new file mode 100644 index 000000000..992df392f --- /dev/null +++ b/cmd/remote/testdata/TestRemoteCommandGoldenOutput/remote-error-not-implemented.golden @@ -0,0 +1,7 @@ +Error: Not implemented +Usage: + remote [flags] + +Flags: + -h, --help help for remote + diff --git a/cmd/root.go b/cmd/root.go index bd2d53946..68369ae55 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,6 +13,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/remote" "opendev.org/airship/airshipctl/cmd/secret" "opendev.org/airship/airshipctl/pkg/environment" "opendev.org/airship/airshipctl/pkg/log" @@ -56,6 +57,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(remote.NewRemoteCommand(settings)) cmd.AddCommand(secret.NewSecretCommand()) return cmd diff --git a/cmd/testdata/TestRootGoldenOutput/rootCmd-with-defaults.golden b/cmd/testdata/TestRootGoldenOutput/rootCmd-with-defaults.golden index 343b5ff54..352c2aa3b 100644 --- a/cmd/testdata/TestRootGoldenOutput/rootCmd-with-defaults.golden +++ b/cmd/testdata/TestRootGoldenOutput/rootCmd-with-defaults.golden @@ -10,6 +10,7 @@ Available Commands: config Modify airshipctl config files document manages deployment documents help Help about any command + remote Control remote entities, i.e. hosts. secret manages secrets version Show the version number of airshipctl