Skip to content

Commit

Permalink
assisted: adjust return consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 committed Jan 21, 2025
1 parent 08e6955 commit 64f0cf9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
8 changes: 2 additions & 6 deletions pkg/assisted/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

const (
nonExistentMsg = "Cannot update non-existent agent"
nonExistentMsg = "cannot update non-existent agent"
)

// agentBuilder provides struct for the agent object containing connection to
Expand Down Expand Up @@ -300,11 +300,7 @@ func (builder *agentBuilder) Update() (*agentBuilder, error) {
glog.V(100).Infof("agent %s in namespace %s does not exist",
builder.Definition.Name, builder.Definition.Namespace)

builder.errorMsg = nonExistentMsg
}

if builder.errorMsg != "" {
return nil, fmt.Errorf(builder.errorMsg)
return nil, fmt.Errorf(nonExistentMsg)
}

err := builder.apiClient.Update(context.TODO(), builder.Definition)
Expand Down
1 change: 0 additions & 1 deletion pkg/assisted/agentclusterinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ func (builder *AgentClusterInstallBuilder) Update(force bool) (*AgentClusterInst

err = builder.DeleteAndWait(time.Second * 10)
builder.Definition.ResourceVersion = ""
// fmt.Printf("agentclusterinstall exists: %v\n", builder.Exists())

if err != nil {
glog.V(100).Infof(
Expand Down
8 changes: 3 additions & 5 deletions pkg/assisted/agentserviceconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ func (builder *AgentServiceConfigBuilder) WithMirrorRegistryRef(configMapName st
glog.V(100).Infof("The configMapName is empty")

builder.errorMsg = "cannot add agentserviceconfig mirrorRegistryRef with empty configmap name"
}

if builder.errorMsg != "" {
return builder
}

Expand Down Expand Up @@ -347,7 +345,7 @@ func (builder *AgentServiceConfigBuilder) Get() (*agentInstallV1Beta1.AgentServi
return nil, err
}

return agentServiceConfig, err
return agentServiceConfig, nil
}

// Create generates an agentserviceconfig on the cluster.
Expand Down Expand Up @@ -524,13 +522,13 @@ func (builder *AgentServiceConfigBuilder) validate() (bool, error) {
if builder.Definition == nil {
glog.V(100).Infof("The %s is undefined", resourceCRD)

builder.errorMsg = msg.UndefinedCrdObjectErrString(resourceCRD)
return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD))
}

if builder.apiClient == nil {
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)

builder.errorMsg = fmt.Sprintf("%s builder cannot have nil apiClient", resourceCRD)
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
}

if builder.errorMsg != "" {
Expand Down
6 changes: 1 addition & 5 deletions pkg/assisted/infraenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,11 +790,7 @@ func (builder *InfraEnvBuilder) Update(force bool) (*InfraEnvBuilder, error) {
glog.V(100).Infof("infraenv %s in namespace %s does not exist",
builder.Definition.Name, builder.Definition.Namespace)

builder.errorMsg = "Cannot update non-existent infraenv"
}

if builder.errorMsg != "" {
return nil, fmt.Errorf(builder.errorMsg)
return nil, fmt.Errorf("cannot update non-existent infraenv")
}

err := builder.apiClient.Update(context.TODO(), builder.Definition)
Expand Down

0 comments on commit 64f0cf9

Please sign in to comment.