Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A couple of static checks cleanups #14719

Merged
merged 3 commits into from
Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cmd/kops/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/klog/v2"
"k8s.io/kops/cmd/kops/util"
"k8s.io/kops/pkg/apis/kops"
kopsapi "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/kopscodecs"
"k8s.io/kops/pkg/kubemanifest"
Expand Down Expand Up @@ -109,7 +108,7 @@ func RunCreate(ctx context.Context, f *util.Factory, out io.Writer, c *CreateOpt
fmt.Fprintf(&sb, "\n")

var addons kubemanifest.ObjectList
var clusters []*kops.Cluster
var clusters []*kopsapi.Cluster

for _, f := range c.Filenames {
var contents []byte
Expand Down Expand Up @@ -210,7 +209,7 @@ func RunCreate(ctx context.Context, f *util.Factory, out io.Writer, c *CreateOpt

default:
klog.V(2).Infof("Type of object was %T", v)
return fmt.Errorf("Unhandled kind %q in %s", gvk, f)
return fmt.Errorf("unhandled kind %q in %s", gvk, f)
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (

kopsbase "k8s.io/kops"
"k8s.io/kops/cmd/kops/util"
"k8s.io/kops/pkg/apis/kops"
api "k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/apis/kops/registry"
kopsutil "k8s.io/kops/pkg/apis/kops/util"
Expand Down Expand Up @@ -675,7 +674,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr

{
// Build full IG spec to ensure we end up with a valid IG
fullInstanceGroups := []*kops.InstanceGroup{}
fullInstanceGroups := []*api.InstanceGroup{}
for _, group := range instanceGroups {
fullGroup, err := cloudup.PopulateInstanceGroupSpec(cluster, group, cloud, clusterResult.Channel)
if err != nil {
Expand Down Expand Up @@ -842,7 +841,7 @@ func parseCloudLabels(s string) (map[string]string, error) {
r.TrimLeadingSpace = true
kvPairs, err := r.ReadAll()
if err != nil {
return nil, fmt.Errorf("One or more key=value pairs are malformed:\n%s\n:%v", records, err)
return nil, fmt.Errorf("one or more key=value pairs are malformed:\n%s\n:%w", records, err)
}

m := make(map[string]string, len(kvPairs))
Expand Down
4 changes: 2 additions & 2 deletions cmd/kops/get_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func RunGetAll(ctx context.Context, f commandutils.Factory, out io.Writer, optio
}

if cluster == nil {
return fmt.Errorf("No cluster found")
return fmt.Errorf("no cluster found")
}

igList, err := client.InstanceGroupsFor(cluster).List(ctx, metav1.ListOptions{})
Expand Down Expand Up @@ -157,7 +157,7 @@ func RunGetAll(ctx context.Context, f commandutils.Factory, out io.Writer, optio
}

default:
return fmt.Errorf("Unknown output format: %q", options.Output)
return fmt.Errorf("unknown output format: %q", options.Output)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/kops/get_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func RunGetClusters(ctx context.Context, f commandutils.Factory, out io.Writer,
// kops get cluster test.example.com -o json will return a single object (since a specific cluster is selected)
return fullOutputJSON(out, singleClusterSelected, obj...)
default:
return fmt.Errorf("Unknown output format: %q", options.Output)
return fmt.Errorf("unknown output format: %q", options.Output)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/kops/get_keypairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func RunGetKeypairs(ctx context.Context, f commandutils.Factory, out io.Writer,
}

default:
return fmt.Errorf("Unknown output format: %q", options.Output)
return fmt.Errorf("unknown output format: %q", options.Output)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/kops/get_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func RunGetSecrets(ctx context.Context, f *util.Factory, out io.Writer, options
}

if len(items) == 0 {
return fmt.Errorf("No secrets found")
return fmt.Errorf("no secrets found")
}
switch options.Output {

Expand Down
5 changes: 0 additions & 5 deletions cmd/kops/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ func (i *integrationTest) withNTH() *integrationTest {
return i
}

func (i *integrationTest) withKubeDNS() *integrationTest {
i.kubeDNS = true
return i
}

func (i *integrationTest) withOIDCDiscovery() *integrationTest {
i.discovery = true
return i
Expand Down
2 changes: 1 addition & 1 deletion cmd/kops/validate_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func NewCmdValidateCluster(f *util.Factory, out io.Writer) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
result, err := RunValidateCluster(context.TODO(), f, out, options)
if err != nil {
return fmt.Errorf("Validation failed: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: %w

return fmt.Errorf("validation failed: %v", err)
}

// We want the validate command to exit non-zero if validation found a problem,
Expand Down