From ed400d6ef162869d8c6ed1a13c6badd8517bcb9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jess=C3=A9=20Moraes=20Braga?= Date: Wed, 25 Jan 2023 15:57:19 +0100 Subject: [PATCH] #4: Argument --client-name shown as -- in error message - also fixes a typo in cce.go --- src/argument_verifier.go | 34 +++++++++++++++++----------------- src/cce/cce.go | 2 +- src/main.go | 3 ++- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/argument_verifier.go b/src/argument_verifier.go index 4e1b68f6..cc5066f6 100644 --- a/src/argument_verifier.go +++ b/src/argument_verifier.go @@ -7,22 +7,22 @@ import ( ) const ( - envOsUsername string = "OS_USERNAME" - envOsPassword string = "OS_PASSWORD" - envOsDomainName string = "OS_DOMAIN_NAME" - envOsUserDomainId string = "OS_USER_DOMAIN_ID" - envOsProjectName string = "OS_PROJECT_NAME" - envIdpName string = "IDP_NAME" - envIdpUrl string = "IDP_URL" - envClientId string = "CLIENT_ID" - envClientSecret string = "CLIENT_SECRET" - envClusterName string = "CLUSTER_NAME" - - authTypeIDP string = "idp" - authTypeIAM string = "iam" - - protocolSAML string = "saml" - protocolOIDC string = "oidc" + envOsUsername = "OS_USERNAME" + envOsPassword = "OS_PASSWORD" + envOsDomainName = "OS_DOMAIN_NAME" + envOsUserDomainId = "OS_USER_DOMAIN_ID" + envOsProjectName = "OS_PROJECT_NAME" + envIdpName = "IDP_NAME" + envIdpUrl = "IDP_URL" + envClientId = "CLIENT_ID" + envClientSecret = "CLIENT_SECRET" + envClusterName = "CLUSTER_NAME" + + authTypeIDP = "idp" + authTypeIAM = "iam" + + protocolSAML = "saml" + protocolOIDC = "oidc" ) func getProjectNameOrThrow(projectName string) string { @@ -38,7 +38,7 @@ func getClusterNameOrThrow(clusterName string) string { return clusterName } - return getEnvironmentVariableOrThrow(clusterName, envClusterName) + return getEnvironmentVariableOrThrow(clusterArg, envClusterName) } func getIdpInfoOrThrow(provider string, url string) (string, string) { diff --git a/src/cce/cce.go b/src/cce/cce.go index a4b5fb50..5a379de8 100644 --- a/src/cce/cce.go +++ b/src/cce/cce.go @@ -137,7 +137,7 @@ func getClusterId(clusterName string, projectName string) (clusterId string, err Id: cluster.Metadata.UID, }) } - println(fmt.Sprintf("Clustes for project %s:\n%s", projectName, strings.Join(clusters.GetClusterNames(), ",\n"))) + println(fmt.Sprintf("Clusters for project %s:\n%s", projectName, strings.Join(clusters.GetClusterNames(), ",\n"))) config.UpdateClusters(clusters) cloud = config.GetActiveCloudConfig() diff --git a/src/main.go b/src/main.go index 29b27e8c..d33944dd 100644 --- a/src/main.go +++ b/src/main.go @@ -28,6 +28,7 @@ const ( idpUrlArg = "idp-url" clientIdArg = "client-id" clientSecretArg = "client-secret" + clusterArg = "cluster" ) func main() { @@ -91,7 +92,7 @@ func main() { // Get Kubernetes Configuration getKubeConfigCommand := cceCommand.NewCommand("get-kube-config", "Get remote kube config and merge it with existing local config file.") - clusterName := getKubeConfigCommand.String("c", "cluster", &argparse.Options{Required: false, Help: fmt.Sprintf("Name of the cluster you want to access %s %s.", provideArgumentHelp, envClusterName)}) + clusterName := getKubeConfigCommand.String("c", clusterArg, &argparse.Options{Required: false, Help: fmt.Sprintf("Name of the clusterArg you want to access %s %s.", provideArgumentHelp, envClusterName)}) daysValid := getKubeConfigCommand.String("v", "days-valid", &argparse.Options{Required: false, Help: "Period (in days) that the config will be valid", Default: "7"}) // AK/SK Management