[#58] Update var names to be golint compliant

This patch resolves complaints from golint such as:

cmd/config/set_authinfo_test.go:84:3: don't use leading k in Go names;
pkg/remote/redfish/redfish.go:39:2: var systemId should be systemID
pkg/remote/redfish/redfish.go:47:2: var managerId should be managerID
pkg/remote/redfish/redfish.go:51:2: var vMediaId should be vMediaID
pkg/remote/redfish/redfish.go:115:2: var parsedUrl should be parsedURL
pkg/remote/redfish/utils.go:29:2: var trimmedUrl should be trimmedURL
pkg/remote/redfish/utils.go:39:3: var rId should be rID

Relates-To: #58

Change-Id: I758565c84b44aac118d5f1cbf714224ab1ff82c5
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
This commit is contained in:
Alexander Hughes 2020-02-28 09:48:46 -05:00
parent f66f94dc80
commit dd1dba6eb3
6 changed files with 43 additions and 43 deletions

View File

@ -172,10 +172,10 @@ func TestModifyCluster(t *testing.T) {
clusterName.WithType(tname, tctype)
given.Clusters[tname].ClusterTypes[tctype] = config.NewCluster()
given.Clusters[tname].ClusterTypes[tctype].NameInKubeconf = clusterName.Name()
kCluster := kubeconfig.NewCluster()
kCluster.Server = "https://192.168.0.10"
given.KubeConfig().Clusters[clusterName.Name()] = kCluster
given.Clusters[tname].ClusterTypes[tctype].SetKubeCluster(kCluster)
cluster := kubeconfig.NewCluster()
cluster.Server = "https://192.168.0.10"
given.KubeConfig().Clusters[clusterName.Name()] = cluster
given.Clusters[tname].ClusterTypes[tctype].SetKubeCluster(cluster)
expected, cleanupExpected := config.InitConfig(t)
defer cleanupExpected(t)

View File

@ -551,13 +551,13 @@ func (c *Config) AddContext(theContext *ContextOptions) *Context {
nContext := NewContext()
c.Contexts[theContext.Name] = nContext
// Create a new Kubeconfig Context object as well
kContext := clientcmdapi.NewContext()
context := clientcmdapi.NewContext()
nContext.NameInKubeconf = theContext.Name
contextName := NewClusterComplexName()
contextName.WithType(theContext.Name, theContext.ClusterType)
nContext.SetKubeContext(kContext)
c.KubeConfig().Contexts[theContext.Name] = kContext
nContext.SetKubeContext(context)
c.KubeConfig().Contexts[theContext.Name] = context
// Ok , I have initialized structs for the Context information
// We can use Modify to populate the correct information
@ -566,21 +566,21 @@ func (c *Config) AddContext(theContext *ContextOptions) *Context {
}
func (c *Config) ModifyContext(context *Context, theContext *ContextOptions) {
kContext := context.KubeContext()
if kContext == nil {
kubeContext := context.KubeContext()
if kubeContext == nil {
return
}
if theContext.Cluster != "" {
kContext.Cluster = theContext.Cluster
kubeContext.Cluster = theContext.Cluster
}
if theContext.AuthInfo != "" {
kContext.AuthInfo = theContext.AuthInfo
kubeContext.AuthInfo = theContext.AuthInfo
}
if theContext.Manifest != "" {
context.Manifest = theContext.Manifest
}
if theContext.Namespace != "" {
kContext.Namespace = theContext.Namespace
kubeContext.Namespace = theContext.Namespace
}
}
@ -660,33 +660,33 @@ func (c *Config) AddAuthInfo(theAuthInfo *AuthInfoOptions) *AuthInfo {
nAuthInfo := NewAuthInfo()
c.AuthInfos[theAuthInfo.Name] = nAuthInfo
// Create a new Kubeconfig AuthInfo object as well
kAuthInfo := clientcmdapi.NewAuthInfo()
nAuthInfo.SetKubeAuthInfo(kAuthInfo)
c.KubeConfig().AuthInfos[theAuthInfo.Name] = kAuthInfo
authInfo := clientcmdapi.NewAuthInfo()
nAuthInfo.SetKubeAuthInfo(authInfo)
c.KubeConfig().AuthInfos[theAuthInfo.Name] = authInfo
c.ModifyAuthInfo(nAuthInfo, theAuthInfo)
return nAuthInfo
}
func (c *Config) ModifyAuthInfo(authinfo *AuthInfo, theAuthInfo *AuthInfoOptions) {
kAuthInfo := authinfo.KubeAuthInfo()
if kAuthInfo == nil {
kubeAuthInfo := authinfo.KubeAuthInfo()
if kubeAuthInfo == nil {
return
}
if theAuthInfo.ClientCertificate != "" {
kAuthInfo.ClientCertificate = theAuthInfo.ClientCertificate
kubeAuthInfo.ClientCertificate = theAuthInfo.ClientCertificate
}
if theAuthInfo.Token != "" {
kAuthInfo.Token = theAuthInfo.Token
kubeAuthInfo.Token = theAuthInfo.Token
}
if theAuthInfo.Username != "" {
kAuthInfo.Username = theAuthInfo.Username
kubeAuthInfo.Username = theAuthInfo.Username
}
if theAuthInfo.Password != "" {
kAuthInfo.Password = theAuthInfo.Password
kubeAuthInfo.Password = theAuthInfo.Password
}
if theAuthInfo.ClientKey != "" {
kAuthInfo.ClientKey = theAuthInfo.ClientKey
kubeAuthInfo.ClientKey = theAuthInfo.ClientKey
}
}

View File

@ -242,9 +242,9 @@ func TestGetId(t *testing.T) {
cnt := getDockerContainerMock(mockDockerClient{})
err := cnt.RunCommand([]string{"testCmd"}, nil, nil, []string{}, false)
require.NoError(t, err)
actualId := cnt.GetId()
actualID := cnt.GetId()
assert.Equal(t, "testID", actualId)
assert.Equal(t, "testID", actualID)
}
func TestRunCommand(t *testing.T) {

View File

@ -28,7 +28,7 @@ const (
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")
ErrCantParseURL = errors.New("could not get target directory from url")
)
type OptionsBuilder interface {
@ -52,7 +52,7 @@ type Repository struct {
func NewRepository(basePath string, builder OptionsBuilder) (*Repository, error) {
dirName := nameFromURL(builder.URL())
if dirName == "" {
return nil, fmt.Errorf("URL: %s, original error: %w", builder.URL(), ErrCantParseUrl)
return nil, fmt.Errorf("URL: %s, original error: %w", builder.URL(), ErrCantParseURL)
}
fs := osfs.New(filepath.Join(basePath, dirName))

View File

@ -36,39 +36,39 @@ 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.Api.GetSystem(cfg.Context, systemID)
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())
}
alog.Debugf("Ephemeral Node System ID: '%s'", systemId)
alog.Debugf("Ephemeral Node System ID: '%s'", systemID)
/* get manager for system */
managerId := GetResourceIDFromURL(system.Links.ManagedBy[0].OdataId)
alog.Debugf("Ephemeral node managerId: '%s'", managerId)
managerID := GetResourceIDFromURL(system.Links.ManagedBy[0].OdataId)
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.Api, managerID)
if err != nil {
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 */
err = SetVirtualMedia(cfg.Context, cfg.Api, managerId, vMediaId, cfg.IsoPath)
err = SetVirtualMedia(cfg.Context, cfg.Api, 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.Api, systemID, vMediaType)
if err != nil {
return err
}
/* Reboot system */
err = RebootSystem(cfg.Context, cfg.Api, systemId)
err = RebootSystem(cfg.Context, cfg.Api, systemID)
if err != nil {
return err
}
@ -112,7 +112,7 @@ func NewRedfishRemoteDirectClient(ctx context.Context,
var api redfishApi.RedfishAPI = redfishClient.NewAPIClient(cfg).DefaultApi
parsedUrl, err := url.Parse(remoteURL)
parsedURL, err := url.Parse(remoteURL)
if err != nil {
return RedfishRemoteDirect{},
ErrRedfishMissingConfig{
@ -122,7 +122,7 @@ func NewRedfishRemoteDirectClient(ctx context.Context,
client := RedfishRemoteDirect{
Context: ctx,
RemoteURL: *parsedUrl,
RemoteURL: *parsedURL,
EphemeralNodeId: ephNodeID,
IsoPath: isoPath,
Api: api,

View File

@ -26,8 +26,8 @@ func GetResourceIDFromURL(refURL string) string {
log.Fatal(err)
}
trimmedUrl := strings.TrimSuffix(u.Path, "/")
elems := strings.Split(trimmedUrl, "/")
trimmedURL := strings.TrimSuffix(u.Path, "/")
elems := strings.Split(trimmedURL, "/")
id := elems[len(elems)-1]
return id
@ -36,8 +36,8 @@ func GetResourceIDFromURL(refURL string) string {
// Checks whether an ID exists in Redfish IDref collection
func IsIDInList(idRefList []redfishClient.IdRef, id string) bool {
for _, r := range idRefList {
rId := GetResourceIDFromURL(r.OdataId)
if rId == id {
rID := GetResourceIDFromURL(r.OdataId)
if rID == id {
return true
}
}