From 0a4764e93a3ef7415c04576187af134b30d48234 Mon Sep 17 00:00:00 2001 From: Alexander Hughes Date: Fri, 28 Feb 2020 10:08:35 -0500 Subject: [PATCH] [#58] Make structs golint compliant This patch addresses golint failures such as: pkg/bootstrap/isogen/command_test.go:24:2: struct field getId should be getID pkg/config/types.go:83:2: don't use leading k in Go names; struct field kCluster should be cluster pkg/config/types.go:108:2: don't use leading k in Go names; struct field kContext should be context pkg/config/types.go:113:2: don't use leading k in Go names; struct field kAuthInfo should be authInfo pkg/container/container_docker.go:79:2: struct field imageUrl should be imageURL pkg/container/container_docker_test.go:427:3: struct field imageUrl should be imageURL pkg/remote/redfish/redfish.go:23:2: struct field EphemeralNodeId should be EphemeralNodeID pkg/remote/redfish/redfish.go:29:2: struct field Api should be API Relates-To: #58 Change-Id: Ie8d1c49c9d392f10be0f38224c98b588a9e2a544 Signed-off-by: Alexander Hughes --- pkg/bootstrap/isogen/command_test.go | 8 ++++---- pkg/config/cmds_test.go | 8 ++++---- pkg/config/config.go | 16 ++++++++-------- pkg/config/types.go | 6 +++--- pkg/container/container_docker.go | 10 +++++----- pkg/container/container_docker_test.go | 6 +++--- pkg/remote/redfish/redfish.go | 20 ++++++++++---------- pkg/remote/redfish/redfish_test.go | 4 ++-- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/pkg/bootstrap/isogen/command_test.go b/pkg/bootstrap/isogen/command_test.go index ac81f9b45..d122ac15b 100644 --- a/pkg/bootstrap/isogen/command_test.go +++ b/pkg/bootstrap/isogen/command_test.go @@ -21,7 +21,7 @@ type mockContainer struct { runCommand func() error runCommandOutput func() (io.ReadCloser, error) rmContainer func() error - getId func() string + getID func() string } func (mc *mockContainer) ImagePull() error { @@ -41,7 +41,7 @@ func (mc *mockContainer) RmContainer() error { } func (mc *mockContainer) GetId() string { - return mc.getId() + return mc.getID() } func TestBootstrapIso(t *testing.T) { @@ -91,7 +91,7 @@ func TestBootstrapIso(t *testing.T) { { builder: &mockContainer{ runCommand: func() error { return nil }, - getId: func() string { return "TESTID" }, + getID: func() string { return "TESTID" }, }, cfg: testCfg, debug: true, @@ -101,7 +101,7 @@ func TestBootstrapIso(t *testing.T) { { builder: &mockContainer{ runCommand: func() error { return nil }, - getId: func() string { return "TESTID" }, + getID: func() string { return "TESTID" }, rmContainer: func() error { return testErr }, }, cfg: testCfg, diff --git a/pkg/config/cmds_test.go b/pkg/config/cmds_test.go index f344c5775..d55c6b831 100644 --- a/pkg/config/cmds_test.go +++ b/pkg/config/cmds_test.go @@ -47,7 +47,7 @@ func TestRunGetAuthInfo(t *testing.T) { conf := DummyConfig() secondAuthInfo := DummyAuthInfo() secondUserName := "second_user" - secondAuthInfo.kAuthInfo.Username = secondUserName + secondAuthInfo.authInfo.Username = secondUserName conf.AuthInfos[secondUserName] = secondAuthInfo dummyAuthInfoOptions := DummyAuthInfoOptions() @@ -194,7 +194,7 @@ func TestRunSetAuthInfo(t *testing.T) { modified, err := RunSetAuthInfo(dummyAuthInfoOptions, conf, false) assert.NoError(t, err) assert.True(t, modified) - assert.Equal(t, dummyAuthInfoOptions.Password, conf.AuthInfos["dummy_user"].kAuthInfo.Password) + assert.Equal(t, dummyAuthInfoOptions.Password, conf.AuthInfos["dummy_user"].authInfo.Password) }) } @@ -220,7 +220,7 @@ func TestRunSetCluster(t *testing.T) { assert.True(t, modified) assert.Equal( t, "http://123.45.67.890", - conf.Clusters["dummy_cluster"].ClusterTypes["ephemeral"].kCluster.Server) + conf.Clusters["dummy_cluster"].ClusterTypes["ephemeral"].cluster.Server) }) } @@ -244,7 +244,7 @@ func TestRunSetContext(t *testing.T) { modified, err := RunSetContext(dummyContextOptions, conf, false) assert.NoError(t, err) assert.True(t, modified) - assert.Equal(t, "new_namespace", conf.Contexts["dummy_context"].kContext.Namespace) + assert.Equal(t, "new_namespace", conf.Contexts["dummy_context"].context.Namespace) }) } diff --git a/pkg/config/config.go b/pkg/config/config.go index 02a3bed6c..54f72eca7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -761,10 +761,10 @@ func (c *Cluster) PrettyString() string { } func (c *Cluster) KubeCluster() *clientcmdapi.Cluster { - return c.kCluster + return c.cluster } func (c *Cluster) SetKubeCluster(kc *clientcmdapi.Cluster) { - c.kCluster = kc + c.cluster = kc } // Context functions @@ -774,7 +774,7 @@ func (c *Context) Equal(d *Context) bool { } return c.NameInKubeconf == d.NameInKubeconf && c.Manifest == d.Manifest && - c.kContext == d.kContext + c.context == d.context } func (c *Context) String() string { @@ -799,11 +799,11 @@ func (c *Context) PrettyString() string { } func (c *Context) KubeContext() *clientcmdapi.Context { - return c.kContext + return c.context } func (c *Context) SetKubeContext(kc *clientcmdapi.Context) { - c.kContext = kc + c.context = kc } func (c *Context) ClusterType() string { @@ -817,7 +817,7 @@ func (c *AuthInfo) Equal(d *AuthInfo) bool { if d == nil { return c == d } - return c.kAuthInfo == d.kAuthInfo + return c.authInfo == d.authInfo } func (c *AuthInfo) String() string { @@ -830,10 +830,10 @@ func (c *AuthInfo) String() string { } func (c *AuthInfo) KubeAuthInfo() *clientcmdapi.AuthInfo { - return c.kAuthInfo + return c.authInfo } func (c *AuthInfo) SetKubeAuthInfo(kc *clientcmdapi.AuthInfo) { - c.kAuthInfo = kc + c.authInfo = kc } // Manifest functions diff --git a/pkg/config/types.go b/pkg/config/types.go index c860cc019..be03579a3 100644 --- a/pkg/config/types.go +++ b/pkg/config/types.go @@ -80,7 +80,7 @@ type Cluster struct { NameInKubeconf string `json:"cluster-kubeconf"` // Kubeconfig Cluster Object - kCluster *kubeconfig.Cluster + cluster *kubeconfig.Cluster // Bootstrap configuration this clusters ephemeral hosts will rely on Bootstrap string `json:"bootstrap-info"` @@ -105,12 +105,12 @@ type Context struct { Manifest string `json:"manifest,omitempty"` // Kubeconfig Context Object - kContext *kubeconfig.Context + context *kubeconfig.Context } type AuthInfo struct { // Kubeconfig AuthInfo Object - kAuthInfo *kubeconfig.AuthInfo + authInfo *kubeconfig.AuthInfo } // Manifests is a tuple of references to a Manifest (how do Identify, collect , diff --git a/pkg/container/container_docker.go b/pkg/container/container_docker.go index 9730b59ec..874ceecc7 100644 --- a/pkg/container/container_docker.go +++ b/pkg/container/container_docker.go @@ -76,7 +76,7 @@ type DockerClient interface { // DockerContainer docker container object wrapper type DockerContainer struct { tag string - imageUrl string + imageURL string id string dockerClient DockerClient ctx *context.Context @@ -108,7 +108,7 @@ func NewDockerContainer(ctx *context.Context, url string, cli DockerClient) (*Do cnt := &DockerContainer{ tag: t, - imageUrl: url, + imageURL: url, id: "", dockerClient: cli, ctx: ctx, @@ -134,7 +134,7 @@ func (c *DockerContainer) getCmd(cmd []string) ([]string, error) { return cmd, nil } - id, err := c.getImageId(c.imageUrl) + id, err := c.getImageId(c.imageURL) if err != nil { return nil, err } @@ -154,7 +154,7 @@ func (c *DockerContainer) getConfig( envVars []string, ) (container.Config, container.HostConfig) { cCfg := container.Config{ - Image: c.imageUrl, + Image: c.imageURL, Cmd: cmd, AttachStdin: true, OpenStdin: true, @@ -198,7 +198,7 @@ func (c *DockerContainer) GetId() string { func (c *DockerContainer) ImagePull() error { // TODO (D. Ukov) add logic for searching among local images // to avoid image download on each execution - resp, err := c.dockerClient.ImagePull(*c.ctx, c.imageUrl, types.ImagePullOptions{}) + resp, err := c.dockerClient.ImagePull(*c.ctx, c.imageURL, types.ImagePullOptions{}) if err != nil { return err } diff --git a/pkg/container/container_docker_test.go b/pkg/container/container_docker_test.go index 47507550b..1f56c62e7 100644 --- a/pkg/container/container_docker_test.go +++ b/pkg/container/container_docker_test.go @@ -424,7 +424,7 @@ func TestNewDockerContainer(t *testing.T) { testError := fmt.Errorf("image pull error") type resultStruct struct { tag string - imageUrl string + imageURL string id string } @@ -446,7 +446,7 @@ func TestNewDockerContainer(t *testing.T) { expectedErr: nil, expectedResult: resultStruct{ tag: "testTag", - imageUrl: "testPrefix/testImage:testTag", + imageURL: "testPrefix/testImage:testTag", id: "", }, }, @@ -473,7 +473,7 @@ func TestNewDockerContainer(t *testing.T) { } else { actualResStruct = resultStruct{ tag: actualRes.tag, - imageUrl: actualRes.imageUrl, + imageURL: actualRes.imageURL, id: actualRes.id, } } diff --git a/pkg/remote/redfish/redfish.go b/pkg/remote/redfish/redfish.go index 72c5e63a9..2919b5923 100644 --- a/pkg/remote/redfish/redfish.go +++ b/pkg/remote/redfish/redfish.go @@ -20,13 +20,13 @@ type RedfishRemoteDirect struct { RemoteURL url.URL // ephemeral Host ID - EphemeralNodeId string + EphemeralNodeID string // ISO URL IsoPath string // Redfish Client implementation - Api redfishApi.RedfishAPI + RedfishAPI redfishApi.RedfishAPI } // Top level function to handle Redfish remote direct @@ -36,8 +36,8 @@ func (cfg RedfishRemoteDirect) DoRemoteDirect() error { /* TODO: Add Authentication when redfish library supports it. */ /* Get system details */ - systemID := cfg.EphemeralNodeId - system, _, err := cfg.Api.GetSystem(cfg.Context, systemID) + systemID := cfg.EphemeralNodeID + system, _, err := cfg.RedfishAPI.GetSystem(cfg.Context, systemID) if err != nil { return NewRedfishClientErrorf("Get System[%s] failed with err: %s", systemID, err.Error()) } @@ -48,27 +48,27 @@ func (cfg RedfishRemoteDirect) 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.Api, managerID) + vMediaID, vMediaType, err := GetVirtualMediaID(cfg.Context, cfg.RedfishAPI, managerID) if err != nil { return err } alog.Debugf("Ephemeral Node Virtual Media Id: '%s'", vMediaID) /* Load ISO in manager's virtual media */ - err = SetVirtualMedia(cfg.Context, cfg.Api, managerID, vMediaID, cfg.IsoPath) + err = SetVirtualMedia(cfg.Context, cfg.RedfishAPI, managerID, vMediaID, cfg.IsoPath) if err != nil { return err } alog.Debugf("Successfully loaded virtual media: '%s'", cfg.IsoPath) /* Set system's bootsource to selected media */ - err = SetSystemBootSourceForMediaType(cfg.Context, cfg.Api, systemID, vMediaType) + err = SetSystemBootSourceForMediaType(cfg.Context, cfg.RedfishAPI, systemID, vMediaType) if err != nil { return err } /* Reboot system */ - err = RebootSystem(cfg.Context, cfg.Api, systemID) + err = RebootSystem(cfg.Context, cfg.RedfishAPI, systemID) if err != nil { return err } @@ -123,9 +123,9 @@ func NewRedfishRemoteDirectClient(ctx context.Context, client := RedfishRemoteDirect{ Context: ctx, RemoteURL: *parsedURL, - EphemeralNodeId: ephNodeID, + EphemeralNodeID: ephNodeID, IsoPath: isoPath, - Api: api, + RedfishAPI: api, } return client, nil diff --git a/pkg/remote/redfish/redfish_test.go b/pkg/remote/redfish/redfish_test.go index a995bf94e..bb57bdd13 100644 --- a/pkg/remote/redfish/redfish_test.go +++ b/pkg/remote/redfish/redfish_test.go @@ -66,7 +66,7 @@ func TestRedfishRemoteDirectInvalidSystemId(t *testing.T) { systemID := "invalid-server" localRDCfg := getDefaultRedfishRemoteDirectObj(t, m) - localRDCfg.EphemeralNodeId = systemID + localRDCfg.EphemeralNodeID = systemID realErr := fmt.Errorf("%s system do not exist", systemID) m.On("GetSystem", context.Background(), systemID). @@ -252,7 +252,7 @@ func getDefaultRedfishRemoteDirectObj(t *testing.T, api redfishAPI.RedfishAPI) R require.NoError(t, err) - rDCfg.Api = api + rDCfg.RedfishAPI = api return rDCfg }