Skip to content

Commit

Permalink
Merge pull request #10124 from adityabhatia/bump-golangci-lint-1.56
Browse files Browse the repository at this point in the history
🌱 bump `golangci-lint` to v1.56.1
  • Loading branch information
k8s-ci-robot committed Feb 9, 2024
2 parents 4f7645b + d6afeb8 commit f6742b5
Show file tree
Hide file tree
Showing 109 changed files with 232 additions and 232 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # tag=v3.7.0
with:
version: v1.55.2
version: v1.56.1
args: --out-format=colored-line-number
working-directory: ${{matrix.working-directory}}
2 changes: 1 addition & 1 deletion bootstrap/kubeadm/api/v1beta1/kubeadm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ func (bts *BootstrapTokenString) UnmarshalJSON(b []byte) error {

// String returns the string representation of the BootstrapTokenString.
func (bts BootstrapTokenString) String() string {
if len(bts.ID) > 0 && len(bts.Secret) > 0 {
if bts.ID != "" && bts.Secret != "" {
return bootstraputil.TokenFromIDAndSecret(bts.ID, bts.Secret)
}
return ""
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/kubeadm/api/v1beta1/kubeadm_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func roundtrip(input string, bts *BootstrapTokenString) error {
var err error
newbts := &BootstrapTokenString{}
// If string input was specified, roundtrip like this: string -> (unmarshal) -> object -> (marshal) -> string
if len(input) > 0 {
if input != "" {
if err := json.Unmarshal([]byte(input), newbts); err != nil {
return errors.Wrap(err, "expected no unmarshal error, got error")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func TestKubeadmConfigReconciler_TestSecretOwnerReferenceReconciliation(t *testi
key := client.ObjectKeyFromObject(config)
actual := &corev1.Secret{}

t.Run("KubeadmConfig ownerReference is added on first reconcile", func(t *testing.T) {
t.Run("KubeadmConfig ownerReference is added on first reconcile", func(*testing.T) {
_, err = k.Reconcile(ctx, request)
g.Expect(err).ToNot(HaveOccurred())

Expand All @@ -191,7 +191,7 @@ func TestKubeadmConfigReconciler_TestSecretOwnerReferenceReconciliation(t *testi
g.Expect(controllerOwner.Name).To(Equal(config.Name))
})

t.Run("KubeadmConfig ownerReference re-reconciled without error", func(t *testing.T) {
t.Run("KubeadmConfig ownerReference re-reconciled without error", func(*testing.T) {
_, err = k.Reconcile(ctx, request)
g.Expect(err).ToNot(HaveOccurred())

Expand All @@ -202,7 +202,7 @@ func TestKubeadmConfigReconciler_TestSecretOwnerReferenceReconciliation(t *testi
g.Expect(controllerOwner.Kind).To(Equal(config.Kind))
g.Expect(controllerOwner.Name).To(Equal(config.Name))
})
t.Run("non-KubeadmConfig controller OwnerReference is replaced", func(t *testing.T) {
t.Run("non-KubeadmConfig controller OwnerReference is replaced", func(*testing.T) {
g.Expect(myclient.Get(ctx, key, actual)).To(Succeed())

actual.SetOwnerReferences([]metav1.OwnerReference{
Expand Down Expand Up @@ -741,7 +741,7 @@ func TestReconcileIfJoinNodePoolsAndControlPlaneIsReady(t *testing.T) {
name: "Join a worker node with a fully compiled kubeadm config object",
machinePool: newWorkerMachinePoolForCluster(cluster),
configName: "workerpool-join-cfg",
configBuilder: func(namespace, name string) *bootstrapv1.KubeadmConfig {
configBuilder: func(namespace, _ string) *bootstrapv1.KubeadmConfig {
return newWorkerJoinKubeadmConfig(namespace, "workerpool-join-cfg")
},
},
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/kubeadm/internal/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var (
)

func TestMain(m *testing.M) {
setupReconcilers := func(ctx context.Context, mgr ctrl.Manager) {
setupReconcilers := func(_ context.Context, mgr ctrl.Manager) {
var err error
secretCachingClient, err = client.New(mgr.GetConfig(), client.Options{
HTTPClient: mgr.GetHTTPClient(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func TestControlPlaneInitMutex_LockWithMachineDeletion(t *testing.T) {
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(*testing.T) {
l := &ControlPlaneInitMutex{
client: tc.client,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (bts *BootstrapTokenString) UnmarshalJSON(b []byte) error {

// String returns the string representation of the BootstrapTokenString.
func (bts BootstrapTokenString) String() string {
if len(bts.ID) > 0 && len(bts.Secret) > 0 {
if bts.ID != "" && bts.Secret != "" {
return bootstraputil.TokenFromIDAndSecret(bts.ID, bts.Secret)
}
return ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func roundtrip(input string, bts *BootstrapTokenString) error {
var err error
newbts := &BootstrapTokenString{}
// If string input was specified, roundtrip like this: string -> (unmarshal) -> object -> (marshal) -> string
if len(input) > 0 {
if input != "" {
if err := json.Unmarshal([]byte(input), newbts); err != nil {
return errors.Wrap(err, "expected no unmarshal error, got error")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (bts *BootstrapTokenString) UnmarshalJSON(b []byte) error {

// String returns the string representation of the BootstrapTokenString.
func (bts BootstrapTokenString) String() string {
if len(bts.ID) > 0 && len(bts.Secret) > 0 {
if bts.ID != "" && bts.Secret != "" {
return bootstraputil.TokenFromIDAndSecret(bts.ID, bts.Secret)
}
return ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func roundtrip(input string, bts *BootstrapTokenString) error {
var err error
newbts := &BootstrapTokenString{}
// If string input was specified, roundtrip like this: string -> (unmarshal) -> object -> (marshal) -> string
if len(input) > 0 {
if input != "" {
if err := json.Unmarshal([]byte(input), newbts); err != nil {
return errors.Wrap(err, "expected no unmarshal error, got error")
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/clusterctl/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func newFakeClient(ctx context.Context, configClient config.Client) *fakeClient
fake.internalClient, _ = newClusterctlClient(ctx, "fake-config",
InjectConfig(fake.configClient),
InjectClusterClientFactory(clusterClientFactory),
InjectRepositoryFactory(func(ctx context.Context, input RepositoryClientFactoryInput) (repository.Client, error) {
InjectRepositoryFactory(func(_ context.Context, input RepositoryClientFactoryInput) (repository.Client, error) {
if _, ok := fake.repositories[input.Provider.ManifestLabel()]; !ok {
return nil, errors.Errorf("repository for kubeconfig %q does not exist", input.Provider.ManifestLabel())
}
Expand Down Expand Up @@ -212,14 +212,14 @@ func newFakeCluster(kubeconfig cluster.Kubeconfig, configClient config.Client) *
}

fake.fakeProxy = test.NewFakeProxy()
pollImmediateWaiter := func(ctx context.Context, interval, timeout time.Duration, condition wait.ConditionWithContextFunc) error {
pollImmediateWaiter := func(context.Context, time.Duration, time.Duration, wait.ConditionWithContextFunc) error {
return nil
}

fake.internalclient = cluster.New(kubeconfig, configClient,
cluster.InjectProxy(fake.fakeProxy),
cluster.InjectPollImmediateWaiter(pollImmediateWaiter),
cluster.InjectRepositoryFactory(func(ctx context.Context, provider config.Provider, configClient config.Client, options ...repository.Option) (repository.Client, error) {
cluster.InjectRepositoryFactory(func(_ context.Context, provider config.Provider, _ config.Client, _ ...repository.Option) (repository.Client, error) {
if _, ok := fake.repositories[provider.Name()]; !ok {
return nil, errors.Errorf("repository for kubeconfig %q does not exist", provider.Name())
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/clusterctl/client/cluster/cert_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func Test_getManifestObjs(t *testing.T) {

cm := &certManagerClient{
configClient: defaultConfigClient,
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, options ...repository.Option) (repository.Client, error) {
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, _ ...repository.Option) (repository.Client, error) {
return repository.New(ctx, provider, configClient, repository.InjectRepository(tt.fields.repository))
},
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func Test_getManifestObjs(t *testing.T) {
}

func Test_GetTimeout(t *testing.T) {
pollImmediateWaiter := func(ctx context.Context, interval, timeout time.Duration, condition wait.ConditionWithContextFunc) error {
pollImmediateWaiter := func(context.Context, time.Duration, time.Duration, wait.ConditionWithContextFunc) error {
return nil
}

Expand Down Expand Up @@ -426,7 +426,7 @@ func Test_shouldUpgrade(t *testing.T) {

proxy := test.NewFakeProxy()
fakeConfigClient := newFakeConfig().WithCertManager("", tt.configVersion, "")
pollImmediateWaiter := func(ctx context.Context, interval, timeout time.Duration, condition wait.ConditionWithContextFunc) error {
pollImmediateWaiter := func(context.Context, time.Duration, time.Duration, wait.ConditionWithContextFunc) error {
return nil
}
cm := newCertManagerClient(fakeConfigClient, nil, proxy, pollImmediateWaiter)
Expand Down Expand Up @@ -715,7 +715,7 @@ func Test_certManagerClient_PlanUpgrade(t *testing.T) {

proxy := test.NewFakeProxy().WithObjs(tt.objs...)
fakeConfigClient := newFakeConfig()
pollImmediateWaiter := func(ctx context.Context, interval, timeout time.Duration, condition wait.ConditionWithContextFunc) error {
pollImmediateWaiter := func(context.Context, time.Duration, time.Duration, wait.ConditionWithContextFunc) error {
return nil
}
cm := newCertManagerClient(fakeConfigClient, nil, proxy, pollImmediateWaiter)
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func Test_providerInstaller_Validate(t *testing.T) {
configClient: configClient,
proxy: tt.fields.proxy,
providerInventory: newInventoryClient(tt.fields.proxy, nil),
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, options ...repository.Option) (repository.Client, error) {
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, _ ...repository.Option) (repository.Client, error) {
return repository.New(ctx, provider, configClient, repository.InjectRepository(repositoryMap[provider.ManifestLabel()]))
},
installQueue: tt.fields.installQueue,
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/mover.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ func (o *objectMover) createTargetObject(ctx context.Context, nodeToCreate *node

// FIXME Workaround for https://github.com/kubernetes/kubernetes/issues/32220. Remove when the issue is fixed.
// If the resource already exists, the API server ordinarily returns an AlreadyExists error. Due to the above issue, if the resource has a non-empty metadata.generateName field, the API server returns a ServerTimeoutError. To ensure that the API server returns an AlreadyExists error, we set the metadata.generateName field to an empty string.
if len(obj.GetName()) > 0 && len(obj.GetGenerateName()) > 0 {
if obj.GetName() != "" && obj.GetGenerateName() != "" {
obj.SetGenerateName("")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (k *proxy) ListResources(ctx context.Context, labels map[string]string, nam
// Get all the API resources in the cluster.
resourceListBackoff := newReadBackoff()
var resourceList []*metav1.APIResourceList
if err := retryWithExponentialBackoff(ctx, resourceListBackoff, func(ctx context.Context) error {
if err := retryWithExponentialBackoff(ctx, resourceListBackoff, func(context.Context) error {
resourceList, err = cs.Discovery().ServerPreferredResources()
return err
}); err != nil {
Expand Down
20 changes: 10 additions & 10 deletions cmd/clusterctl/client/cluster/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func Test_templateClient_getGitHubFileContent(t *testing.T) {
configClient, err := config.New(context.Background(), "", config.InjectReader(test.NewFakeReader()))
g.Expect(err).ToNot(HaveOccurred())

mux.HandleFunc("/repos/kubernetes-sigs/cluster-api/contents/config/default/cluster-template.yaml", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/kubernetes-sigs/cluster-api/contents/config/default/cluster-template.yaml", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprint(w, `{
"type": "file",
"encoding": "base64",
Expand Down Expand Up @@ -214,7 +214,7 @@ func Test_templateClient_getGitHubFileContent(t *testing.T) {

c := &templateClient{
configClient: configClient,
gitHubClientFactory: func(ctx context.Context, configVariablesClient config.VariablesClient) (*github.Client, error) {
gitHubClientFactory: func(context.Context, config.VariablesClient) (*github.Client, error) {
return client, nil
},
}
Expand All @@ -232,7 +232,7 @@ func Test_templateClient_getGitHubFileContent(t *testing.T) {
}

func Test_templateClient_getRawUrlFileContent(t *testing.T) {
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprint(w, template)
}))

Expand Down Expand Up @@ -343,7 +343,7 @@ func Test_templateClient_GetFromURL(t *testing.T) {
fakeGithubClient, mux, teardown := test.NewFakeGitHub()
defer teardown()

mux.HandleFunc("/repos/kubernetes-sigs/cluster-api/contents/config/default/cluster-template.yaml", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/kubernetes-sigs/cluster-api/contents/config/default/cluster-template.yaml", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprint(w, `{
"type": "file",
"encoding": "base64",
Expand All @@ -355,7 +355,7 @@ func Test_templateClient_GetFromURL(t *testing.T) {
}`)
})

mux.HandleFunc("/repos/some-owner/some-repo/releases/tags/v1.0.0", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/some-owner/some-repo/releases/tags/v1.0.0", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprint(w, `{
"tag_name": "v1.0.0",
"name": "v1.0.0",
Expand All @@ -370,11 +370,11 @@ func Test_templateClient_GetFromURL(t *testing.T) {
}`)
})

mux.HandleFunc("/repos/some-owner/some-repo/releases/assets/87654321", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/some-owner/some-repo/releases/assets/87654321", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprint(w, template)
})

mux.HandleFunc("/repos/some-owner/some-repo/releases/tags/v2.0.0", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/some-owner/some-repo/releases/tags/v2.0.0", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprint(w, `{
"tag_name": "v2.0.0",
"name": "v2.0.0",
Expand All @@ -390,14 +390,14 @@ func Test_templateClient_GetFromURL(t *testing.T) {
})

// redirect asset
mux.HandleFunc("/repos/some-owner/some-repo/releases/assets/22222222", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/some-owner/some-repo/releases/assets/22222222", func(w http.ResponseWriter, _ *http.Request) {
// add the "/api-v3" prefix to match the prefix of the fake github server
w.Header().Add("Location", "/api-v3/redirected/22222222")
w.WriteHeader(http.StatusFound)
})

// redirect location
mux.HandleFunc("/redirected/22222222", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/redirected/22222222", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprint(w, template)
})

Expand Down Expand Up @@ -488,7 +488,7 @@ func Test_templateClient_GetFromURL(t *testing.T) {

ctx := context.Background()

gitHubClientFactory := func(ctx context.Context, configVariablesClient config.VariablesClient) (*github.Client, error) {
gitHubClientFactory := func(context.Context, config.VariablesClient) (*github.Client, error) {
return fakeGithubClient, nil
}
processor := yaml.NewSimpleProcessor()
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/cluster/upgrader_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func Test_providerUpgrader_getUpgradeInfo(t *testing.T) {

u := &providerUpgrader{
configClient: configClient,
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, options ...repository.Option) (repository.Client, error) {
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, _ ...repository.Option) (repository.Client, error) {
return repository.New(ctx, provider, configClient, repository.InjectRepository(tt.fields.repo))
},
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/clusterctl/client/cluster/upgrader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func Test_providerUpgrader_Plan(t *testing.T) {

u := &providerUpgrader{
configClient: configClient,
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, options ...repository.Option) (repository.Client, error) {
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, _ ...repository.Option) (repository.Client, error) {
return repository.New(ctx, provider, configClient, repository.InjectRepository(tt.fields.repository[provider.ManifestLabel()]))
},
providerInventory: newInventoryClient(tt.fields.proxy, nil),
Expand Down Expand Up @@ -786,7 +786,7 @@ func Test_providerUpgrader_createCustomPlan(t *testing.T) {

u := &providerUpgrader{
configClient: configClient,
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, options ...repository.Option) (repository.Client, error) {
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, _ ...repository.Option) (repository.Client, error) {
return repository.New(ctx, provider, configClient, repository.InjectRepository(tt.fields.repository[provider.Name()]))
},
providerInventory: newInventoryClient(tt.fields.proxy, nil),
Expand Down Expand Up @@ -905,7 +905,7 @@ func Test_providerUpgrader_ApplyPlan(t *testing.T) {

u := &providerUpgrader{
configClient: configClient,
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, options ...repository.Option) (repository.Client, error) {
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, _ ...repository.Option) (repository.Client, error) {
return repository.New(ctx, provider, configClient, repository.InjectRepository(tt.fields.repository[provider.ManifestLabel()]))
},
providerInventory: newInventoryClient(tt.fields.proxy, nil),
Expand Down Expand Up @@ -1046,7 +1046,7 @@ func Test_providerUpgrader_ApplyCustomPlan(t *testing.T) {

u := &providerUpgrader{
configClient: configClient,
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, options ...repository.Option) (repository.Client, error) {
repositoryClientFactory: func(ctx context.Context, provider config.Provider, configClient config.Client, _ ...repository.Option) (repository.Client, error) {
return repository.New(ctx, provider, configClient, repository.InjectRepository(tt.fields.repository[provider.ManifestLabel()]))
},
providerInventory: newInventoryClient(tt.fields.proxy, nil),
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/config/reader_viper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ func Test_viperReader_Init(t *testing.T) {
g.Expect(os.WriteFile(configFileBadContents, []byte("bad-contents"), 0600)).To(Succeed())

// To test the remote config file
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "text/plain")
_, err := w.Write([]byte("bar: bar"))
g.Expect(err).ToNot(HaveOccurred())
}))
defer ts.Close()

// To test the remote config file when fails to fetch
tsFail := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
tsFail := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusNotFound)
}))
defer tsFail.Close()
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ func newFakeClientWithoutCluster(configClient config.Client) *fakeClient {
var err error
fake.internalClient, err = newClusterctlClient(context.Background(), "fake-config",
InjectConfig(fake.configClient),
InjectRepositoryFactory(func(ctx context.Context, input RepositoryClientFactoryInput) (repository.Client, error) {
InjectRepositoryFactory(func(_ context.Context, input RepositoryClientFactoryInput) (repository.Client, error) {
if _, ok := fake.repositories[input.Provider.ManifestLabel()]; !ok {
return nil, errors.Errorf("repository for kubeconfig %q does not exist", input.Provider.ManifestLabel())
}
Expand Down Expand Up @@ -1067,7 +1067,7 @@ v3: default3`,
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(*testing.T) {
config1 := newFakeConfig(ctx).
WithProvider(infraProviderConfig)
cluster1 := newFakeCluster(cluster.Kubeconfig{}, config1)
Expand Down
Loading

0 comments on commit f6742b5

Please sign in to comment.