Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: commandName, Long: fmt.Sprintf(`The '%s' command is used to deploy a service to ECS, or perform different type of actions on top of it.`, commandName), Example: cliutils.GenerateExampleInCMD([]cliutils.ExampleTemplateOptions{ { CLIName: "golang-cli-boilerplate", Command: commandName, Options: "--aws-region=us-east-1 --output=yaml --save", Explanation: `This command will list all the ECS clusters in the us-east-1 region, and it'll save the output in a file called ecs-clusters.yaml.`, }, }), Run: func(cmd *cobra.Command, args []string) { client := GetClient(cmd) client.UX.Titles.ShowTitle(viper.GetString("CLI_NAME_TITLE")) client.UX.Messages.ShowInfo(tui.MessageOptions{ Message: "CLI successfully started. Configuration loaded successfully.", }) awsAccessKeyPassed := viper.GetString("awsAccessKeyId") awsSecretKeyPassed := viper.GetString("awsSecretAccessKey") awsRegionPassed := viper.GetString("awsRegion") aws, err := cloudaws.NewClient(client.Ctx, client.Logger, cloudaws.InitAWSAdapterOptions{ Region: awsRegionPassed, Creds: cloudaws.AWSCreds{ AccessKeyID: awsAccessKeyPassed, SecretAccessKey: awsSecretKeyPassed, }, }) if err != nil { client.UX.Messages.ShowError(tui.MessageOptions{ Message: err.Error(), }) os.Exit(1) } adapter, err := aws.Build(aws.WithECS()) if err != nil { client.UX.Messages.ShowError(tui.MessageOptions{ Message: err.Error(), }) os.Exit(1) } ecsConnector := cloudaws.NewECSConnector(client.Ctx, adapter.ECSClient, client.Logger) result, _ := ecsConnector.ListECSClusters() option := viper.GetString("output") save := viper.GetBool("save") clusters := struct { ClusterArns []string `json:"clusterArns" yaml:"clusterArns"` }{} clusters.ClusterArns = append(clusters.ClusterArns, result.ClusterArns...) out := output.NewTerminalOutput(client.UX.Messages, client.Logger) var data [][]string for i, cluster := range result.ClusterArns { data = append(data, []string{strconv.Itoa(i), cluster}) } if err := out.Show(output.Options{ Data: data, OutputType: option, SaveInDisk: save, Filename: "ecs-clusters", TableHeaders: []string{"#", "CLUSTER"}, }); err != nil { client.UX.Messages.ShowError(tui.MessageOptions{ Message: err.Error(), }) os.Exit(1) } }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.