[#86] remove unused code
A number of items were identified by GoLand's code inspection as being unused. These are being removed in this change. Change-Id: I0c8c0b5f5c33f2e715f991a02ddd63174758c533 Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
This commit is contained in:
parent
26fdd05b0f
commit
7549fdbeb0
@ -13,7 +13,7 @@ func NewBootstrapCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Co
|
||||
Short: "Bootstrap ephemeral Kubernetes cluster",
|
||||
}
|
||||
|
||||
isoGenCmd := NewISOGenCommand(bootstrapRootCmd, rootSettings)
|
||||
isoGenCmd := NewISOGenCommand(rootSettings)
|
||||
bootstrapRootCmd.AddCommand(isoGenCmd)
|
||||
|
||||
remoteDirectCmd := NewRemoteDirectCommand(rootSettings)
|
||||
|
@ -8,12 +8,12 @@ import (
|
||||
)
|
||||
|
||||
// NewISOGenCommand creates a new command for ISO image creation
|
||||
func NewISOGenCommand(parent *cobra.Command, rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
func NewISOGenCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
imageGen := &cobra.Command{
|
||||
Use: "isogen",
|
||||
Short: "Generate bootstrap ISO image",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return isogen.GenerateBootstrapIso(rootSettings, args)
|
||||
return isogen.GenerateBootstrapIso(rootSettings)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ func NewDocumentCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Com
|
||||
}
|
||||
|
||||
documentRootCmd.AddCommand(NewDocumentPullCommand(rootSettings))
|
||||
documentRootCmd.AddCommand(secret.NewSecretCommand(rootSettings))
|
||||
documentRootCmd.AddCommand(secret.NewSecretCommand())
|
||||
documentRootCmd.AddCommand(NewRenderCommand(rootSettings))
|
||||
|
||||
return documentRootCmd
|
||||
|
@ -1,20 +1,16 @@
|
||||
package generate
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"opendev.org/airship/airshipctl/pkg/environment"
|
||||
)
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
// NewGenerateCommand creates a new command for generating secret information
|
||||
func NewGenerateCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
func NewGenerateCommand() *cobra.Command {
|
||||
generateRootCmd := &cobra.Command{
|
||||
Use: "generate",
|
||||
// TODO(howell): Make this more expressive
|
||||
Short: "generates various secrets",
|
||||
}
|
||||
|
||||
generateRootCmd.AddCommand(NewGenerateMasterPassphraseCommand(rootSettings))
|
||||
generateRootCmd.AddCommand(NewGenerateMasterPassphraseCommand())
|
||||
|
||||
return generateRootCmd
|
||||
}
|
||||
|
@ -5,12 +5,11 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"opendev.org/airship/airshipctl/pkg/environment"
|
||||
"opendev.org/airship/airshipctl/pkg/secret"
|
||||
)
|
||||
|
||||
// NewGenerateMasterPassphraseCommand creates a new command for generating secret information
|
||||
func NewGenerateMasterPassphraseCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
func NewGenerateMasterPassphraseCommand() *cobra.Command {
|
||||
masterPassphraseCmd := &cobra.Command{
|
||||
Use: "masterpassphrase",
|
||||
// TODO(howell): Make this more expressive
|
||||
|
@ -4,18 +4,17 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"opendev.org/airship/airshipctl/cmd/document/secret/generate"
|
||||
"opendev.org/airship/airshipctl/pkg/environment"
|
||||
)
|
||||
|
||||
// NewSecretCommand creates a new command for managing airshipctl secrets
|
||||
func NewSecretCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command {
|
||||
func NewSecretCommand() *cobra.Command {
|
||||
secretRootCmd := &cobra.Command{
|
||||
Use: "secret",
|
||||
// TODO(howell): Make this more expressive
|
||||
Short: "manages secrets",
|
||||
}
|
||||
|
||||
secretRootCmd.AddCommand(generate.NewGenerateCommand(rootSettings))
|
||||
secretRootCmd.AddCommand(generate.NewGenerateCommand())
|
||||
|
||||
return secretRootCmd
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ const (
|
||||
)
|
||||
|
||||
// GenerateBootstrapIso will generate data for cloud init and start ISO builder container
|
||||
func GenerateBootstrapIso(settings *environment.AirshipCTLSettings, args []string) error {
|
||||
func GenerateBootstrapIso(settings *environment.AirshipCTLSettings) error {
|
||||
ctx := context.Background()
|
||||
|
||||
globalConf := settings.Config()
|
||||
|
@ -26,18 +26,6 @@ type TestClient struct {
|
||||
func (tc TestClient) ClientSet() kubernetes.Interface { return tc.MockClientset() }
|
||||
func (tc TestClient) Kubectl() kubectl.Interface { return tc.MockKubectl() }
|
||||
|
||||
type TestKubectl struct {
|
||||
MockApply func() error
|
||||
MockApplyOptions func() (*kubectl.ApplyOptions, error)
|
||||
}
|
||||
|
||||
func (tk TestKubectl) Apply(docs []document.Document, ao *kubectl.ApplyOptions) error {
|
||||
return tk.MockApply()
|
||||
}
|
||||
func (tk TestKubectl) ApplyOptions() (*kubectl.ApplyOptions, error) {
|
||||
return tk.MockApplyOptions()
|
||||
}
|
||||
|
||||
const (
|
||||
kubeconfigPath = "testdata/kubeconfig.yaml"
|
||||
filenameRC = "testdata/replicationcontroller.yaml"
|
||||
|
@ -20,14 +20,11 @@ const (
|
||||
AirshipConfigVersion = "v1alpha1"
|
||||
AirshipConfigAPIVersion = AirshipConfigGroup + "/" + AirshipConfigVersion
|
||||
AirshipConfigKind = "Config"
|
||||
|
||||
AirshipConfigDir = ".airship"
|
||||
AirshipConfig = "config"
|
||||
AirshipKubeConfig = "kubeconfig"
|
||||
|
||||
AirshipConfigEnv = "AIRSHIPCONFIG"
|
||||
AirshipKubeConfigEnv = "AIRSHIP_KUBECONFIG"
|
||||
|
||||
AirshipDefaultContext = "default"
|
||||
AirshipDefaultManifest = "default"
|
||||
AirshipDefaultManifestRepo = "treasuremap"
|
||||
@ -39,7 +36,6 @@ const (
|
||||
AirshipDefaultRemoteType = "redfish"
|
||||
)
|
||||
|
||||
// Constants defining CLI flags
|
||||
const (
|
||||
FlagAPIServer = "server"
|
||||
FlagAuthInfoName = "user"
|
||||
@ -48,18 +44,17 @@ const (
|
||||
FlagCertFile = "client-certificate"
|
||||
FlagClusterName = "cluster"
|
||||
FlagClusterType = "cluster-type"
|
||||
FlagContext = "context"
|
||||
|
||||
FlagCurrentContext = "current-context"
|
||||
FlagConfigFilePath = "airshipconf"
|
||||
FlagEmbedCerts = "embed-certs"
|
||||
FlagImpersonate = "as"
|
||||
FlagImpersonateGroup = "as-group"
|
||||
|
||||
FlagInsecure = "insecure-skip-tls-verify"
|
||||
FlagKeyFile = "client-key"
|
||||
FlagManifest = "manifest"
|
||||
FlagNamespace = "namespace"
|
||||
FlagPassword = "password"
|
||||
FlagTimeout = "request-timeout"
|
||||
|
||||
FlagUsername = "username"
|
||||
FlagCurrent = "current"
|
||||
)
|
||||
|
@ -218,7 +218,7 @@ func (c *DockerContainer) RunCommand(
|
||||
volumeMounts []string,
|
||||
envVars []string,
|
||||
// TODO (D. Ukov) add debug logic
|
||||
debug bool,
|
||||
_ bool,
|
||||
) error {
|
||||
realCmd, err := c.getCmd(cmd)
|
||||
if err != nil {
|
||||
|
@ -30,9 +30,9 @@ func (mc mockConn) Write(b []byte) (n int, err error) {
|
||||
func (mc mockConn) Close() error { return nil }
|
||||
func (mc mockConn) LocalAddr() net.Addr { return nil }
|
||||
func (mc mockConn) RemoteAddr() net.Addr { return nil }
|
||||
func (mc mockConn) SetDeadline(t time.Time) error { return nil }
|
||||
func (mc mockConn) SetReadDeadline(t time.Time) error { return nil }
|
||||
func (mc mockConn) SetWriteDeadline(t time.Time) error { return nil }
|
||||
func (mc mockConn) SetDeadline(time.Time) error { return nil }
|
||||
func (mc mockConn) SetReadDeadline(time.Time) error { return nil }
|
||||
func (mc mockConn) SetWriteDeadline(time.Time) error { return nil }
|
||||
|
||||
type mockDockerClient struct {
|
||||
imageInspectWithRaw func() (types.ImageInspect, []byte, error)
|
||||
|
@ -1,11 +1,9 @@
|
||||
package document
|
||||
|
||||
// Document labels and annotations
|
||||
const (
|
||||
// Selectors
|
||||
BaseAirshipSelector = "airshipit.org"
|
||||
EphemeralClusterSelector = BaseAirshipSelector + "/ephemeral in (True, true)"
|
||||
TargetClusterSelector = BaseAirshipSelector + "/target in (True, true)"
|
||||
|
||||
// Labels
|
||||
DeployedByLabel = BaseAirshipSelector + "/deployed"
|
||||
|
@ -17,17 +17,8 @@ import (
|
||||
"opendev.org/airship/airshipctl/pkg/log"
|
||||
)
|
||||
|
||||
const (
|
||||
SSHAuth = "ssh-key"
|
||||
SSHPass = "ssh-pass"
|
||||
HTTPBasic = "http-basic"
|
||||
|
||||
DefaultRemoteName = "origin"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNoOpenRepo = errors.New("no open repository is stored")
|
||||
ErrRemoteRefNotImplemented = errors.New("remoteref is not yet implemented")
|
||||
ErrCantParseURL = errors.New("could not get target directory from url")
|
||||
)
|
||||
|
||||
|
@ -27,13 +27,13 @@ type mockBuilder struct {
|
||||
func (md mockBuilder) ToAuth() (transport.AuthMethod, error) {
|
||||
return md.AuthMethod, md.AuthError
|
||||
}
|
||||
func (md mockBuilder) ToCloneOptions(auth transport.AuthMethod) *git.CloneOptions {
|
||||
func (md mockBuilder) ToCloneOptions(transport.AuthMethod) *git.CloneOptions {
|
||||
return md.CloneOptions
|
||||
}
|
||||
func (md mockBuilder) ToCheckoutOptions(force bool) *git.CheckoutOptions {
|
||||
func (md mockBuilder) ToCheckoutOptions(bool) *git.CheckoutOptions {
|
||||
return md.CheckoutOptions
|
||||
}
|
||||
func (md mockBuilder) ToFetchOptions(auth transport.AuthMethod) *git.FetchOptions {
|
||||
func (md mockBuilder) ToFetchOptions(transport.AuthMethod) *git.FetchOptions {
|
||||
return md.FetchOptions
|
||||
}
|
||||
func (md mockBuilder) URL() string { return md.URLString }
|
||||
|
@ -3,13 +3,4 @@ package environment
|
||||
// OutputFormat denotes the form with which to display tabulated data
|
||||
type OutputFormat string
|
||||
|
||||
// These are valid values for OutputFormat
|
||||
const (
|
||||
Default = ""
|
||||
JSON = "json"
|
||||
YAML = "yaml"
|
||||
NameOnly = "name"
|
||||
Wide = "wide"
|
||||
)
|
||||
|
||||
const HomeEnvVar = "$HOME"
|
||||
|
@ -28,8 +28,8 @@ type MockFileSystem struct {
|
||||
document.FileSystem
|
||||
}
|
||||
|
||||
func (fsys MockFileSystem) RemoveAll(name string) error { return fsys.MockRemoveAll() }
|
||||
func (fsys MockFileSystem) TempFile(bufferDir string, prefix string) (document.File, error) {
|
||||
func (fsys MockFileSystem) RemoveAll(string) error { return fsys.MockRemoveAll() }
|
||||
func (fsys MockFileSystem) TempFile(string, string) (document.File, error) {
|
||||
return fsys.MockTempFile()
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ func (cfg RemoteDirect) DoRemoteDirect() error {
|
||||
alog.Debugf("Ephemeral node managerID: '%s'", managerID)
|
||||
|
||||
/* Get manager's Cd or DVD virtual media ID */
|
||||
vMediaID, vMediaType, err := GetVirtualMediaID(cfg.Context, cfg.RedfishAPI, managerID)
|
||||
vMediaID, vMediaType, err := GetVirtualMediaID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -46,10 +46,7 @@ func IsIDInList(idRefList []redfishClient.IdRef, id string) bool {
|
||||
|
||||
// This function walks through the list of manager's virtual media resources
|
||||
// and gets the ID of virtualmedia which has type "CD" or "DVD"
|
||||
func GetVirtualMediaID(ctx context.Context,
|
||||
api redfishApi.RedfishAPI,
|
||||
managerID string,
|
||||
) (string, string, error) {
|
||||
func GetVirtualMediaID() (string, string, error) {
|
||||
// TODO: Sushy emulator has a bug which sends 'virtualMedia.inserted' field as
|
||||
// string instead of a boolean which causes the redfish client to fail
|
||||
// while unmarshalling this field.
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
|
||||
const (
|
||||
AirshipRemoteTypeRedfish string = "redfish"
|
||||
AirshipRemoteTypeSmash string = "smash"
|
||||
AirshipHostKind string = "BareMetalHost"
|
||||
)
|
||||
|
||||
|
@ -49,7 +49,7 @@ func (f *MockKubectlFactory) ToDiscoveryClient() (discovery.CachedDiscoveryInter
|
||||
}
|
||||
func (f *MockKubectlFactory) DynamicClient() (dynamic.Interface, error) { return f.MockDynamicClient() }
|
||||
func (f *MockKubectlFactory) OpenAPISchema() (openapi.Resources, error) { return f.MockOpenAPISchema() }
|
||||
func (f *MockKubectlFactory) Validator(validate bool) (validation.Schema, error) {
|
||||
func (f *MockKubectlFactory) Validator(bool) (validation.Schema, error) {
|
||||
return f.MockValidator()
|
||||
}
|
||||
func (f *MockKubectlFactory) ToRESTMapper() (meta.RESTMapper, error) { return f.MockToRESTMapper() }
|
||||
|
@ -63,20 +63,6 @@ func RunTest(t *testing.T, test *CmdTest) {
|
||||
}
|
||||
}
|
||||
|
||||
// ReadFixtureBytes is a convenience function for opening a test fixture
|
||||
func ReadFixtureBytes(t *testing.T, filename string) []byte {
|
||||
t.Helper()
|
||||
fixtureData, err := ioutil.ReadFile(filename)
|
||||
require.NoErrorf(t, err, "Unexpected error while reading fixture at %s", filename)
|
||||
return fixtureData
|
||||
}
|
||||
|
||||
// ReadFixtureString is a convenience function for opening a test fixture
|
||||
func ReadFixtureString(t *testing.T, filename string) string {
|
||||
t.Helper()
|
||||
return string(ReadFixtureBytes(t, filename))
|
||||
}
|
||||
|
||||
func updateGolden(t *testing.T, test *CmdTest, actual []byte) {
|
||||
t.Helper()
|
||||
goldenDir := filepath.Join(testdataDir, t.Name()+goldenDirSuffix)
|
||||
|
Loading…
Reference in New Issue
Block a user