Documentation ¶
Overview ¶
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "create <name>", Short: "Create a new default cloud profile in the current workspace", Long: `Create cloud credentials for a cloud provider to be used to provision resources in the current workspace. Currently supported cloud providers: - AWS - Azure - GCP `, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { cloudProfileName := args[0] if cloudProvider == "" { options := make([]string, len(generated.AllCloudProvider)) for i, provider := range generated.AllCloudProvider { options[i] = string(provider) } answer := "" err := survey.AskOne(&survey.Select{ Message: "Select cloud provider", Options: options, }, &answer, survey.WithValidator(survey.Required)) cobra.CheckErr(err) cloudProvider = generated.CloudProvider(answer) } else { found := false for _, provider := range generated.AllCloudProvider { if cloudProvider == provider { found = true break } } if !found { return fmt.Errorf("invalid cloud provider: %s", cloudProvider) } } if cloudProvider == generated.CloudProviderDigitalOcean { return errors.New("Digital Ocean is not supported yet") } _context := ctx.GetContextValue(cmd) _config := _context.Root client := cloud_profile.NewFromConfig(*_context.ServiceClientConfig) whereAccount := generated.AccountWhereUniqueInput{Username: &_config.Workspace.Username} if collision, err := checkCollision(cmd.Context(), *client, whereAccount, cloudProfileName, cloudProvider); err != nil { cobra.CheckErr(err) } else if collision { return errors.New(fmt.Sprintf("%s for %s already exists in the current workspace", cloudProfileName, cloudProvider)) } createInput, err := createCredentialsOnProvider(cmd.Context(), cloudProfileName, cloudProvider) if err != nil { cobra.CheckErr(err) } createInput = setIsDefault(createInput) cloudProfile, err := createCloudProfile(cmd.Context(), *client, whereAccount, createInput) if err != nil { cobra.CheckErr(err) } cmd.Printf("Successfully created cloud profile %s\n", cloudProfile.Name) return nil }, }
Cmd represents the create command
Functions ¶
This section is empty.
Types ¶
type AWSCredentialsCreator ¶
type AWSCredentialsCreator struct {
// contains filtered or unexported fields
}
func NewAWSCredentialsCreator ¶
func NewAWSCredentialsCreator(ctx context.Context) AWSCredentialsCreator
type AzureCredentialsCreator ¶
type AzureCredentialsCreator struct {
// contains filtered or unexported fields
}
func NewAzureCredentialsCreator ¶
func NewAzureCredentialsCreator(ctx context.Context) AzureCredentialsCreator
type CredentialsCreator ¶
type CredentialsCreator interface {
// contains filtered or unexported methods
}
type CredentialsCreatorWrapper ¶
type CredentialsCreatorWrapper struct {
// contains filtered or unexported fields
}
func NewCredentialsCreatorWrapper ¶
func NewCredentialsCreatorWrapper(ctx context.Context, provider generated.CloudProvider) (wrapper CredentialsCreatorWrapper)
type GCPCredentialsCreator ¶
type GCPCredentialsCreator struct {
// contains filtered or unexported fields
}
func NewGCPCredentialsCreator ¶
func NewGCPCredentialsCreator(ctx context.Context) GCPCredentialsCreator
Click to show internal directories.
Click to hide internal directories.