Fix: add terraform aws provider without AWS_SESSION_TOKEN

Fix #3589 and refine prompts for cli

Signed-off-by: Zheng Xi Zhou <zzxwill@gmail.com>
This commit is contained in:
Zheng Xi Zhou
2022-04-06 14:23:04 +08:00
parent aea98ff5bf
commit 904a72857b
2 changed files with 7 additions and 4 deletions
+2 -2
View File
@@ -295,7 +295,7 @@ func generateTerraformTypedComponentDefinition(cmd *cobra.Command, name, kind, p
}
switch provider {
case "aws", "azure", "alibaba", "tencent", "gcp", "baidu", "elastic":
case "aws", "azure", "alibaba", "tencent", "gcp", "baidu", "elastic", "ucloud":
var terraform *commontype.Terraform
git, err := cmd.Flags().GetString(FlagGit)
@@ -371,7 +371,7 @@ func generateTerraformTypedComponentDefinition(cmd *cobra.Command, name, kind, p
}
return out.String(), nil
default:
return "", errors.Errorf("Provider `%s` is not supported. Only `alibaba`, `aws`, `azure` are supported.", provider)
return "", errors.Errorf("Provider `%s` is not supported. Only `alibaba`, `aws`, `azure`, `gcp`, `baidu`, `tencent`, `elastic`, `ucloud` are supported.", provider)
}
}
+5 -2
View File
@@ -188,7 +188,7 @@ func prepareProviderAddSubCommand(c common.Args) ([]*cobra.Command, error) {
if err != nil {
return err
}
if value == "" {
if value == "" && p.Required {
return fmt.Errorf("must specify a value for %s", p.Name)
}
properties[p.Name] = value
@@ -219,9 +219,12 @@ func prepareProviderAddSubCommand(c common.Args) ([]*cobra.Command, error) {
},
}
if err := k8sClient.Create(ctx, a); err != nil {
return err
return fmt.Errorf("failed to authentiate Terraform cloud provier %s", providerType)
}
fmt.Printf("Successfully authentiate provider %s for %s\n", name, providerType)
return nil
}
return fmt.Errorf("failed to authentiate Terraform cloud provier %s", providerType)
}
return fmt.Errorf("terraform provider %s for %s already exists", name, providerType)
}