go: remove unused parameters

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2023-03-20 11:03:36 +01:00
parent 822d7823f8
commit 0036b24266
106 changed files with 320 additions and 323 deletions

View file

@ -90,7 +90,7 @@ func signalContext(ctx context.Context, sig os.Signal) (context.Context, context
return sigCtx, cancelFunc
}
func preRunRoot(cmd *cobra.Command, args []string) {
func preRunRoot(cmd *cobra.Command, _ []string) {
cmd.SilenceUsage = true
}

View file

@ -45,7 +45,7 @@ type stubTerraformClient struct {
showErr error
}
func (c *stubTerraformClient) CreateCluster(ctx context.Context) (terraform.CreateOutput, error) {
func (c *stubTerraformClient) CreateCluster(_ context.Context) (terraform.CreateOutput, error) {
return terraform.CreateOutput{
IP: c.ip,
Secret: c.initSecret,
@ -54,15 +54,15 @@ func (c *stubTerraformClient) CreateCluster(ctx context.Context) (terraform.Crea
}, c.createClusterErr
}
func (c *stubTerraformClient) CreateIAMConfig(ctx context.Context, provider cloudprovider.Provider) (terraform.IAMOutput, error) {
func (c *stubTerraformClient) CreateIAMConfig(_ context.Context, _ cloudprovider.Provider) (terraform.IAMOutput, error) {
return c.iamOutput, c.iamOutputErr
}
func (c *stubTerraformClient) PrepareWorkspace(path string, input terraform.Variables) error {
func (c *stubTerraformClient) PrepareWorkspace(_ string, _ terraform.Variables) error {
return c.prepareWorkspaceErr
}
func (c *stubTerraformClient) Destroy(ctx context.Context) error {
func (c *stubTerraformClient) Destroy(_ context.Context) error {
c.destroyCalled = true
return c.destroyErr
}
@ -76,7 +76,7 @@ func (c *stubTerraformClient) RemoveInstaller() {
c.removeInstallerCalled = true
}
func (c *stubTerraformClient) Show(ctx context.Context) (*tfjson.State, error) {
func (c *stubTerraformClient) Show(_ context.Context) (*tfjson.State, error) {
c.showCalled = true
return c.tfjsonState, c.showErr
}

View file

@ -431,7 +431,7 @@ type stubDynamicClient struct {
updateErr error
}
func (u *stubDynamicClient) getCurrent(ctx context.Context, name string) (*unstructured.Unstructured, error) {
func (u *stubDynamicClient) getCurrent(_ context.Context, _ string) (*unstructured.Unstructured, error) {
return u.object, u.getErr
}
@ -450,16 +450,16 @@ type stubStableClient struct {
k8sErr error
}
func (s *stubStableClient) getCurrentConfigMap(ctx context.Context, name string) (*corev1.ConfigMap, error) {
func (s *stubStableClient) getCurrentConfigMap(_ context.Context, _ string) (*corev1.ConfigMap, error) {
return s.configMap, s.getErr
}
func (s *stubStableClient) updateConfigMap(ctx context.Context, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error) {
func (s *stubStableClient) updateConfigMap(_ context.Context, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error) {
s.updatedConfigMap = configMap
return s.updatedConfigMap, s.updateErr
}
func (s *stubStableClient) createConfigMap(ctx context.Context, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error) {
func (s *stubStableClient) createConfigMap(_ context.Context, configMap *corev1.ConfigMap) (*corev1.ConfigMap, error) {
s.configMap = configMap
return s.configMap, s.createErr
}

View file

@ -33,11 +33,11 @@ type stubCloudCreator struct {
}
func (c *stubCloudCreator) Create(
ctx context.Context,
_ context.Context,
provider cloudprovider.Provider,
config *config.Config,
insType string,
coordCount, nodeCount int,
_ *config.Config,
_ string,
_, _ int,
) (clusterid.File, error) {
c.createCalled = true
c.id.CloudProvider = provider
@ -65,9 +65,9 @@ type stubIAMCreator struct {
}
func (c *stubIAMCreator) Create(
ctx context.Context,
_ context.Context,
provider cloudprovider.Provider,
iamConfig *cloudcmd.IAMConfig,
_ *cloudcmd.IAMConfig,
) (iamid.File, error) {
c.createCalled = true
c.id.CloudProvider = provider
@ -82,12 +82,12 @@ type stubIAMDestroyer struct {
getTfstateKeyErr error
}
func (d *stubIAMDestroyer) DestroyIAMConfiguration(ctx context.Context) error {
func (d *stubIAMDestroyer) DestroyIAMConfiguration(_ context.Context) error {
d.destroyCalled = true
return d.destroyErr
}
func (d *stubIAMDestroyer) GetTfstateServiceAccountKey(ctx context.Context) (gcpshared.ServiceAccountKey, error) {
func (d *stubIAMDestroyer) GetTfstateServiceAccountKey(_ context.Context) (gcpshared.ServiceAccountKey, error) {
d.getTfstateKeyCalled = true
return d.gcpSaKey, d.getTfstateKeyErr
}

View file

@ -53,7 +53,7 @@ type configFetchMeasurementsCmd struct {
log debugLog
}
func runConfigFetchMeasurements(cmd *cobra.Command, args []string) error {
func runConfigFetchMeasurements(cmd *cobra.Command, _ []string) error {
log, err := newCLILogger(cmd)
if err != nil {
return fmt.Errorf("creating logger: %w", err)

View file

@ -156,7 +156,7 @@ func parseGenerateFlags(cmd *cobra.Command) (generateFlags, error) {
// createCompletion handles the completion of the create command. It is frequently called
// while the user types arguments of the command to suggest completion.
func generateCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
func generateCompletion(_ *cobra.Command, args []string, _ string) ([]string, cobra.ShellCompDirective) {
switch len(args) {
case 0:
return []string{"aws", "gcp", "azure", "qemu"}, cobra.ShellCompDirectiveNoFileComp

View file

@ -25,7 +25,7 @@ func newConfigInstanceTypesCmd() *cobra.Command {
return cmd
}
func printSupportedInstanceTypes(cmd *cobra.Command, args []string) {
func printSupportedInstanceTypes(cmd *cobra.Command, _ []string) {
cmd.Printf(`AWS instance families:
%v
Azure Confidential VM instance types:

View file

@ -25,7 +25,7 @@ func newConfigKubernetesVersionsCmd() *cobra.Command {
return cmd
}
func printSupportedKubernetesVersions(cmd *cobra.Command, args []string) {
func printSupportedKubernetesVersions(cmd *cobra.Command, _ []string) {
cmd.Printf("Supported Kubernetes Versions:\n\t%s\n", formatKubernetesVersions())
}

View file

@ -42,7 +42,7 @@ type createCmd struct {
log debugLog
}
func runCreate(cmd *cobra.Command, args []string) error {
func runCreate(cmd *cobra.Command, _ []string) error {
log, err := newCLILogger(cmd)
if err != nil {
return fmt.Errorf("creating logger: %w", err)

View file

@ -423,7 +423,7 @@ func (c *awsIAMCreator) writeOutputValuesToConfig(conf *config.Config, flags iam
conf.Provider.AWS.IAMProfileWorkerNodes = iamFile.AWSOutput.WorkerNodeInstanceProfile
}
func (c *awsIAMCreator) parseAndWriteIDFile(iamFile iamid.File, fileHandler file.Handler) error {
func (c *awsIAMCreator) parseAndWriteIDFile(_ iamid.File, _ file.Handler) error {
return nil
}
@ -488,7 +488,7 @@ func (c *azureIAMCreator) writeOutputValuesToConfig(conf *config.Config, flags i
conf.Provider.Azure.ClientSecretValue = iamFile.AzureOutput.ApplicationClientSecretValue
}
func (c *azureIAMCreator) parseAndWriteIDFile(iamFile iamid.File, fileHandler file.Handler) error {
func (c *azureIAMCreator) parseAndWriteIDFile(_ iamid.File, _ file.Handler) error {
return nil
}
@ -552,14 +552,14 @@ func (c *gcpIAMCreator) printConfirmValues(cmd *cobra.Command, flags iamFlags) {
cmd.Printf("Zone:\t\t\t%s\n\n", flags.gcp.zone)
}
func (c *gcpIAMCreator) printOutputValues(cmd *cobra.Command, flags iamFlags, iamFile iamid.File) {
func (c *gcpIAMCreator) printOutputValues(cmd *cobra.Command, _ iamFlags, _ iamid.File) {
cmd.Printf("projectID:\t\t%s\n", constants.GCPServiceAccountKeyFile)
cmd.Printf("region:\t\t\t%s\n", constants.GCPServiceAccountKeyFile)
cmd.Printf("zone:\t\t\t%s\n", constants.GCPServiceAccountKeyFile)
cmd.Printf("serviceAccountKeyPath:\t%s\n\n", constants.GCPServiceAccountKeyFile)
}
func (c *gcpIAMCreator) writeOutputValuesToConfig(conf *config.Config, flags iamFlags, iamFile iamid.File) {
func (c *gcpIAMCreator) writeOutputValuesToConfig(conf *config.Config, flags iamFlags, _ iamid.File) {
conf.Provider.GCP.Project = flags.gcp.projectID
conf.Provider.GCP.ServiceAccountKeyPath = constants.GCPServiceAccountKeyFile
conf.Provider.GCP.Region = flags.gcp.region

View file

@ -33,7 +33,7 @@ func newIAMDestroyCmd() *cobra.Command {
return cmd
}
func runIAMDestroy(cmd *cobra.Command, _args []string) error {
func runIAMDestroy(cmd *cobra.Command, _ []string) error {
log, err := newCLILogger(cmd)
if err != nil {
return fmt.Errorf("creating logger: %w", err)

View file

@ -71,7 +71,7 @@ type initCmd struct {
}
// runInitialize runs the initialize command.
func runInitialize(cmd *cobra.Command, args []string) error {
func runInitialize(cmd *cobra.Command, _ []string) error {
log, err := newCLILogger(cmd)
if err != nil {
return fmt.Errorf("creating logger: %w", err)

View file

@ -464,7 +464,7 @@ type testValidator struct {
pcrs measurements.M
}
func (v *testValidator) Validate(attDoc []byte, nonce []byte) ([]byte, error) {
func (v *testValidator) Validate(attDoc []byte, _ []byte) ([]byte, error) {
var attestation struct {
UserData []byte
PCRs map[uint32][]byte
@ -486,7 +486,7 @@ type testIssuer struct {
pcrs map[uint32][]byte
}
func (i *testIssuer) Issue(userData []byte, nonce []byte) ([]byte, error) {
func (i *testIssuer) Issue(userData []byte, _ []byte) ([]byte, error) {
return json.Marshal(
struct {
UserData []byte
@ -505,7 +505,7 @@ type stubInitServer struct {
initproto.UnimplementedAPIServer
}
func (s *stubInitServer) Init(ctx context.Context, req *initproto.InitRequest) (*initproto.InitResponse, error) {
func (s *stubInitServer) Init(_ context.Context, _ *initproto.InitRequest) (*initproto.InitResponse, error) {
return s.initResp, s.initErr
}
@ -563,7 +563,7 @@ func defaultConfigWithExpectedMeasurements(t *testing.T, conf *config.Config, cs
type stubLicenseClient struct{}
func (c *stubLicenseClient) QuotaCheck(ctx context.Context, checkRequest license.QuotaCheckRequest) (license.QuotaCheckResponse, error) {
func (c *stubLicenseClient) QuotaCheck(_ context.Context, _ license.QuotaCheckRequest) (license.QuotaCheckResponse, error) {
return license.QuotaCheckResponse{
Quota: 25,
}, nil

View file

@ -51,7 +51,7 @@ type miniUpCmd struct {
log debugLog
}
func runUp(cmd *cobra.Command, args []string) error {
func runUp(cmd *cobra.Command, _ []string) error {
log, err := newCLILogger(cmd)
if err != nil {
return fmt.Errorf("creating logger: %w", err)

View file

@ -343,4 +343,4 @@ func (d *stubDoer) Do(context.Context) error {
func (d *stubDoer) setDialer(grpcDialer, string) {}
func (d *stubDoer) setURIs(kmsURI, storageURI string) {}
func (d *stubDoer) setURIs(_, _ string) {}

View file

@ -34,7 +34,7 @@ func NewTerminateCmd() *cobra.Command {
}
// runTerminate runs the terminate command.
func runTerminate(cmd *cobra.Command, args []string) error {
func runTerminate(cmd *cobra.Command, _ []string) error {
fileHandler := file.NewHandler(afero.NewOsFs())
spinner, err := newSpinnerOrStderr(cmd)
if err != nil {

View file

@ -41,7 +41,7 @@ func newUpgradeApplyCmd() *cobra.Command {
return cmd
}
func runUpgradeApply(cmd *cobra.Command, args []string) error {
func runUpgradeApply(cmd *cobra.Command, _ []string) error {
log, err := newCLILogger(cmd)
if err != nil {
return fmt.Errorf("creating logger: %w", err)

View file

@ -73,10 +73,10 @@ type stubUpgrader struct {
helmErr error
}
func (u stubUpgrader) UpgradeNodeVersion(ctx context.Context, conf *config.Config) error {
func (u stubUpgrader) UpgradeNodeVersion(_ context.Context, _ *config.Config) error {
return u.nodeVersionErr
}
func (u stubUpgrader) UpgradeHelmServices(ctx context.Context, config *config.Config, timeout time.Duration, allowDestructive bool) error {
func (u stubUpgrader) UpgradeHelmServices(_ context.Context, _ *config.Config, _ time.Duration, _ bool) error {
return u.helmErr
}

View file

@ -50,7 +50,7 @@ func newUpgradeCheckCmd() *cobra.Command {
return cmd
}
func runUpgradeCheck(cmd *cobra.Command, args []string) error {
func runUpgradeCheck(cmd *cobra.Command, _ []string) error {
log, err := newCLILogger(cmd)
if err != nil {
return fmt.Errorf("creating logger: %w", err)
@ -144,7 +144,7 @@ func (u *upgradeCheckCmd) upgradeCheck(cmd *cobra.Command, fileHandler file.Hand
return err
}
supportedServices, supportedImages, supportedK8s, err := u.collect.supportedVersions(cmd.Context(), currentImage, csp)
supportedServices, supportedImages, supportedK8s, err := u.collect.supportedVersions(cmd.Context(), currentImage)
if err != nil {
return err
}
@ -229,10 +229,10 @@ func filterK8sUpgrades(currentVersion string, newVersions []string) []string {
type collector interface {
currentVersions(ctx context.Context) (serviceVersions string, imageVersion string, k8sVersion string, err error)
supportedVersions(ctx context.Context, version string, csp cloudprovider.Provider) (serviceVersions string, imageVersions []versionsapi.Version, k8sVersions []string, err error)
newImages(ctx context.Context, version string, csp cloudprovider.Provider) ([]versionsapi.Version, error)
supportedVersions(ctx context.Context, version string) (serviceVersions string, imageVersions []versionsapi.Version, k8sVersions []string, err error)
newImages(ctx context.Context, version string) ([]versionsapi.Version, error)
newMeasurementes(ctx context.Context, csp cloudprovider.Provider, images []versionsapi.Version) (map[string]measurements.M, error)
newerVersions(ctx context.Context, currentVersion string, allowedVersions []string) ([]versionsapi.Version, error)
newerVersions(ctx context.Context, allowedVersions []string) ([]versionsapi.Version, error)
}
type versionCollector struct {
@ -283,13 +283,13 @@ func (v *versionCollector) currentVersions(ctx context.Context) (serviceVersion
}
// supportedVersions returns slices of supported versions.
func (v *versionCollector) supportedVersions(ctx context.Context, version string, csp cloudprovider.Provider) (serviceVersion string, imageVersions []versionsapi.Version, k8sVersions []string, err error) {
func (v *versionCollector) supportedVersions(ctx context.Context, version string) (serviceVersion string, imageVersions []versionsapi.Version, k8sVersions []string, err error) {
k8sVersions = versions.SupportedK8sVersions()
serviceVersion, err = helm.AvailableServiceVersions()
if err != nil {
return "", nil, nil, fmt.Errorf("loading service versions: %w", err)
}
imageVersions, err = v.newImages(ctx, version, csp)
imageVersions, err = v.newImages(ctx, version)
if err != nil {
return "", nil, nil, fmt.Errorf("loading image versions: %w", err)
}
@ -297,7 +297,7 @@ func (v *versionCollector) supportedVersions(ctx context.Context, version string
return serviceVersion, imageVersions, k8sVersions, nil
}
func (v *versionCollector) newImages(ctx context.Context, version string, csp cloudprovider.Provider) ([]versionsapi.Version, error) {
func (v *versionCollector) newImages(ctx context.Context, version string) ([]versionsapi.Version, error) {
// find compatible images
// image updates should always be possible for the current minor version of the cluster
// (e.g. 0.1.0 -> 0.1.1, 0.1.2, 0.1.3, etc.)
@ -329,7 +329,7 @@ func (v *versionCollector) newImages(ctx context.Context, version string, csp cl
}
v.log.Debugf("Allowed minor versions are %#v", allowedMinorVersions)
newerImages, err := v.newerVersions(ctx, currentImageMinorVer, allowedMinorVersions)
newerImages, err := v.newerVersions(ctx, allowedMinorVersions)
if err != nil {
return nil, fmt.Errorf("newer versions: %w", err)
}
@ -337,7 +337,7 @@ func (v *versionCollector) newImages(ctx context.Context, version string, csp cl
return newerImages, nil
}
func (v *versionCollector) newerVersions(ctx context.Context, currentVersion string, allowedVersions []string) ([]versionsapi.Version, error) {
func (v *versionCollector) newerVersions(ctx context.Context, allowedVersions []string) ([]versionsapi.Version, error) {
var updateCandidates []versionsapi.Version
for _, minorVer := range allowedVersions {
patchList := versionsapi.List{

View file

@ -267,23 +267,23 @@ type stubVersionCollector struct {
someErr error
}
func (s *stubVersionCollector) newMeasurementes(ctx context.Context, csp cloudprovider.Provider, images []versionsapi.Version) (map[string]measurements.M, error) {
func (s *stubVersionCollector) newMeasurementes(_ context.Context, _ cloudprovider.Provider, _ []versionsapi.Version) (map[string]measurements.M, error) {
return s.supportedImageVersions, nil
}
func (s *stubVersionCollector) currentVersions(ctx context.Context) (serviceVersions string, imageVersion string, k8sVersion string, err error) {
func (s *stubVersionCollector) currentVersions(_ context.Context) (serviceVersions string, imageVersion string, k8sVersion string, err error) {
return s.currentServicesVersions, s.currentImageVersion, s.currentK8sVersion, s.someErr
}
func (s *stubVersionCollector) supportedVersions(ctx context.Context, version string, csp cloudprovider.Provider) (serviceVersions string, imageVersions []versionsapi.Version, k8sVersions []string, err error) {
func (s *stubVersionCollector) supportedVersions(_ context.Context, _ string) (serviceVersions string, imageVersions []versionsapi.Version, k8sVersions []string, err error) {
return s.supportedServicesVersions, s.supportedImages, s.supportedK8sVersions, s.someErr
}
func (s *stubVersionCollector) newImages(ctx context.Context, version string, csp cloudprovider.Provider) ([]versionsapi.Version, error) {
func (s *stubVersionCollector) newImages(_ context.Context, _ string) ([]versionsapi.Version, error) {
return s.images, nil
}
func (s *stubVersionCollector) newerVersions(ctx context.Context, currentVersion string, allowedVersions []string) ([]versionsapi.Version, error) {
func (s *stubVersionCollector) newerVersions(_ context.Context, _ []string) ([]versionsapi.Version, error) {
return s.images, nil
}
@ -297,6 +297,6 @@ func (u stubUpgradeChecker) CurrentImage(context.Context) (string, error) {
return u.image, u.err
}
func (u stubUpgradeChecker) CurrentKubernetesVersion(ctx context.Context) (string, error) {
func (u stubUpgradeChecker) CurrentKubernetesVersion(_ context.Context) (string, error) {
return u.k8sVersion, u.err
}

View file

@ -50,7 +50,7 @@ type verifyCmd struct {
log debugLog
}
func runVerify(cmd *cobra.Command, args []string) error {
func runVerify(cmd *cobra.Command, _ []string) error {
log, err := newCLILogger(cmd)
if err != nil {
return fmt.Errorf("creating logger: %w", err)

View file

@ -263,7 +263,7 @@ type stubVerifyClient struct {
endpoint string
}
func (c *stubVerifyClient) Verify(ctx context.Context, endpoint string, req *verifyproto.GetAttestationRequest, validator atls.Validator) error {
func (c *stubVerifyClient) Verify(_ context.Context, endpoint string, _ *verifyproto.GetAttestationRequest, _ atls.Validator) error {
c.endpoint = endpoint
return c.verifyErr
}

View file

@ -26,7 +26,7 @@ func NewVersionCmd() *cobra.Command {
return cmd
}
func runVersion(cmd *cobra.Command, args []string) {
func runVersion(cmd *cobra.Command, _ []string) {
buildInfo, ok := debug.ReadBuildInfo()
var commit, state, date, goVersion, compiler, platform string
if ok {

View file

@ -142,8 +142,8 @@ func TestBackupCRs(t *testing.T) {
type stubLog struct{}
func (s stubLog) Debugf(format string, args ...any) {}
func (s stubLog) Sync() {}
func (s stubLog) Debugf(_ string, _ ...any) {}
func (s stubLog) Sync() {}
type stubCrdClient struct {
crds []apiextensionsv1.CustomResourceDefinition
@ -153,14 +153,14 @@ type stubCrdClient struct {
crdClient
}
func (c stubCrdClient) GetCRDs(ctx context.Context) ([]apiextensionsv1.CustomResourceDefinition, error) {
func (c stubCrdClient) GetCRDs(_ context.Context) ([]apiextensionsv1.CustomResourceDefinition, error) {
if c.getCRDsError != nil {
return nil, c.getCRDsError
}
return c.crds, nil
}
func (c stubCrdClient) GetCRs(ctx context.Context, gvr schema.GroupVersionResource) ([]unstructured.Unstructured, error) {
func (c stubCrdClient) GetCRs(_ context.Context, _ schema.GroupVersionResource) ([]unstructured.Unstructured, error) {
if c.getCRsError != nil {
return nil, c.getCRsError
}

View file

@ -73,10 +73,10 @@ func (a *stubActionWrapper) listAction(_ string) ([]*release.Release, error) {
return []*release.Release{{Chart: &chart.Chart{Metadata: &chart.Metadata{Version: a.version}}}}, nil
}
func (a *stubActionWrapper) getValues(release string) (map[string]any, error) {
func (a *stubActionWrapper) getValues(_ string) (map[string]any, error) {
return nil, nil
}
func (a *stubActionWrapper) upgradeAction(ctx context.Context, releaseName string, chart *chart.Chart, values map[string]any, timeout time.Duration) error {
func (a *stubActionWrapper) upgradeAction(_ context.Context, _ string, _ *chart.Chart, _ map[string]any, _ time.Duration) error {
return nil
}

View file

@ -321,7 +321,7 @@ type stubVersionsAPIImageFetcher struct {
fetchImageInfoErr error
}
func (f *stubVersionsAPIImageFetcher) FetchImageInfo(ctx context.Context, imageInfo versionsapi.ImageInfo) (
func (f *stubVersionsAPIImageFetcher) FetchImageInfo(_ context.Context, _ versionsapi.ImageInfo) (
versionsapi.ImageInfo, error,
) {
return f.fetchImageInfoInfo, f.fetchImageInfoErr