From 82ef9e480654a2eddcdc3b084717c12b6ead1bf0 Mon Sep 17 00:00:00 2001 From: Andrew Keesler Date: Tue, 15 Sep 2020 11:00:00 -0400 Subject: [PATCH] cmd/pinniped/cmd: fix some linting errors Signed-off-by: Andrew Keesler --- cmd/pinniped/cmd/get_kubeconfig.go | 12 ++++++------ cmd/pinniped/cmd/get_kubeconfig_test.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/pinniped/cmd/get_kubeconfig.go b/cmd/pinniped/cmd/get_kubeconfig.go index 1c4937ca1..ff9b98adb 100644 --- a/cmd/pinniped/cmd/get_kubeconfig.go +++ b/cmd/pinniped/cmd/get_kubeconfig.go @@ -169,7 +169,7 @@ func getKubeConfig( kubeClientCreator func(restConfig *rest.Config) (pinnipedclientset.Interface, error), ) error { if token == "" { - return fmt.Errorf("--" + getKubeConfigCmdTokenFlagName + " flag value cannot be empty") + return constable.Error("--" + getKubeConfigCmdTokenFlagName + " flag value cannot be empty") } fullPathToSelf, err := os.Executable() @@ -193,7 +193,7 @@ func getKubeConfig( return constable.Error(`CredentialIssuerConfig "pinniped-config" was missing KubeConfigInfo`) } - v1Cluster, err := copyCurrentClusterFromExistingKubeConfig(err, currentKubeConfig, currentContextNameOverride) + v1Cluster, err := copyCurrentClusterFromExistingKubeConfig(currentKubeConfig, currentContextNameOverride) if err != nil { return err } @@ -244,12 +244,12 @@ func fetchPinnipedCredentialIssuerConfig(clientConfig clientcmd.ClientConfig, ku credentialIssuerConfig, err := clientset.CrdV1alpha1().CredentialIssuerConfigs(pinnipedInstallationNamespace).Get(ctx, issuerconfig.ConfigName, metav1.GetOptions{}) if err != nil { if apierrors.IsNotFound(err) { - return nil, fmt.Errorf( + return nil, constable.Error(fmt.Sprintf( `CredentialIssuerConfig "%s" was not found in namespace "%s". Is Pinniped installed on this cluster in namespace "%s"?`, issuerconfig.ConfigName, pinnipedInstallationNamespace, pinnipedInstallationNamespace, - ) + )) } return nil, err } @@ -280,7 +280,7 @@ func writeConfigAsYAML(outputWriter io.Writer, config v1.Config) error { return nil } -func copyCurrentClusterFromExistingKubeConfig(err error, currentKubeConfig clientcmdapi.Config, currentContextNameOverride string) (v1.Cluster, error) { +func copyCurrentClusterFromExistingKubeConfig(currentKubeConfig clientcmdapi.Config, currentContextNameOverride string) (v1.Cluster, error) { v1Cluster := v1.Cluster{} contextName := currentKubeConfig.CurrentContext @@ -288,7 +288,7 @@ func copyCurrentClusterFromExistingKubeConfig(err error, currentKubeConfig clien contextName = currentContextNameOverride } - err = v1.Convert_api_Cluster_To_v1_Cluster( + err := v1.Convert_api_Cluster_To_v1_Cluster( currentKubeConfig.Clusters[currentKubeConfig.Contexts[contextName].Cluster], &v1Cluster, nil, diff --git a/cmd/pinniped/cmd/get_kubeconfig_test.go b/cmd/pinniped/cmd/get_kubeconfig_test.go index e08316cfc..87ad76589 100644 --- a/cmd/pinniped/cmd/get_kubeconfig_test.go +++ b/cmd/pinniped/cmd/get_kubeconfig_test.go @@ -201,6 +201,7 @@ func TestNewGetKubeConfigCmd(t *testing.T) { }, spec.Parallel(), spec.Report(report.Terminal{})) } +//nolint: unparam func expectedKubeconfigYAML(clusterCAData, clusterServer, command, token, pinnipedEndpoint, pinnipedCABundle string) string { return here.Docf(` apiVersion: v1 @@ -636,6 +637,5 @@ func TestGetKubeConfig(t *testing.T) { r.Empty(outputBuffer.String()) }) }) - }, spec.Parallel(), spec.Report(report.Terminal{})) }