diff --git a/bootstrapper/internal/kubernetes/kubewaiter/kubewaiter.go b/bootstrapper/internal/kubernetes/kubewaiter/kubewaiter.go index 00e0970537..64ef2abfc7 100644 --- a/bootstrapper/internal/kubernetes/kubewaiter/kubewaiter.go +++ b/bootstrapper/internal/kubernetes/kubewaiter/kubewaiter.go @@ -29,7 +29,7 @@ type CloudKubeAPIWaiter struct{} // Wait waits for the Kubernetes API to be available. // Note that the kubernetesClient must have the kubeconfig already set. func (w *CloudKubeAPIWaiter) Wait(ctx context.Context, kubernetesClient KubernetesClient) error { - funcAlwaysRetriable := func(err error) bool { return true } + funcAlwaysRetriable := func(_ error) bool { return true } doer := &kubeDoer{kubeClient: kubernetesClient} retrier := retry.NewIntervalRetrier(doer, 5*time.Second, funcAlwaysRetriable) diff --git a/cli/internal/cloudcmd/tfplan_test.go b/cli/internal/cloudcmd/tfplan_test.go index 5d7ad6a42a..3cad299c12 100644 --- a/cli/internal/cloudcmd/tfplan_test.go +++ b/cli/internal/cloudcmd/tfplan_test.go @@ -54,7 +54,7 @@ func TestTFPlan(t *testing.T) { wantBackup: true, }, "workspace is empty": { - prepareFs: func(require *require.Assertions) file.Handler { + prepareFs: func(_ *require.Assertions) file.Handler { return file.NewHandler(afero.NewMemMapFs()) }, tf: &stubUpgradePlanner{}, diff --git a/cli/internal/cmd/apply_test.go b/cli/internal/cmd/apply_test.go index 55f0556697..a177cd1d41 100644 --- a/cli/internal/cmd/apply_test.go +++ b/cli/internal/cmd/apply_test.go @@ -238,7 +238,7 @@ func TestSkipPhases(t *testing.T) { } func TestValidateInputs(t *testing.T) { - defaultConfig := func(csp cloudprovider.Provider) func(require *require.Assertions, fh file.Handler) { + defaultConfig := func(csp cloudprovider.Provider) func(require *require.Assertions, _ file.Handler) { return func(require *require.Assertions, fh file.Handler) { cfg := defaultConfigWithExpectedMeasurements(t, config.Default(), csp) @@ -261,7 +261,7 @@ func TestValidateInputs(t *testing.T) { require.NoError(fh.WriteYAML(constants.ConfigFilename, cfg)) } } - preInitState := func(csp cloudprovider.Provider) func(require *require.Assertions, fh file.Handler) { + preInitState := func(csp cloudprovider.Provider) func(_ *require.Assertions, _ file.Handler) { return func(require *require.Assertions, fh file.Handler) { stateFile := defaultStateFile(csp) stateFile.ClusterValues = state.ClusterValues{} @@ -332,7 +332,7 @@ func TestValidateInputs(t *testing.T) { wantPhases: newPhases(skipInitPhase, skipImagePhase), // No image upgrades on QEMU }, "no config file errors": { - createConfig: func(require *require.Assertions, fh file.Handler) {}, + createConfig: func(_ *require.Assertions, _ file.Handler) {}, createState: postInitState(cloudprovider.GCP), createMasterSecret: defaultMasterSecret, createAdminConfig: defaultAdminConfig, @@ -344,7 +344,7 @@ func TestValidateInputs(t *testing.T) { createConfig: defaultConfig(cloudprovider.GCP), createState: preInitState(cloudprovider.GCP), createMasterSecret: defaultMasterSecret, - createAdminConfig: func(require *require.Assertions, fh file.Handler) {}, + createAdminConfig: func(_ *require.Assertions, _ file.Handler) {}, createTfState: defaultTfState, flags: applyFlags{}, wantErr: true, @@ -352,8 +352,8 @@ func TestValidateInputs(t *testing.T) { "[init] no admin config file, no master secret": { createConfig: defaultConfig(cloudprovider.GCP), createState: preInitState(cloudprovider.GCP), - createMasterSecret: func(require *require.Assertions, fh file.Handler) {}, - createAdminConfig: func(require *require.Assertions, fh file.Handler) {}, + createMasterSecret: func(_ *require.Assertions, _ file.Handler) {}, + createAdminConfig: func(_ *require.Assertions, _ file.Handler) {}, createTfState: defaultTfState, flags: applyFlags{}, wantPhases: newPhases(skipImagePhase, skipK8sPhase), @@ -363,16 +363,16 @@ func TestValidateInputs(t *testing.T) { createState: preInitState(cloudprovider.GCP), createMasterSecret: defaultMasterSecret, createAdminConfig: defaultAdminConfig, - createTfState: func(require *require.Assertions, fh file.Handler) {}, + createTfState: func(_ *require.Assertions, _ file.Handler) {}, flags: applyFlags{}, wantErr: true, }, "[create] only config, skip everything but infrastructure": { createConfig: defaultConfig(cloudprovider.GCP), - createState: func(require *require.Assertions, fh file.Handler) {}, - createMasterSecret: func(require *require.Assertions, fh file.Handler) {}, - createAdminConfig: func(require *require.Assertions, fh file.Handler) {}, - createTfState: func(require *require.Assertions, fh file.Handler) {}, + createState: func(_ *require.Assertions, _ file.Handler) {}, + createMasterSecret: func(_ *require.Assertions, _ file.Handler) {}, + createAdminConfig: func(_ *require.Assertions, _ file.Handler) {}, + createTfState: func(_ *require.Assertions, _ file.Handler) {}, flags: applyFlags{ skipPhases: newPhases(skipInitPhase, skipAttestationConfigPhase, skipCertSANsPhase, skipHelmPhase, skipK8sPhase, skipImagePhase), }, @@ -380,19 +380,19 @@ func TestValidateInputs(t *testing.T) { }, "[create + init] only config file": { createConfig: defaultConfig(cloudprovider.GCP), - createState: func(require *require.Assertions, fh file.Handler) {}, - createMasterSecret: func(require *require.Assertions, fh file.Handler) {}, - createAdminConfig: func(require *require.Assertions, fh file.Handler) {}, - createTfState: func(require *require.Assertions, fh file.Handler) {}, + createState: func(_ *require.Assertions, _ file.Handler) {}, + createMasterSecret: func(_ *require.Assertions, _ file.Handler) {}, + createAdminConfig: func(_ *require.Assertions, _ file.Handler) {}, + createTfState: func(_ *require.Assertions, _ file.Handler) {}, flags: applyFlags{}, wantPhases: newPhases(skipImagePhase, skipK8sPhase), }, "[init] self-managed: config and state file exist, skip-phases=infrastructure": { createConfig: defaultConfig(cloudprovider.GCP), createState: preInitState(cloudprovider.GCP), - createMasterSecret: func(require *require.Assertions, fh file.Handler) {}, - createAdminConfig: func(require *require.Assertions, fh file.Handler) {}, - createTfState: func(require *require.Assertions, fh file.Handler) {}, + createMasterSecret: func(_ *require.Assertions, _ file.Handler) {}, + createAdminConfig: func(_ *require.Assertions, _ file.Handler) {}, + createTfState: func(_ *require.Assertions, _ file.Handler) {}, flags: applyFlags{ skipPhases: newPhases(skipInfrastructurePhase), }, @@ -414,7 +414,7 @@ func TestValidateInputs(t *testing.T) { createTfState: defaultTfState, stdin: "y\n", wantPhases: newPhases(skipInitPhase, skipK8sPhase), - assert: func(require *require.Assertions, assert *assert.Assertions, conf *config.Config, stateFile *state.State) { + assert: func(_ *require.Assertions, assert *assert.Assertions, conf *config.Config, _ *state.State) { assert.NotEmpty(conf.KubernetesVersion) _, err := versions.NewValidK8sVersion(string(conf.KubernetesVersion), true) assert.NoError(err) diff --git a/cli/internal/cmd/configgenerate_test.go b/cli/internal/cmd/configgenerate_test.go index d3ffbff189..2533cffcbb 100644 --- a/cli/internal/cmd/configgenerate_test.go +++ b/cli/internal/cmd/configgenerate_test.go @@ -196,7 +196,7 @@ func TestNoValidProviderAttestationCombination(t *testing.T) { {cloudprovider.OpenStack, variant.AWSNitroTPM{}}, } for _, test := range tests { - t.Run("", func(t *testing.T) { + t.Run("", func(_ *testing.T) { _, err := createConfigWithAttestationVariant(test.provider, "", test.attestation) assert.Error(err) }) diff --git a/cli/internal/cmd/create_test.go b/cli/internal/cmd/create_test.go index fe3119ee38..f6290cce83 100644 --- a/cli/internal/cmd/create_test.go +++ b/cli/internal/cmd/create_test.go @@ -122,7 +122,7 @@ func TestCreate(t *testing.T) { wantErr: true, }, "config does not exist": { - setupFs: func(a *require.Assertions, p cloudprovider.Provider) afero.Fs { return afero.NewMemMapFs() }, + setupFs: func(_ *require.Assertions, _ cloudprovider.Provider) afero.Fs { return afero.NewMemMapFs() }, creator: &stubCloudCreator{ state: infraState, planDiff: true, diff --git a/cli/internal/cmd/iamcreate_test.go b/cli/internal/cmd/iamcreate_test.go index 19aba50dbf..3a9c830512 100644 --- a/cli/internal/cmd/iamcreate_test.go +++ b/cli/internal/cmd/iamcreate_test.go @@ -67,7 +67,7 @@ func TestParseIDFile(t *testing.T) { func TestIAMCreateAWS(t *testing.T) { defaultFs := createFSWithConfig(*createConfig(cloudprovider.AWS)) - readOnlyFs := func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs { + readOnlyFs := func(_ *require.Assertions, _ cloudprovider.Provider, _ []string, _ []string) afero.Fs { fs := afero.NewReadOnlyFs(afero.NewMemMapFs()) return fs } @@ -257,7 +257,7 @@ func TestIAMCreateAWS(t *testing.T) { func TestIAMCreateAzure(t *testing.T) { defaultFs := createFSWithConfig(*createConfig(cloudprovider.Azure)) - readOnlyFs := func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs { + readOnlyFs := func(_ *require.Assertions, _ cloudprovider.Provider, _ []string, _ []string) afero.Fs { fs := afero.NewReadOnlyFs(afero.NewMemMapFs()) return fs } @@ -434,7 +434,7 @@ func TestIAMCreateAzure(t *testing.T) { func TestIAMCreateGCP(t *testing.T) { defaultFs := createFSWithConfig(*createConfig(cloudprovider.GCP)) - readOnlyFs := func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs { + readOnlyFs := func(_ *require.Assertions, _ cloudprovider.Provider, _ []string, _ []string) afero.Fs { fs := afero.NewReadOnlyFs(afero.NewMemMapFs()) return fs } @@ -684,7 +684,7 @@ func TestValidateConfigWithFlagCompatibility(t *testing.T) { } func createFSWithConfig(cfg config.Config) func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs { - return func(require *require.Assertions, provider cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs { + return func(require *require.Assertions, _ cloudprovider.Provider, existingConfigFiles []string, existingDirs []string) afero.Fs { fs := afero.NewMemMapFs() fileHandler := file.NewHandler(fs) for _, f := range existingConfigFiles { diff --git a/cli/internal/cmd/init_test.go b/cli/internal/cmd/init_test.go index de6278d660..f55b7e77cc 100644 --- a/cli/internal/cmd/init_test.go +++ b/cli/internal/cmd/init_test.go @@ -438,12 +438,12 @@ func TestGenerateMasterSecret(t *testing.T) { wantErr: true, }, "file does not exist": { - createFileFunc: func(handler file.Handler) error { return nil }, + createFileFunc: func(_ file.Handler) error { return nil }, fs: afero.NewMemMapFs, wantErr: false, }, "file not writeable": { - createFileFunc: func(handler file.Handler) error { return nil }, + createFileFunc: func(_ file.Handler) error { return nil }, fs: func() afero.Fs { return afero.NewReadOnlyFs(afero.NewMemMapFs()) }, wantErr: true, }, diff --git a/cli/internal/cmd/maapatch.go b/cli/internal/cmd/maapatch.go index e5bea9f699..a32e8729a9 100644 --- a/cli/internal/cmd/maapatch.go +++ b/cli/internal/cmd/maapatch.go @@ -23,7 +23,7 @@ func NewMaaPatchCmd() *cobra.Command { Long: "Patch the MAA's attestation policy.", Args: cobra.MatchAll( cobra.ExactArgs(1), - func(cmd *cobra.Command, args []string) error { + func(_ *cobra.Command, args []string) error { if _, err := url.Parse(args[0]); err != nil { return fmt.Errorf("argument %s is not a valid URL: %w", args[0], err) } diff --git a/cli/internal/cmd/terminate_test.go b/cli/internal/cmd/terminate_test.go index e2888d4b0a..1999290e95 100644 --- a/cli/internal/cmd/terminate_test.go +++ b/cli/internal/cmd/terminate_test.go @@ -104,7 +104,7 @@ func TestTerminate(t *testing.T) { }, "missing id file does not error": { stateFile: state.New(), - setupFs: func(require *require.Assertions, stateFile *state.State) afero.Fs { + setupFs: func(require *require.Assertions, _ *state.State) afero.Fs { fs := afero.NewMemMapFs() fileHandler := file.NewHandler(fs) require.NoError(fileHandler.Write(constants.AdminConfFilename, []byte{1, 2}, file.OptNone)) diff --git a/cli/internal/cmd/upgradeapply_test.go b/cli/internal/cmd/upgradeapply_test.go index 488a512d51..8cf546c378 100644 --- a/cli/internal/cmd/upgradeapply_test.go +++ b/cli/internal/cmd/upgradeapply_test.go @@ -254,7 +254,7 @@ func TestUpgradeApply(t *testing.T) { log: logger.NewTest(t), spinner: &nopSpinner{}, merger: &stubMerger{}, - newInfraApplier: func(ctx context.Context) (cloudApplier, func(), error) { + newInfraApplier: func(_ context.Context) (cloudApplier, func(), error) { return tc.terraformUpgrader, func() {}, nil }, applier: &stubConstellApplier{ diff --git a/cli/internal/cmd/userinteraction_test.go b/cli/internal/cmd/userinteraction_test.go index 77e541b50f..3222be8d78 100644 --- a/cli/internal/cmd/userinteraction_test.go +++ b/cli/internal/cmd/userinteraction_test.go @@ -23,7 +23,7 @@ func TestAskToConfirm(t *testing.T) { cmd := &cobra.Command{ Use: "test", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { ok, err := askToConfirm(cmd, "777") if err != nil { return err diff --git a/cli/internal/cmd/validargs.go b/cli/internal/cmd/validargs.go index 73b84c6e4e..6b65736125 100644 --- a/cli/internal/cmd/validargs.go +++ b/cli/internal/cmd/validargs.go @@ -14,7 +14,7 @@ import ( ) func isCloudProvider(arg int) cobra.PositionalArgs { - return func(cmd *cobra.Command, args []string) error { + return func(_ *cobra.Command, args []string) error { if provider := cloudprovider.FromString(args[arg]); provider == cloudprovider.Unknown { return fmt.Errorf("argument %s isn't a valid cloud provider", args[arg]) } diff --git a/cli/internal/terraform/terraform_test.go b/cli/internal/terraform/terraform_test.go index 9993cdab7d..103f0e959f 100644 --- a/cli/internal/terraform/terraform_test.go +++ b/cli/internal/terraform/terraform_test.go @@ -852,7 +852,7 @@ func TestCleanupWorkspace(t *testing.T) { }, "no error if files do not exist": { provider: cloudprovider.QEMU, - prepareFS: func(f file.Handler) error { return nil }, + prepareFS: func(_ file.Handler) error { return nil }, }, } diff --git a/csi/cryptmapper/cryptmapper_test.go b/csi/cryptmapper/cryptmapper_test.go index 537c0f0674..cef34cd189 100644 --- a/csi/cryptmapper/cryptmapper_test.go +++ b/csi/cryptmapper/cryptmapper_test.go @@ -81,7 +81,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: false, }, "success with error on Load": { @@ -89,7 +89,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{loadErr: assert.AnError}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: false, }, "success with integrity": { @@ -98,7 +98,7 @@ func TestOpenCryptDevice(t *testing.T) { integrity: true, mapper: &stubCryptDevice{loadErr: assert.AnError}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: false, }, "error on Init": { @@ -106,7 +106,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{initErr: assert.AnError}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: true, }, "error on Format": { @@ -114,7 +114,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{loadErr: assert.AnError, formatErr: assert.AnError}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: true, }, "error on Activate": { @@ -122,7 +122,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{activatePassErr: assert.AnError}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: true, }, "error on diskInfo": { @@ -130,7 +130,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{loadErr: assert.AnError}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "", assert.AnError }, + diskInfo: func(_ string) (string, error) { return "", assert.AnError }, wantErr: true, }, "disk is already formatted": { @@ -138,7 +138,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{loadErr: assert.AnError}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "ext4", nil }, + diskInfo: func(_ string) (string, error) { return "ext4", nil }, wantErr: true, }, "error with integrity on wipe": { @@ -147,7 +147,7 @@ func TestOpenCryptDevice(t *testing.T) { integrity: true, mapper: &stubCryptDevice{loadErr: assert.AnError, wipeErr: assert.AnError}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: true, }, "error on adding keyslot": { @@ -155,7 +155,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{loadErr: assert.AnError, keySlotAddErr: assert.AnError}, kms: &fakeKMS{}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: true, }, "incorrect key length": { @@ -163,7 +163,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{}, kms: &fakeKMS{presetKey: []byte{0x1, 0x2, 0x3}}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: true, }, "incorrect key length with error on Load": { @@ -171,7 +171,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{loadErr: assert.AnError}, kms: &fakeKMS{presetKey: []byte{0x1, 0x2, 0x3}}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: true, }, "getKey fails": { @@ -179,7 +179,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{}, kms: &fakeKMS{getDEKErr: assert.AnError}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: true, }, "getKey fails with error on Load": { @@ -187,7 +187,7 @@ func TestOpenCryptDevice(t *testing.T) { volumeID: "volume0", mapper: &stubCryptDevice{loadErr: assert.AnError}, kms: &fakeKMS{getDEKErr: assert.AnError}, - diskInfo: func(disk string) (string, error) { return "", nil }, + diskInfo: func(_ string) (string, error) { return "", nil }, wantErr: true, }, } diff --git a/disk-mapper/internal/recoveryserver/recoveryserver_test.go b/disk-mapper/internal/recoveryserver/recoveryserver_test.go index 9da0a1ce2e..cf4e6c0433 100644 --- a/disk-mapper/internal/recoveryserver/recoveryserver_test.go +++ b/disk-mapper/internal/recoveryserver/recoveryserver_test.go @@ -147,7 +147,7 @@ func TestRecover(t *testing.T) { } func newStubKMS(setupErr, getDEKErr error) kmsFactory { - return func(ctx context.Context, storageURI string, kmsURI string) (kms.CloudKMS, error) { + return func(_ context.Context, _ string, _ string) (kms.CloudKMS, error) { if setupErr != nil { return nil, setupErr } diff --git a/internal/api/attestationconfigapi/cli/validargs.go b/internal/api/attestationconfigapi/cli/validargs.go index c077c58e0e..033aaa0a33 100644 --- a/internal/api/attestationconfigapi/cli/validargs.go +++ b/internal/api/attestationconfigapi/cli/validargs.go @@ -15,7 +15,7 @@ import ( ) func isCloudProvider(arg int) cobra.PositionalArgs { - return func(cmd *cobra.Command, args []string) error { + return func(_ *cobra.Command, args []string) error { if provider := cloudprovider.FromString(args[arg]); provider == cloudprovider.Unknown { return fmt.Errorf("argument %s isn't a valid cloud provider", args[arg]) } @@ -24,7 +24,7 @@ func isCloudProvider(arg int) cobra.PositionalArgs { } func isValidKind(arg int) cobra.PositionalArgs { - return func(cmd *cobra.Command, args []string) error { + return func(_ *cobra.Command, args []string) error { if kind := kindFromString(args[arg]); kind == unknown { return fmt.Errorf("argument %s isn't a valid kind", args[arg]) } diff --git a/internal/atls/atls.go b/internal/atls/atls.go index 14f5c1f768..1fff52d175 100644 --- a/internal/atls/atls.go +++ b/internal/atls/atls.go @@ -96,7 +96,7 @@ func getATLSConfigForClientFunc(issuer Issuer, validators []Validator) (func(*tl } // this function will be called once for every client - return func(chi *tls.ClientHelloInfo) (*tls.Config, error) { + return func(_ *tls.ClientHelloInfo) (*tls.Config, error) { // generate nonce for this connection serverNonce, err := crypto.GenerateRandomBytes(crypto.RNGLengthDefault) if err != nil { diff --git a/internal/atls/atls_test.go b/internal/atls/atls_test.go index e25122797a..db315b3a11 100644 --- a/internal/atls/atls_test.go +++ b/internal/atls/atls_test.go @@ -142,7 +142,7 @@ func TestTLSConfig(t *testing.T) { serverConfig, err := CreateAttestationServerTLSConfig(tc.serverIssuer, tc.serverValidators) require.NoError(err) - server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = io.WriteString(w, "hello") })) server.TLS = serverConfig @@ -196,7 +196,7 @@ func TestClientConnectionConcurrency(t *testing.T) { serverCfg, err := CreateAttestationServerTLSConfig(NewFakeIssuer(variant.Dummy{}), NewFakeValidators(variant.Dummy{})) require.NoError(err) - server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = io.WriteString(w, "hello") })) server.TLS = serverCfg @@ -270,7 +270,7 @@ func TestServerConnectionConcurrency(t *testing.T) { require.NoError(err) for i := 0; i < serverCount; i++ { - server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = io.WriteString(w, "hello") })) server.TLS = serverCfg diff --git a/internal/attestation/azure/snp/validator_test.go b/internal/attestation/azure/snp/validator_test.go index 64d6f03e2f..f07428461e 100644 --- a/internal/attestation/azure/snp/validator_test.go +++ b/internal/attestation/azure/snp/validator_test.go @@ -57,7 +57,7 @@ func TestNewValidator(t *testing.T) { } for name, tc := range testCases { - t.Run(name, func(t *testing.T) { + t.Run(name, func(_ *testing.T) { validator := NewValidator(tc.cfg, tc.logger) require.NotNil(validator) require.NotNil(validator.log) diff --git a/internal/attestation/azure/tdx/issuer_test.go b/internal/attestation/azure/tdx/issuer_test.go index 9194ccfa00..e57e63aa09 100644 --- a/internal/attestation/azure/tdx/issuer_test.go +++ b/internal/attestation/azure/tdx/issuer_test.go @@ -91,7 +91,7 @@ func TestIMDSGetQuote(t *testing.T) { wantErr bool }{ "success": { - client: newTestClient(func(req *http.Request) *http.Response { + client: newTestClient(func(_ *http.Request) *http.Response { quote := quoteResponse{ Quote: "test", } @@ -106,7 +106,7 @@ func TestIMDSGetQuote(t *testing.T) { wantErr: false, }, "bad status code": { - client: newTestClient(func(req *http.Request) *http.Response { + client: newTestClient(func(_ *http.Request) *http.Response { return &http.Response{ StatusCode: http.StatusInternalServerError, Body: io.NopCloser(bytes.NewBufferString("")), @@ -116,7 +116,7 @@ func TestIMDSGetQuote(t *testing.T) { wantErr: true, }, "bad json": { - client: newTestClient(func(req *http.Request) *http.Response { + client: newTestClient(func(_ *http.Request) *http.Response { return &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewBufferString("")), diff --git a/internal/attestation/azure/trustedlaunch/trustedlaunch_test.go b/internal/attestation/azure/trustedlaunch/trustedlaunch_test.go index 023bb785f7..a3bef9ed9c 100644 --- a/internal/attestation/azure/trustedlaunch/trustedlaunch_test.go +++ b/internal/attestation/azure/trustedlaunch/trustedlaunch_test.go @@ -104,7 +104,7 @@ func TestGetAttestationCert(t *testing.T) { wantValidateErr bool }{ "success": { - crlServer: func(req *http.Request) *http.Response { + crlServer: func(_ *http.Request) *http.Response { return &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader(intermediateCert.Raw)), @@ -136,14 +136,14 @@ func TestGetAttestationCert(t *testing.T) { }, }, "intermediate cert cannot be fetched": { - crlServer: func(req *http.Request) *http.Response { + crlServer: func(_ *http.Request) *http.Response { return &http.Response{StatusCode: http.StatusNotFound} }, getAkCert: defaultAkCertFunc, wantIssueErr: true, }, "intermediate cert is not signed by root cert": { - crlServer: func(req *http.Request) *http.Response { + crlServer: func(_ *http.Request) *http.Response { return &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader(rootCert.Raw)), @@ -153,7 +153,7 @@ func TestGetAttestationCert(t *testing.T) { wantValidateErr: true, }, "ak does not match ak cert public key": { - crlServer: func(req *http.Request) *http.Response { + crlServer: func(_ *http.Request) *http.Response { return &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader(intermediateCert.Raw)), diff --git a/internal/attestation/gcp/validator_test.go b/internal/attestation/gcp/validator_test.go index 09b9ade4a8..203809a4ff 100644 --- a/internal/attestation/gcp/validator_test.go +++ b/internal/attestation/gcp/validator_test.go @@ -176,7 +176,7 @@ type fakeInstanceClient struct { } func prepareFakeClient(ident *computepb.ShieldedInstanceIdentity, newErr, getIdentErr error) func(ctx context.Context, opts ...option.ClientOption) (gcpRestClient, error) { - return func(ctx context.Context, opts ...option.ClientOption) (gcpRestClient, error) { + return func(_ context.Context, _ ...option.ClientOption) (gcpRestClient, error) { return &fakeInstanceClient{ getIdentErr: getIdentErr, ident: ident, diff --git a/internal/attestation/vtpm/attestation_test.go b/internal/attestation/vtpm/attestation_test.go index a1bb237c50..311b9ebad1 100644 --- a/internal/attestation/vtpm/attestation_test.go +++ b/internal/attestation/vtpm/attestation_test.go @@ -308,7 +308,7 @@ func TestFailIssuer(t *testing.T) { "fail getAttestationKey": { issuer: NewIssuer( newSimTPMWithEventLog, - func(tpm io.ReadWriter) (*tpmclient.Key, error) { + func(_ io.ReadWriter) (*tpmclient.Key, error) { return nil, errors.New("failure") }, fakeGetInstanceInfo, @@ -320,7 +320,7 @@ func TestFailIssuer(t *testing.T) { "fail Attest": { issuer: NewIssuer( newSimTPMWithEventLog, - func(tpm io.ReadWriter) (*tpmclient.Key, error) { + func(_ io.ReadWriter) (*tpmclient.Key, error) { return &tpmclient.Key{}, nil }, fakeGetInstanceInfo, diff --git a/internal/cloud/azure/imds_test.go b/internal/cloud/azure/imds_test.go index b0afa517e6..242a052e74 100644 --- a/internal/cloud/azure/imds_test.go +++ b/internal/cloud/azure/imds_test.go @@ -185,7 +185,7 @@ func TestIMDSClient(t *testing.T) { wantTags: defaultWantTags, }, "invalid imds response detected": { - server: newHTTPBufconnServer(func(writer http.ResponseWriter, request *http.Request) { + server: newHTTPBufconnServer(func(writer http.ResponseWriter, _ *http.Request) { fmt.Fprintln(writer, "invalid-result") }), wantProviderIDErr: true, diff --git a/internal/constellation/helm/retryaction.go b/internal/constellation/helm/retryaction.go index 32e54b7463..89579356e2 100644 --- a/internal/constellation/helm/retryaction.go +++ b/internal/constellation/helm/retryaction.go @@ -28,7 +28,7 @@ type retrieableApplier interface { // retryApply retries the given retriable action. func retryApply(ctx context.Context, action retrieableApplier, retryInterval time.Duration, log debugLog) error { var retries int - retriable := func(err error) bool { + retriable := func(_ error) bool { // abort after maximumRetryAttempts tries. if retries >= maximumRetryAttempts { return false diff --git a/internal/grpc/atlscredentials/atlscredentials_test.go b/internal/grpc/atlscredentials/atlscredentials_test.go index 77272088df..a9ddaa6ac0 100644 --- a/internal/grpc/atlscredentials/atlscredentials_test.go +++ b/internal/grpc/atlscredentials/atlscredentials_test.go @@ -66,7 +66,7 @@ func TestATLSCredentials(t *testing.T) { go func() { var err error defer func() { errChan <- err }() - conn, err := grpc.DialContext(context.Background(), "", grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) { + conn, err := grpc.DialContext(context.Background(), "", grpc.WithContextDialer(func(_ context.Context, _ string) (net.Conn, error) { return lis.Dial() }), grpc.WithTransportCredentials(clientCreds)) require.NoError(err) diff --git a/internal/installer/installer_test.go b/internal/installer/installer_test.go index dead113c04..1e346f4343 100644 --- a/internal/installer/installer_test.go +++ b/internal/installer/installer_test.go @@ -80,7 +80,7 @@ func TestInstall(t *testing.T) { wantFiles: map[string][]byte{"/destination": []byte("file-contents")}, }, "download fails": { - server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }), + server: newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(500) }), component: &components.Component{ Url: serverURL, Hash: "sha256:abc", @@ -89,7 +89,7 @@ func TestInstall(t *testing.T) { wantErr: true, }, "dataurl works": { - server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }), + server: newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(500) }), component: &components.Component{ Url: "data:text/plain,file-contents", Hash: "", @@ -98,7 +98,7 @@ func TestInstall(t *testing.T) { wantFiles: map[string][]byte{"/destination": []byte("file-contents")}, }, "broken dataurl fails": { - server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }), + server: newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(500) }), component: &components.Component{ Url: "data:file-contents", Hash: "", @@ -129,7 +129,7 @@ func TestInstall(t *testing.T) { fs: &afero.Afero{Fs: afero.NewMemMapFs()}, hClient: &hClient, clock: testclock.NewFakeClock(time.Time{}), - retriable: func(err error) bool { return false }, + retriable: func(_ error) bool { return false }, } err := inst.Install(context.Background(), tc.component) @@ -388,7 +388,7 @@ func TestDownloadToTempDir(t *testing.T) { wantFile: []byte("file-contents"), }, "download fails": { - server: newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) }), + server: newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(500) }), wantErr: true, }, "creating temp file fails on RO fs": { @@ -397,7 +397,7 @@ func TestDownloadToTempDir(t *testing.T) { wantErr: true, }, "content length mismatch": { - server: newHTTPBufconnServer(func(writer http.ResponseWriter, request *http.Request) { + server: newHTTPBufconnServer(func(writer http.ResponseWriter, _ *http.Request) { writer.Header().Set("Content-Length", "1337") writer.WriteHeader(200) }), @@ -607,7 +607,7 @@ func newHTTPBufconnServer(handlerFunc http.HandlerFunc) httpBufconnServer { } func newHTTPBufconnServerWithBody(body []byte) httpBufconnServer { - return newHTTPBufconnServer(func(writer http.ResponseWriter, request *http.Request) { + return newHTTPBufconnServer(func(writer http.ResponseWriter, _ *http.Request) { if _, err := writer.Write(body); err != nil { panic(err) } @@ -615,7 +615,7 @@ func newHTTPBufconnServerWithBody(body []byte) httpBufconnServer { } func newHTTPBufconnServerWithState(state chan int, body []byte) httpBufconnServer { - return newHTTPBufconnServer(func(w http.ResponseWriter, r *http.Request) { + return newHTTPBufconnServer(func(w http.ResponseWriter, _ *http.Request) { switch <-state { case 500: w.WriteHeader(500) diff --git a/internal/logger/log.go b/internal/logger/log.go index 26c891009c..d8d62b13ab 100644 --- a/internal/logger/log.go +++ b/internal/logger/log.go @@ -69,7 +69,7 @@ func GetClientStreamInterceptor(l *slog.Logger) grpc.DialOption { } func middlewareLogger(l *slog.Logger) logging.Logger { - return logging.LoggerFunc(func(ctx context.Context, lvl logging.Level, msg string, fields ...any) { + return logging.LoggerFunc(func(_ context.Context, lvl logging.Level, msg string, fields ...any) { var pcs [1]uintptr runtime.Callers(2, pcs[:]) // skip [Callers, LoggerFunc] diff --git a/internal/validation/constraints_test.go b/internal/validation/constraints_test.go index 8386801cdf..103649d565 100644 --- a/internal/validation/constraints_test.go +++ b/internal/validation/constraints_test.go @@ -165,7 +165,7 @@ func TestNotEmptySlice(t *testing.T) { } func TestAll(t *testing.T) { - c := func(i int, s string) *Constraint { + c := func(_ int, s string) *Constraint { return Equal(s, "abc") } testCases := map[string]struct { diff --git a/joinservice/internal/watcher/validator_test.go b/joinservice/internal/watcher/validator_test.go index 67b3daff46..efada4028d 100644 --- a/joinservice/internal/watcher/validator_test.go +++ b/joinservice/internal/watcher/validator_test.go @@ -138,7 +138,7 @@ func TestUpdate(t *testing.T) { // create tls config and start the server serverConfig, err := atls.CreateAttestationServerTLSConfig(nil, []atls.Validator{validator}) require.NoError(err) - server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, _ = io.WriteString(w, "hello") })) server.TLS = serverConfig diff --git a/operators/constellation-node-operator/controllers/autoscalingstrategy_controller.go b/operators/constellation-node-operator/controllers/autoscalingstrategy_controller.go index 31e615ec66..9fa73ff246 100644 --- a/operators/constellation-node-operator/controllers/autoscalingstrategy_controller.go +++ b/operators/constellation-node-operator/controllers/autoscalingstrategy_controller.go @@ -175,7 +175,7 @@ func (r *AutoscalingStrategyReconciler) findObjectsForDeployment(ctx context.Con // scalingGroupChangePredicate filters events on scaling group resources. func scalingGroupChangePredicate() predicate.Predicate { return predicate.Funcs{ - CreateFunc: func(e event.CreateEvent) bool { + CreateFunc: func(_ event.CreateEvent) bool { return true }, UpdateFunc: func(e event.UpdateEvent) bool { @@ -198,10 +198,10 @@ func scalingGroupChangePredicate() predicate.Predicate { return false } }, - DeleteFunc: func(e event.DeleteEvent) bool { + DeleteFunc: func(_ event.DeleteEvent) bool { return true }, - GenericFunc: func(e event.GenericEvent) bool { + GenericFunc: func(_ event.GenericEvent) bool { return false }, } diff --git a/operators/constellation-node-operator/controllers/pendingnode_controller.go b/operators/constellation-node-operator/controllers/pendingnode_controller.go index 8e35e7e569..1bd5b97dfd 100644 --- a/operators/constellation-node-operator/controllers/pendingnode_controller.go +++ b/operators/constellation-node-operator/controllers/pendingnode_controller.go @@ -165,7 +165,7 @@ func (r *PendingNodeReconciler) SetupWithManager(mgr ctrl.Manager) error { // joining, leaving, node becoming ready or node receiving a provider id. func nodeStateChangePredicate() predicate.Predicate { return predicate.Funcs{ - CreateFunc: func(e event.CreateEvent) bool { + CreateFunc: func(_ event.CreateEvent) bool { return true }, UpdateFunc: func(e event.UpdateEvent) bool { @@ -181,10 +181,10 @@ func nodeStateChangePredicate() predicate.Predicate { receivedProviderID := len(oldNode.Spec.ProviderID) == 0 && len(newNode.Spec.ProviderID) != 0 return becameReady || receivedProviderID }, - DeleteFunc: func(e event.DeleteEvent) bool { + DeleteFunc: func(_ event.DeleteEvent) bool { return true }, - GenericFunc: func(e event.GenericEvent) bool { + GenericFunc: func(_ event.GenericEvent) bool { return false }, } diff --git a/operators/constellation-node-operator/internal/cloud/azure/client/nodeimage_test.go b/operators/constellation-node-operator/internal/cloud/azure/client/nodeimage_test.go index daf8d600fa..1358596026 100644 --- a/operators/constellation-node-operator/internal/cloud/azure/client/nodeimage_test.go +++ b/operators/constellation-node-operator/internal/cloud/azure/client/nodeimage_test.go @@ -252,7 +252,7 @@ func TestCreateNode(t *testing.T) { getErr: tc.getSKUCapacityErr, updateErr: tc.updateScaleSetErr, }, - capacityPollerGenerator: func(resourceGroup, scaleSet string, wantedCapacity int64) capacityPoller { + capacityPollerGenerator: func(_, _ string, _ int64) capacityPoller { return poller }, } diff --git a/operators/constellation-node-operator/sgreconciler/nodejoin_watcher.go b/operators/constellation-node-operator/sgreconciler/nodejoin_watcher.go index 4458de2436..2b31aef505 100644 --- a/operators/constellation-node-operator/sgreconciler/nodejoin_watcher.go +++ b/operators/constellation-node-operator/sgreconciler/nodejoin_watcher.go @@ -55,7 +55,7 @@ func (w *NodeJoinWatcher) SetupWithManager(mgr ctrl.Manager) error { Named("node-join-watcher"). Watches( client.Object(&corev1.Node{}), - handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request { + handler.EnqueueRequestsFromMapFunc(func(_ context.Context, obj client.Object) []ctrl.Request { return []ctrl.Request{{ NamespacedName: types.NamespacedName{Name: obj.GetName()}, }} @@ -70,7 +70,7 @@ func nodeJoinLeavePredicate() predicate.Predicate { return predicate.Funcs{ // CreateFunc is not specified => never filter out create events // DeleteFunc is not specified => never filter out delete events - UpdateFunc: func(e event.UpdateEvent) bool { return false }, - GenericFunc: func(e event.GenericEvent) bool { return false }, + UpdateFunc: func(_ event.UpdateEvent) bool { return false }, + GenericFunc: func(_ event.GenericEvent) bool { return false }, } } diff --git a/terraform-provider-constellation/internal/provider/cluster_resource.go b/terraform-provider-constellation/internal/provider/cluster_resource.go index 35c682a44d..9f51aa8485 100644 --- a/terraform-provider-constellation/internal/provider/cluster_resource.go +++ b/terraform-provider-constellation/internal/provider/cluster_resource.go @@ -428,7 +428,7 @@ func (r *ClusterResource) Configure(_ context.Context, req resource.ConfigureReq return dialer.New(nil, validator, &net.Dialer{}) } - r.newApplier = func(ctx context.Context, validator atls.Validator) *constellation.Applier { + r.newApplier = func(ctx context.Context, _ atls.Validator) *constellation.Applier { return constellation.NewApplier(&tfContextLogger{ctx: ctx}, &nopSpinner{}, constellation.ApplyContextTerraform, newDialer) } }