cmd/pinniped/cmd: fix some linting errors
Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
parent
879d847ffb
commit
82ef9e4806
@ -169,7 +169,7 @@ func getKubeConfig(
|
|||||||
kubeClientCreator func(restConfig *rest.Config) (pinnipedclientset.Interface, error),
|
kubeClientCreator func(restConfig *rest.Config) (pinnipedclientset.Interface, error),
|
||||||
) error {
|
) error {
|
||||||
if token == "" {
|
if token == "" {
|
||||||
return fmt.Errorf("--" + getKubeConfigCmdTokenFlagName + " flag value cannot be empty")
|
return constable.Error("--" + getKubeConfigCmdTokenFlagName + " flag value cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
fullPathToSelf, err := os.Executable()
|
fullPathToSelf, err := os.Executable()
|
||||||
@ -193,7 +193,7 @@ func getKubeConfig(
|
|||||||
return constable.Error(`CredentialIssuerConfig "pinniped-config" was missing KubeConfigInfo`)
|
return constable.Error(`CredentialIssuerConfig "pinniped-config" was missing KubeConfigInfo`)
|
||||||
}
|
}
|
||||||
|
|
||||||
v1Cluster, err := copyCurrentClusterFromExistingKubeConfig(err, currentKubeConfig, currentContextNameOverride)
|
v1Cluster, err := copyCurrentClusterFromExistingKubeConfig(currentKubeConfig, currentContextNameOverride)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -244,12 +244,12 @@ func fetchPinnipedCredentialIssuerConfig(clientConfig clientcmd.ClientConfig, ku
|
|||||||
credentialIssuerConfig, err := clientset.CrdV1alpha1().CredentialIssuerConfigs(pinnipedInstallationNamespace).Get(ctx, issuerconfig.ConfigName, metav1.GetOptions{})
|
credentialIssuerConfig, err := clientset.CrdV1alpha1().CredentialIssuerConfigs(pinnipedInstallationNamespace).Get(ctx, issuerconfig.ConfigName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if apierrors.IsNotFound(err) {
|
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"?`,
|
`CredentialIssuerConfig "%s" was not found in namespace "%s". Is Pinniped installed on this cluster in namespace "%s"?`,
|
||||||
issuerconfig.ConfigName,
|
issuerconfig.ConfigName,
|
||||||
pinnipedInstallationNamespace,
|
pinnipedInstallationNamespace,
|
||||||
pinnipedInstallationNamespace,
|
pinnipedInstallationNamespace,
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ func writeConfigAsYAML(outputWriter io.Writer, config v1.Config) error {
|
|||||||
return nil
|
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{}
|
v1Cluster := v1.Cluster{}
|
||||||
|
|
||||||
contextName := currentKubeConfig.CurrentContext
|
contextName := currentKubeConfig.CurrentContext
|
||||||
@ -288,7 +288,7 @@ func copyCurrentClusterFromExistingKubeConfig(err error, currentKubeConfig clien
|
|||||||
contextName = currentContextNameOverride
|
contextName = currentContextNameOverride
|
||||||
}
|
}
|
||||||
|
|
||||||
err = v1.Convert_api_Cluster_To_v1_Cluster(
|
err := v1.Convert_api_Cluster_To_v1_Cluster(
|
||||||
currentKubeConfig.Clusters[currentKubeConfig.Contexts[contextName].Cluster],
|
currentKubeConfig.Clusters[currentKubeConfig.Contexts[contextName].Cluster],
|
||||||
&v1Cluster,
|
&v1Cluster,
|
||||||
nil,
|
nil,
|
||||||
|
@ -201,6 +201,7 @@ func TestNewGetKubeConfigCmd(t *testing.T) {
|
|||||||
}, spec.Parallel(), spec.Report(report.Terminal{}))
|
}, spec.Parallel(), spec.Report(report.Terminal{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint: unparam
|
||||||
func expectedKubeconfigYAML(clusterCAData, clusterServer, command, token, pinnipedEndpoint, pinnipedCABundle string) string {
|
func expectedKubeconfigYAML(clusterCAData, clusterServer, command, token, pinnipedEndpoint, pinnipedCABundle string) string {
|
||||||
return here.Docf(`
|
return here.Docf(`
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@ -636,6 +637,5 @@ func TestGetKubeConfig(t *testing.T) {
|
|||||||
r.Empty(outputBuffer.String())
|
r.Empty(outputBuffer.String())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
}, spec.Parallel(), spec.Report(report.Terminal{}))
|
}, spec.Parallel(), spec.Report(report.Terminal{}))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user