Skip to content

Commit

Permalink
chore: fix unused parameter lint in new golangcilint version
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Feb 21, 2024
1 parent 68fc2b0 commit 6590345
Show file tree
Hide file tree
Showing 35 changed files with 92 additions and 92 deletions.
2 changes: 1 addition & 1 deletion bootstrapper/internal/kubernetes/kubewaiter/kubewaiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/cloudcmd/tfplan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down
38 changes: 19 additions & 19 deletions cli/internal/cmd/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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{}
Expand Down Expand Up @@ -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,
Expand All @@ -344,16 +344,16 @@ 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,
},
"[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),
Expand All @@ -363,36 +363,36 @@ 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),
},
wantPhases: newPhases(skipInitPhase, skipAttestationConfigPhase, skipCertSANsPhase, skipHelmPhase, skipK8sPhase, skipImagePhase),
},
"[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),
},
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/cmd/configgenerate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/cmd/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions cli/internal/cmd/iamcreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cli/internal/cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/cmd/maapatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/cmd/terminate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/cmd/upgradeapply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/cmd/userinteraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/cmd/validargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/terraform/terraform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
},
}

Expand Down
28 changes: 14 additions & 14 deletions csi/cryptmapper/cryptmapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ 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": {
source: "/dev/some-device",
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": {
Expand All @@ -98,47 +98,47 @@ 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": {
source: "/dev/some-device",
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": {
source: "/dev/some-device",
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": {
source: "/dev/some-device",
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": {
source: "/dev/some-device",
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": {
source: "/dev/some-device",
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": {
Expand All @@ -147,47 +147,47 @@ 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": {
source: "/dev/some-device",
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": {
source: "/dev/some-device",
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": {
source: "/dev/some-device",
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": {
source: "/dev/some-device",
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": {
source: "/dev/some-device",
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,
},
}
Expand Down
2 changes: 1 addition & 1 deletion disk-mapper/internal/recoveryserver/recoveryserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions internal/api/attestationconfigapi/cli/validargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand All @@ -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])
}
Expand Down
Loading

0 comments on commit 6590345

Please sign in to comment.