[#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 <Alexander.Hughes@pm.me>
This commit is contained in:
parent
27825bdf2c
commit
0a4764e93a
@ -21,7 +21,7 @@ type mockContainer struct {
|
|||||||
runCommand func() error
|
runCommand func() error
|
||||||
runCommandOutput func() (io.ReadCloser, error)
|
runCommandOutput func() (io.ReadCloser, error)
|
||||||
rmContainer func() error
|
rmContainer func() error
|
||||||
getId func() string
|
getID func() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *mockContainer) ImagePull() error {
|
func (mc *mockContainer) ImagePull() error {
|
||||||
@ -41,7 +41,7 @@ func (mc *mockContainer) RmContainer() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mc *mockContainer) GetId() string {
|
func (mc *mockContainer) GetId() string {
|
||||||
return mc.getId()
|
return mc.getID()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBootstrapIso(t *testing.T) {
|
func TestBootstrapIso(t *testing.T) {
|
||||||
@ -91,7 +91,7 @@ func TestBootstrapIso(t *testing.T) {
|
|||||||
{
|
{
|
||||||
builder: &mockContainer{
|
builder: &mockContainer{
|
||||||
runCommand: func() error { return nil },
|
runCommand: func() error { return nil },
|
||||||
getId: func() string { return "TESTID" },
|
getID: func() string { return "TESTID" },
|
||||||
},
|
},
|
||||||
cfg: testCfg,
|
cfg: testCfg,
|
||||||
debug: true,
|
debug: true,
|
||||||
@ -101,7 +101,7 @@ func TestBootstrapIso(t *testing.T) {
|
|||||||
{
|
{
|
||||||
builder: &mockContainer{
|
builder: &mockContainer{
|
||||||
runCommand: func() error { return nil },
|
runCommand: func() error { return nil },
|
||||||
getId: func() string { return "TESTID" },
|
getID: func() string { return "TESTID" },
|
||||||
rmContainer: func() error { return testErr },
|
rmContainer: func() error { return testErr },
|
||||||
},
|
},
|
||||||
cfg: testCfg,
|
cfg: testCfg,
|
||||||
|
@ -47,7 +47,7 @@ func TestRunGetAuthInfo(t *testing.T) {
|
|||||||
conf := DummyConfig()
|
conf := DummyConfig()
|
||||||
secondAuthInfo := DummyAuthInfo()
|
secondAuthInfo := DummyAuthInfo()
|
||||||
secondUserName := "second_user"
|
secondUserName := "second_user"
|
||||||
secondAuthInfo.kAuthInfo.Username = secondUserName
|
secondAuthInfo.authInfo.Username = secondUserName
|
||||||
conf.AuthInfos[secondUserName] = secondAuthInfo
|
conf.AuthInfos[secondUserName] = secondAuthInfo
|
||||||
|
|
||||||
dummyAuthInfoOptions := DummyAuthInfoOptions()
|
dummyAuthInfoOptions := DummyAuthInfoOptions()
|
||||||
@ -194,7 +194,7 @@ func TestRunSetAuthInfo(t *testing.T) {
|
|||||||
modified, err := RunSetAuthInfo(dummyAuthInfoOptions, conf, false)
|
modified, err := RunSetAuthInfo(dummyAuthInfoOptions, conf, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, modified)
|
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.True(t, modified)
|
||||||
assert.Equal(
|
assert.Equal(
|
||||||
t, "http://123.45.67.890",
|
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)
|
modified, err := RunSetContext(dummyContextOptions, conf, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, modified)
|
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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,10 +761,10 @@ func (c *Cluster) PrettyString() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) KubeCluster() *clientcmdapi.Cluster {
|
func (c *Cluster) KubeCluster() *clientcmdapi.Cluster {
|
||||||
return c.kCluster
|
return c.cluster
|
||||||
}
|
}
|
||||||
func (c *Cluster) SetKubeCluster(kc *clientcmdapi.Cluster) {
|
func (c *Cluster) SetKubeCluster(kc *clientcmdapi.Cluster) {
|
||||||
c.kCluster = kc
|
c.cluster = kc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Context functions
|
// Context functions
|
||||||
@ -774,7 +774,7 @@ func (c *Context) Equal(d *Context) bool {
|
|||||||
}
|
}
|
||||||
return c.NameInKubeconf == d.NameInKubeconf &&
|
return c.NameInKubeconf == d.NameInKubeconf &&
|
||||||
c.Manifest == d.Manifest &&
|
c.Manifest == d.Manifest &&
|
||||||
c.kContext == d.kContext
|
c.context == d.context
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) String() string {
|
func (c *Context) String() string {
|
||||||
@ -799,11 +799,11 @@ func (c *Context) PrettyString() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) KubeContext() *clientcmdapi.Context {
|
func (c *Context) KubeContext() *clientcmdapi.Context {
|
||||||
return c.kContext
|
return c.context
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) SetKubeContext(kc *clientcmdapi.Context) {
|
func (c *Context) SetKubeContext(kc *clientcmdapi.Context) {
|
||||||
c.kContext = kc
|
c.context = kc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Context) ClusterType() string {
|
func (c *Context) ClusterType() string {
|
||||||
@ -817,7 +817,7 @@ func (c *AuthInfo) Equal(d *AuthInfo) bool {
|
|||||||
if d == nil {
|
if d == nil {
|
||||||
return c == d
|
return c == d
|
||||||
}
|
}
|
||||||
return c.kAuthInfo == d.kAuthInfo
|
return c.authInfo == d.authInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *AuthInfo) String() string {
|
func (c *AuthInfo) String() string {
|
||||||
@ -830,10 +830,10 @@ func (c *AuthInfo) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *AuthInfo) KubeAuthInfo() *clientcmdapi.AuthInfo {
|
func (c *AuthInfo) KubeAuthInfo() *clientcmdapi.AuthInfo {
|
||||||
return c.kAuthInfo
|
return c.authInfo
|
||||||
}
|
}
|
||||||
func (c *AuthInfo) SetKubeAuthInfo(kc *clientcmdapi.AuthInfo) {
|
func (c *AuthInfo) SetKubeAuthInfo(kc *clientcmdapi.AuthInfo) {
|
||||||
c.kAuthInfo = kc
|
c.authInfo = kc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manifest functions
|
// Manifest functions
|
||||||
|
@ -80,7 +80,7 @@ type Cluster struct {
|
|||||||
NameInKubeconf string `json:"cluster-kubeconf"`
|
NameInKubeconf string `json:"cluster-kubeconf"`
|
||||||
|
|
||||||
// Kubeconfig Cluster Object
|
// Kubeconfig Cluster Object
|
||||||
kCluster *kubeconfig.Cluster
|
cluster *kubeconfig.Cluster
|
||||||
|
|
||||||
// Bootstrap configuration this clusters ephemeral hosts will rely on
|
// Bootstrap configuration this clusters ephemeral hosts will rely on
|
||||||
Bootstrap string `json:"bootstrap-info"`
|
Bootstrap string `json:"bootstrap-info"`
|
||||||
@ -105,12 +105,12 @@ type Context struct {
|
|||||||
Manifest string `json:"manifest,omitempty"`
|
Manifest string `json:"manifest,omitempty"`
|
||||||
|
|
||||||
// Kubeconfig Context Object
|
// Kubeconfig Context Object
|
||||||
kContext *kubeconfig.Context
|
context *kubeconfig.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthInfo struct {
|
type AuthInfo struct {
|
||||||
// Kubeconfig AuthInfo Object
|
// Kubeconfig AuthInfo Object
|
||||||
kAuthInfo *kubeconfig.AuthInfo
|
authInfo *kubeconfig.AuthInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manifests is a tuple of references to a Manifest (how do Identify, collect ,
|
// Manifests is a tuple of references to a Manifest (how do Identify, collect ,
|
||||||
|
@ -76,7 +76,7 @@ type DockerClient interface {
|
|||||||
// DockerContainer docker container object wrapper
|
// DockerContainer docker container object wrapper
|
||||||
type DockerContainer struct {
|
type DockerContainer struct {
|
||||||
tag string
|
tag string
|
||||||
imageUrl string
|
imageURL string
|
||||||
id string
|
id string
|
||||||
dockerClient DockerClient
|
dockerClient DockerClient
|
||||||
ctx *context.Context
|
ctx *context.Context
|
||||||
@ -108,7 +108,7 @@ func NewDockerContainer(ctx *context.Context, url string, cli DockerClient) (*Do
|
|||||||
|
|
||||||
cnt := &DockerContainer{
|
cnt := &DockerContainer{
|
||||||
tag: t,
|
tag: t,
|
||||||
imageUrl: url,
|
imageURL: url,
|
||||||
id: "",
|
id: "",
|
||||||
dockerClient: cli,
|
dockerClient: cli,
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
@ -134,7 +134,7 @@ func (c *DockerContainer) getCmd(cmd []string) ([]string, error) {
|
|||||||
return cmd, nil
|
return cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := c.getImageId(c.imageUrl)
|
id, err := c.getImageId(c.imageURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ func (c *DockerContainer) getConfig(
|
|||||||
envVars []string,
|
envVars []string,
|
||||||
) (container.Config, container.HostConfig) {
|
) (container.Config, container.HostConfig) {
|
||||||
cCfg := container.Config{
|
cCfg := container.Config{
|
||||||
Image: c.imageUrl,
|
Image: c.imageURL,
|
||||||
Cmd: cmd,
|
Cmd: cmd,
|
||||||
AttachStdin: true,
|
AttachStdin: true,
|
||||||
OpenStdin: true,
|
OpenStdin: true,
|
||||||
@ -198,7 +198,7 @@ func (c *DockerContainer) GetId() string {
|
|||||||
func (c *DockerContainer) ImagePull() error {
|
func (c *DockerContainer) ImagePull() error {
|
||||||
// TODO (D. Ukov) add logic for searching among local images
|
// TODO (D. Ukov) add logic for searching among local images
|
||||||
// to avoid image download on each execution
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ func TestNewDockerContainer(t *testing.T) {
|
|||||||
testError := fmt.Errorf("image pull error")
|
testError := fmt.Errorf("image pull error")
|
||||||
type resultStruct struct {
|
type resultStruct struct {
|
||||||
tag string
|
tag string
|
||||||
imageUrl string
|
imageURL string
|
||||||
id string
|
id string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ func TestNewDockerContainer(t *testing.T) {
|
|||||||
expectedErr: nil,
|
expectedErr: nil,
|
||||||
expectedResult: resultStruct{
|
expectedResult: resultStruct{
|
||||||
tag: "testTag",
|
tag: "testTag",
|
||||||
imageUrl: "testPrefix/testImage:testTag",
|
imageURL: "testPrefix/testImage:testTag",
|
||||||
id: "",
|
id: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -473,7 +473,7 @@ func TestNewDockerContainer(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
actualResStruct = resultStruct{
|
actualResStruct = resultStruct{
|
||||||
tag: actualRes.tag,
|
tag: actualRes.tag,
|
||||||
imageUrl: actualRes.imageUrl,
|
imageURL: actualRes.imageURL,
|
||||||
id: actualRes.id,
|
id: actualRes.id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,13 @@ type RedfishRemoteDirect struct {
|
|||||||
RemoteURL url.URL
|
RemoteURL url.URL
|
||||||
|
|
||||||
// ephemeral Host ID
|
// ephemeral Host ID
|
||||||
EphemeralNodeId string
|
EphemeralNodeID string
|
||||||
|
|
||||||
// ISO URL
|
// ISO URL
|
||||||
IsoPath string
|
IsoPath string
|
||||||
|
|
||||||
// Redfish Client implementation
|
// Redfish Client implementation
|
||||||
Api redfishApi.RedfishAPI
|
RedfishAPI redfishApi.RedfishAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top level function to handle Redfish remote direct
|
// 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. */
|
/* TODO: Add Authentication when redfish library supports it. */
|
||||||
|
|
||||||
/* Get system details */
|
/* Get system details */
|
||||||
systemID := cfg.EphemeralNodeId
|
systemID := cfg.EphemeralNodeID
|
||||||
system, _, err := cfg.Api.GetSystem(cfg.Context, systemID)
|
system, _, err := cfg.RedfishAPI.GetSystem(cfg.Context, systemID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return NewRedfishClientErrorf("Get System[%s] failed with err: %s", systemID, err.Error())
|
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)
|
alog.Debugf("Ephemeral node managerID: '%s'", managerID)
|
||||||
|
|
||||||
/* Get manager's Cd or DVD virtual media ID */
|
/* 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
alog.Debugf("Ephemeral Node Virtual Media Id: '%s'", vMediaID)
|
alog.Debugf("Ephemeral Node Virtual Media Id: '%s'", vMediaID)
|
||||||
|
|
||||||
/* Load ISO in manager's virtual media */
|
/* 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
alog.Debugf("Successfully loaded virtual media: '%s'", cfg.IsoPath)
|
alog.Debugf("Successfully loaded virtual media: '%s'", cfg.IsoPath)
|
||||||
|
|
||||||
/* Set system's bootsource to selected media */
|
/* 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reboot system */
|
/* Reboot system */
|
||||||
err = RebootSystem(cfg.Context, cfg.Api, systemID)
|
err = RebootSystem(cfg.Context, cfg.RedfishAPI, systemID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -123,9 +123,9 @@ func NewRedfishRemoteDirectClient(ctx context.Context,
|
|||||||
client := RedfishRemoteDirect{
|
client := RedfishRemoteDirect{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
RemoteURL: *parsedURL,
|
RemoteURL: *parsedURL,
|
||||||
EphemeralNodeId: ephNodeID,
|
EphemeralNodeID: ephNodeID,
|
||||||
IsoPath: isoPath,
|
IsoPath: isoPath,
|
||||||
Api: api,
|
RedfishAPI: api,
|
||||||
}
|
}
|
||||||
|
|
||||||
return client, nil
|
return client, nil
|
||||||
|
@ -66,7 +66,7 @@ func TestRedfishRemoteDirectInvalidSystemId(t *testing.T) {
|
|||||||
systemID := "invalid-server"
|
systemID := "invalid-server"
|
||||||
localRDCfg := getDefaultRedfishRemoteDirectObj(t, m)
|
localRDCfg := getDefaultRedfishRemoteDirectObj(t, m)
|
||||||
|
|
||||||
localRDCfg.EphemeralNodeId = systemID
|
localRDCfg.EphemeralNodeID = systemID
|
||||||
|
|
||||||
realErr := fmt.Errorf("%s system do not exist", systemID)
|
realErr := fmt.Errorf("%s system do not exist", systemID)
|
||||||
m.On("GetSystem", context.Background(), systemID).
|
m.On("GetSystem", context.Background(), systemID).
|
||||||
@ -252,7 +252,7 @@ func getDefaultRedfishRemoteDirectObj(t *testing.T, api redfishAPI.RedfishAPI) R
|
|||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
rDCfg.Api = api
|
rDCfg.RedfishAPI = api
|
||||||
|
|
||||||
return rDCfg
|
return rDCfg
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user