Documentation ¶
Overview ¶
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Copyright © 2023 Threeport admin@threeport.io
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ConfigAwsCloudAccountCmd = &cobra.Command{ Use: "aws-account", Example: "tptctl config aws-account --aws-account-name my-account --aws-region us-east-1 --aws-profile my-profile --aws-account-id 123456789012", Short: "Configure an aws account", Long: `Configure AWS account permissions. This creates an account in the Threeport API and the configures the respective customer-managed AWS account.`, SilenceUsage: true, PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsConf, err := aws_config.LoadAWSConfig( false, awsProfile, providerRegion, "", "", "", ) if err != nil { cli.Error("failed to load AWS configuration with local config", err) os.Exit(1) } svcSts := sts.NewFromConfig(*awsConf) callerIdentity, err := svcSts.GetCallerIdentity( context.Background(), &sts.GetCallerIdentityInput{}, ) if err != nil { cli.Error("failed to get caller identity", err) os.Exit(1) } if roleName == "" { roleName = provider.GetResourceManagerRoleName(requestedControlPlane) } // ensure role doesn't exist var nse types.NoSuchEntityException var existingRole *iam.GetRoleOutput svcIam := iam.NewFromConfig(*awsConf) if existingRole, err = svcIam.GetRole( context.Background(), &iam.GetRoleInput{ RoleName: &roleName, }, ); err != nil && !provider.IsException(&err, nse.ErrorCode()) { cli.Error("failed to get role", err) os.Exit(1) } if err == nil { cli.Error("role already exists: ", fmt.Errorf("%s", *existingRole.Role.Arn)) os.Exit(1) } awsAccount := v0.AwsAccount{ Name: ptr.String(awsAccountName), AccountID: callerIdentity.Account, DefaultAccount: ptr.Bool(defaultAccount), DefaultRegion: ptr.String(awsRegion), } createdAwsAccount, err := client.CreateAwsAccount(apiClient, apiEndpoint, &awsAccount) if err != nil { cli.Error("failed to create aws account", err) os.Exit(1) } if externalRoleName == "" { externalRoleName = provider.GetResourceManagerRoleName(requestedControlPlane) } role, err := provider.CreateResourceManagerRole( builder_iam.CreateIamTags( requestedControlPlane, map[string]string{}, ), roleName, *callerIdentity.Account, awsAccountId, externalRoleName, *createdAwsAccount.ExternalId, true, true, *awsConf, ) if err != nil { cli.Error("failed to create role", err) _, err = client.DeleteAwsAccount(apiClient, apiEndpoint, *createdAwsAccount.ID) if err != nil { cli.Error("failed to delete aws account", err) } os.Exit(1) } createdAwsAccount.RoleArn = role.Arn _, err = client.UpdateAwsAccount(apiClient, apiEndpoint, createdAwsAccount) if err != nil { cli.Error("failed to update aws account", err) _, err = client.DeleteAwsAccount(apiClient, apiEndpoint, *createdAwsAccount.ID) if err != nil { cli.Error("failed to delete aws account", err) } err = provider.DeleteResourceManagerRole(roleName, *awsConf) if err != nil { cli.Error("failed to delete threeport role", err) } os.Exit(1) } cli.Complete(fmt.Sprintf("Configured AWS account with runtime manager role: %s", *role.Arn)) }, }
ConfigCurrentInstanceCmd represents the current-instance command
var ConfigCmd = &cobra.Command{
Use: "config",
Short: "Manage your local Threeport config",
Long: `Manage your local Threeport config.
The tptctl command line tool uses a Threeport config file to store connection and
configuration information for one or more installations of Threeport. By default
the file lives at ~/.config/threeport/config.yaml on your filesystem. You can edit
this config file manually if you like, but we recommend you use the config command
to do so where possible.
The config command does nothing by itself. Use one of the avilable subcommands
to manage your Threeport config.`,
}
ConfigCmd represents the config command
var ConfigCurrentControlPlaneCmd = &cobra.Command{ Use: "current-control-plane", Example: "tptctl config current-control-plane --control-plane-name testport", Short: "Set a threeport control plane as the current in-use control plane", Long: `Set a threeport control plane as the current in-use control plane. Once set as the current control plane all subsequent tptctl commands will apply to that Threeport control plane.`, SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { threeportConfig, _, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config", err) os.Exit(1) } // We try to find the current control plane in the current config // If found we set and return var genesisControlPlane *config.ControlPlane var anyControlPlane *config.ControlPlane var currentControlPlane *config.ControlPlane for _, controlPlane := range threeportConfig.ControlPlanes { if controlPlane.Name == configCurrentControlPlaneName { threeportConfig.SetCurrentControlPlane(configCurrentControlPlaneName) cli.Info("Control plane found in config") cli.Complete(fmt.Sprintf("Threeport control plane %s set as the current control plane", configCurrentControlPlaneName)) return } if controlPlane.Genesis { genesisControlPlane = &controlPlane } if controlPlane.Name == threeportConfig.CurrentControlPlane { currentControlPlane = &controlPlane } anyControlPlane = &controlPlane } cli.Info("Control plane not found in config") apiClient, err := threeportConfig.GetHTTPClient(currentControlPlane.Name) if err != nil { cli.Error("failed to get threeport API client", err) os.Exit(1) } var controlPlaneInstanceToSet *v0.ControlPlaneInstance if currentControlPlane != nil { cli.Info("Checking if child of current control plane") apiEndpoint, err := threeportConfig.GetThreeportAPIEndpoint(currentControlPlane.Name) if err != nil { cli.Error("failed to get threeport API endpoint from config", err) os.Exit(1) } controlPlaneInstance, err := client.GetControlPlaneInstanceByName(apiClient, apiEndpoint, currentControlPlane.Name) if err != nil { cli.Error("failed to retrieve current control plane instance", err) os.Exit(1) } for _, controlPlane := range *controlPlaneInstance.Children { if *controlPlane.Name == configCurrentControlPlaneName { controlPlaneInstanceToSet = &controlPlane cli.Info("found requested control plane in children of current control plane") updateThreeportConfigWithControlPlaneInstance(apiClient, apiEndpoint, controlPlaneInstanceToSet, threeportConfig) cli.Complete(fmt.Sprintf("Threeport control plane %s set as the current control plane", configCurrentControlPlaneName)) return } } } else { cli.Warning("Current control plane not found, cannot search children for requested control plane instance.") } cli.Info("Checking to see genesis control plane info for info exists") if genesisControlPlane != nil { cli.Warning(fmt.Sprintf("could not find requested control plane. Try setting current control to the genesis control plane for this instance: %s and traversing the topology of your control planes", genesisControlPlane.Name)) os.Exit(1) } if anyControlPlane == nil { cli.Warning("could not find any control plane in the requested config. Please add atleast one control plane from the group") os.Exit(1) } apiEndpoint, err := threeportConfig.GetThreeportAPIEndpoint(anyControlPlane.Name) if err != nil { cli.Error("failed to get threeport API endpoint from config", err) os.Exit(1) } controlPlaneInstanceToSet, err = client.GetGenesisControlPlaneInstance(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve genesis control plane instance", err) os.Exit(1) } updateThreeportConfigWithControlPlaneInstance(apiClient, apiEndpoint, controlPlaneInstanceToSet, threeportConfig) cli.Warning(fmt.Sprintf("could not find requested control plane info. Current control plane set to the genesis control plane for this instance: %s. Try traversing the topology of your control planes", genesisControlPlane.Name)) os.Exit(1) }, }
ConfigCurrentControlPlaneCmd represents the current-instance command
var ConfigGetControlPlanesCmd = &cobra.Command{ Use: "get-control-planes", Example: "tptctl config get-control-planes", Short: "Get a list of threeport control planes in your threeport config", Long: `Get a list of threeport control planes in your threeport config.`, SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { threeportConfig, _, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config", err) os.Exit(1) } if threeportConfig.CurrentControlPlane == "" { cli.Warning("current control plane is not set - set it with 'tptctl config current-control-plane --control-plane-name <control-plane-name>'") } writer := tabwriter.NewWriter(os.Stdout, 4, 4, 4, ' ', 0) fmt.Fprintln(writer, "NAME\t PROVIDER\t CURRENT CONTROL PLANE") for _, controlPlane := range threeportConfig.ControlPlanes { currentInst := false if controlPlane.Name == threeportConfig.CurrentControlPlane { currentInst = true } fmt.Fprintln(writer, controlPlane.Name, "\t", controlPlane.Provider, "\t", currentInst) } writer.Flush() }, }
ConfigGetControlPlanesCmd represents the get-instances command
var CreateAwsAccountCmd = &cobra.Command{ Example: " tptctl create aws-account --config path/to/config.yaml", Long: "Create a new aws account.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsAccountConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsAccountConfig config.AwsAccountConfig if err := yaml.UnmarshalStrict(configContent, &awsAccountConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsAccount := awsAccountConfig.AwsAccount createdAwsAccount, err := awsAccount.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create aws account", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws account %s created", *createdAwsAccount.Name)) }, Short: "Create a new aws account", SilenceUsage: true, Use: "aws-account", }
CreateAwsAccountCmd represents the aws-account command
var CreateAwsEksKubernetesRuntimeCmd = &cobra.Command{ Example: " tptctl create aws-eks-kubernetes-runtime --config path/to/config.yaml", Long: "Create a new aws eks kubernetes runtime. This command creates a new aws eks kubernetes runtime definition and aws eks kubernetes runtime instance based on the aws eks kubernetes runtime config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsEksKubernetesRuntimeConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsEksKubernetesRuntimeConfig config.AwsEksKubernetesRuntimeConfig if err := yaml.UnmarshalStrict(configContent, &awsEksKubernetesRuntimeConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsEksKubernetesRuntime := awsEksKubernetesRuntimeConfig.AwsEksKubernetesRuntime createdAwsEksKubernetesRuntimeDefinition, createdAwsEksKubernetesRuntimeInstance, err := awsEksKubernetesRuntime.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create aws eks kubernetes runtime", err) os.Exit(1) } cli.Info(fmt.Sprintf("aws eks kubernetes runtime definition %s created", *createdAwsEksKubernetesRuntimeDefinition.Name)) cli.Info(fmt.Sprintf("aws eks kubernetes runtime instance %s created", *createdAwsEksKubernetesRuntimeInstance.Name)) cli.Complete(fmt.Sprintf("aws eks kubernetes runtime %s created", awsEksKubernetesRuntimeConfig.AwsEksKubernetesRuntime.Name)) }, Short: "Create a new aws eks kubernetes runtime", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime", }
CreateAwsEksKubernetesRuntimeCmd represents the aws-eks-kubernetes-runtime command
var CreateAwsEksKubernetesRuntimeDefinitionCmd = &cobra.Command{ Example: " tptctl create aws-eks-kubernetes-runtime-definition --config path/to/config.yaml", Long: "Create a new aws eks kubernetes runtime definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsEksKubernetesRuntimeDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsEksKubernetesRuntimeDefinitionConfig config.AwsEksKubernetesRuntimeDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &awsEksKubernetesRuntimeDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsEksKubernetesRuntimeDefinition := awsEksKubernetesRuntimeDefinitionConfig.AwsEksKubernetesRuntimeDefinition createdAwsEksKubernetesRuntimeDefinition, err := awsEksKubernetesRuntimeDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create aws eks kubernetes runtime definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws eks kubernetes runtime definition %s created", *createdAwsEksKubernetesRuntimeDefinition.Name)) }, Short: "Create a new aws eks kubernetes runtime definition", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime-definition", }
CreateAwsEksKubernetesRuntimeDefinitionCmd represents the aws-eks-kubernetes-runtime-definition command
var CreateAwsEksKubernetesRuntimeInstanceCmd = &cobra.Command{ Example: " tptctl create aws-eks-kubernetes-runtime-instance --config path/to/config.yaml", Long: "Create a new aws eks kubernetes runtime instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsEksKubernetesRuntimeInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsEksKubernetesRuntimeInstanceConfig config.AwsEksKubernetesRuntimeInstanceConfig if err := yaml.UnmarshalStrict(configContent, &awsEksKubernetesRuntimeInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsEksKubernetesRuntimeInstance := awsEksKubernetesRuntimeInstanceConfig.AwsEksKubernetesRuntimeInstance createdAwsEksKubernetesRuntimeInstance, err := awsEksKubernetesRuntimeInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create aws eks kubernetes runtime instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws eks kubernetes runtime instance %s created", *createdAwsEksKubernetesRuntimeInstance.Name)) }, Short: "Create a new aws eks kubernetes runtime instance", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime-instance", }
CreateAwsEksKubernetesRuntimeInstanceCmd represents the aws-eks-kubernetes-runtime-instance command
var CreateAwsObjectStorageBucketCmd = &cobra.Command{ Example: " tptctl create aws-object-storage-bucket --config path/to/config.yaml", Long: "Create a new aws object storage bucket. This command creates a new aws object storage bucket definition and aws object storage bucket instance based on the aws object storage bucket config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsObjectStorageBucketConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsObjectStorageBucketConfig config.AwsObjectStorageBucketConfig if err := yaml.UnmarshalStrict(configContent, &awsObjectStorageBucketConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsObjectStorageBucket := awsObjectStorageBucketConfig.AwsObjectStorageBucket createdAwsObjectStorageBucketDefinition, createdAwsObjectStorageBucketInstance, err := awsObjectStorageBucket.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create aws object storage bucket", err) os.Exit(1) } cli.Info(fmt.Sprintf("aws object storage bucket definition %s created", *createdAwsObjectStorageBucketDefinition.Name)) cli.Info(fmt.Sprintf("aws object storage bucket instance %s created", *createdAwsObjectStorageBucketInstance.Name)) cli.Complete(fmt.Sprintf("aws object storage bucket %s created", awsObjectStorageBucketConfig.AwsObjectStorageBucket.Name)) }, Short: "Create a new aws object storage bucket", SilenceUsage: true, Use: "aws-object-storage-bucket", }
CreateAwsObjectStorageBucketCmd represents the aws-object-storage-bucket command
var CreateAwsObjectStorageBucketDefinitionCmd = &cobra.Command{ Example: " tptctl create aws-object-storage-bucket-definition --config path/to/config.yaml", Long: "Create a new aws object storage bucket definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsObjectStorageBucketDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsObjectStorageBucketDefinitionConfig config.AwsObjectStorageBucketDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &awsObjectStorageBucketDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsObjectStorageBucketDefinition := awsObjectStorageBucketDefinitionConfig.AwsObjectStorageBucketDefinition createdAwsObjectStorageBucketDefinition, err := awsObjectStorageBucketDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create aws object storage bucket definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws object storage bucket definition %s created", *createdAwsObjectStorageBucketDefinition.Name)) }, Short: "Create a new aws object storage bucket definition", SilenceUsage: true, Use: "aws-object-storage-bucket-definition", }
CreateAwsObjectStorageBucketDefinitionCmd represents the aws-object-storage-bucket-definition command
var CreateAwsObjectStorageBucketInstanceCmd = &cobra.Command{ Example: " tptctl create aws-object-storage-bucket-instance --config path/to/config.yaml", Long: "Create a new aws object storage bucket instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsObjectStorageBucketInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsObjectStorageBucketInstanceConfig config.AwsObjectStorageBucketInstanceConfig if err := yaml.UnmarshalStrict(configContent, &awsObjectStorageBucketInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsObjectStorageBucketInstance := awsObjectStorageBucketInstanceConfig.AwsObjectStorageBucketInstance createdAwsObjectStorageBucketInstance, err := awsObjectStorageBucketInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create aws object storage bucket instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws object storage bucket instance %s created", *createdAwsObjectStorageBucketInstance.Name)) }, Short: "Create a new aws object storage bucket instance", SilenceUsage: true, Use: "aws-object-storage-bucket-instance", }
CreateAwsObjectStorageBucketInstanceCmd represents the aws-object-storage-bucket-instance command
var CreateAwsRelationalDatabaseCmd = &cobra.Command{ Example: " tptctl create aws-relational-database --config path/to/config.yaml", Long: "Create a new aws relational database. This command creates a new aws relational database definition and aws relational database instance based on the aws relational database config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsRelationalDatabaseConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsRelationalDatabaseConfig config.AwsRelationalDatabaseConfig if err := yaml.UnmarshalStrict(configContent, &awsRelationalDatabaseConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsRelationalDatabase := awsRelationalDatabaseConfig.AwsRelationalDatabase createdAwsRelationalDatabaseDefinition, createdAwsRelationalDatabaseInstance, err := awsRelationalDatabase.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create aws relational database", err) os.Exit(1) } cli.Info(fmt.Sprintf("aws relational database definition %s created", *createdAwsRelationalDatabaseDefinition.Name)) cli.Info(fmt.Sprintf("aws relational database instance %s created", *createdAwsRelationalDatabaseInstance.Name)) cli.Complete(fmt.Sprintf("aws relational database %s created", awsRelationalDatabaseConfig.AwsRelationalDatabase.Name)) }, Short: "Create a new aws relational database", SilenceUsage: true, Use: "aws-relational-database", }
CreateAwsRelationalDatabaseCmd represents the aws-relational-database command
var CreateAwsRelationalDatabaseDefinitionCmd = &cobra.Command{ Example: " tptctl create aws-relational-database-definition --config path/to/config.yaml", Long: "Create a new aws relational database definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsRelationalDatabaseDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsRelationalDatabaseDefinitionConfig config.AwsRelationalDatabaseDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &awsRelationalDatabaseDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsRelationalDatabaseDefinition := awsRelationalDatabaseDefinitionConfig.AwsRelationalDatabaseDefinition createdAwsRelationalDatabaseDefinition, err := awsRelationalDatabaseDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create aws relational database definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws relational database definition %s created", *createdAwsRelationalDatabaseDefinition.Name)) }, Short: "Create a new aws relational database definition", SilenceUsage: true, Use: "aws-relational-database-definition", }
CreateAwsRelationalDatabaseDefinitionCmd represents the aws-relational-database-definition command
var CreateAwsRelationalDatabaseInstanceCmd = &cobra.Command{ Example: " tptctl create aws-relational-database-instance --config path/to/config.yaml", Long: "Create a new aws relational database instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createAwsRelationalDatabaseInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var awsRelationalDatabaseInstanceConfig config.AwsRelationalDatabaseInstanceConfig if err := yaml.UnmarshalStrict(configContent, &awsRelationalDatabaseInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsRelationalDatabaseInstance := awsRelationalDatabaseInstanceConfig.AwsRelationalDatabaseInstance createdAwsRelationalDatabaseInstance, err := awsRelationalDatabaseInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create aws relational database instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws relational database instance %s created", *createdAwsRelationalDatabaseInstance.Name)) }, Short: "Create a new aws relational database instance", SilenceUsage: true, Use: "aws-relational-database-instance", }
CreateAwsRelationalDatabaseInstanceCmd represents the aws-relational-database-instance command
var CreateCmd = &cobra.Command{
Use: "create",
Short: "Create Threeport objects",
Long: `Create Threeport objects.
The create command does nothing by itself. Use one of the avilable subcommands
to create different objects in the system.`,
}
CreateCmd represents the create command
var CreateControlPlaneCmd = &cobra.Command{ Example: " tptctl create control-plane --config path/to/config.yaml", Long: "Create a new control plane. This command creates a new control plane definition and control plane instance based on the control plane config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createControlPlaneConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var controlPlaneConfig config.ControlPlaneConfig if err := yaml.UnmarshalStrict(configContent, &controlPlaneConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } controlPlane := controlPlaneConfig.ControlPlane createdControlPlaneDefinition, createdControlPlaneInstance, err := controlPlane.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create control plane", err) os.Exit(1) } cli.Info(fmt.Sprintf("control plane definition %s created", *createdControlPlaneDefinition.Name)) cli.Info(fmt.Sprintf("control plane instance %s created", *createdControlPlaneInstance.Name)) cli.Complete(fmt.Sprintf("control plane %s created", controlPlaneConfig.ControlPlane.Name)) }, Short: "Create a new control plane", SilenceUsage: true, Use: "control-plane", }
CreateControlPlaneCmd represents the control-plane command
var CreateControlPlaneDefinitionCmd = &cobra.Command{ Example: " tptctl create control-plane-definition --config path/to/config.yaml", Long: "Create a new control plane definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createControlPlaneDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var controlPlaneDefinitionConfig config.ControlPlaneDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &controlPlaneDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } controlPlaneDefinition := controlPlaneDefinitionConfig.ControlPlaneDefinition createdControlPlaneDefinition, err := controlPlaneDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create control plane definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("control plane definition %s created", *createdControlPlaneDefinition.Name)) }, Short: "Create a new control plane definition", SilenceUsage: true, Use: "control-plane-definition", }
CreateControlPlaneDefinitionCmd represents the control-plane-definition command
var CreateControlPlaneInstanceCmd = &cobra.Command{ Example: " tptctl create control-plane-instance --config path/to/config.yaml", Long: "Create a new control plane instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createControlPlaneInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var controlPlaneInstanceConfig config.ControlPlaneInstanceConfig if err := yaml.UnmarshalStrict(configContent, &controlPlaneInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } controlPlaneInstance := controlPlaneInstanceConfig.ControlPlaneInstance createdControlPlaneInstance, err := controlPlaneInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create control plane instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("control plane instance %s created", *createdControlPlaneInstance.Name)) }, Short: "Create a new control plane instance", SilenceUsage: true, Use: "control-plane-instance", }
CreateControlPlaneInstanceCmd represents the control-plane-instance command
var CreateDomainNameCmd = &cobra.Command{ Example: " tptctl create domain-name --config path/to/config.yaml", Long: "Create a new domain name. This command creates a new domain name definition and domain name instance based on the domain name config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createDomainNameConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var domainNameConfig config.DomainNameConfig if err := yaml.UnmarshalStrict(configContent, &domainNameConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } domainName := domainNameConfig.DomainName createdDomainNameDefinition, createdDomainNameInstance, err := domainName.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create domain name", err) os.Exit(1) } cli.Info(fmt.Sprintf("domain name definition %s created", *createdDomainNameDefinition.Name)) cli.Info(fmt.Sprintf("domain name instance %s created", *createdDomainNameInstance.Name)) cli.Complete(fmt.Sprintf("domain name %s created", domainNameConfig.DomainName.Name)) }, Short: "Create a new domain name", SilenceUsage: true, Use: "domain-name", }
CreateDomainNameCmd represents the domain-name command
var CreateDomainNameDefinitionCmd = &cobra.Command{ Example: " tptctl create domain-name-definition --config path/to/config.yaml", Long: "Create a new domain name definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createDomainNameDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var domainNameDefinitionConfig config.DomainNameDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &domainNameDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } domainNameDefinition := domainNameDefinitionConfig.DomainNameDefinition createdDomainNameDefinition, err := domainNameDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create domain name definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("domain name definition %s created", *createdDomainNameDefinition.Name)) }, Short: "Create a new domain name definition", SilenceUsage: true, Use: "domain-name-definition", }
CreateDomainNameDefinitionCmd represents the domain-name-definition command
var CreateDomainNameInstanceCmd = &cobra.Command{ Example: " tptctl create domain-name-instance --config path/to/config.yaml", Long: "Create a new domain name instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createDomainNameInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var domainNameInstanceConfig config.DomainNameInstanceConfig if err := yaml.UnmarshalStrict(configContent, &domainNameInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } domainNameInstance := domainNameInstanceConfig.DomainNameInstance createdDomainNameInstance, err := domainNameInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create domain name instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("domain name instance %s created", *createdDomainNameInstance.Name)) }, Short: "Create a new domain name instance", SilenceUsage: true, Use: "domain-name-instance", }
CreateDomainNameInstanceCmd represents the domain-name-instance command
var CreateGatewayCmd = &cobra.Command{ Example: " tptctl create gateway --config path/to/config.yaml", Long: "Create a new gateway. This command creates a new gateway definition and gateway instance based on the gateway config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createGatewayConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var gatewayConfig config.GatewayConfig if err := yaml.UnmarshalStrict(configContent, &gatewayConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } gateway := gatewayConfig.Gateway createdGatewayDefinition, createdGatewayInstance, err := gateway.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create gateway", err) os.Exit(1) } cli.Info(fmt.Sprintf("gateway definition %s created", *createdGatewayDefinition.Name)) cli.Info(fmt.Sprintf("gateway instance %s created", *createdGatewayInstance.Name)) cli.Complete(fmt.Sprintf("gateway %s created", gatewayConfig.Gateway.Name)) }, Short: "Create a new gateway", SilenceUsage: true, Use: "gateway", }
CreateGatewayCmd represents the gateway command
var CreateGatewayDefinitionCmd = &cobra.Command{ Example: " tptctl create gateway-definition --config path/to/config.yaml", Long: "Create a new gateway definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createGatewayDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var gatewayDefinitionConfig config.GatewayDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &gatewayDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } gatewayDefinition := gatewayDefinitionConfig.GatewayDefinition createdGatewayDefinition, err := gatewayDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create gateway definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("gateway definition %s created", *createdGatewayDefinition.Name)) }, Short: "Create a new gateway definition", SilenceUsage: true, Use: "gateway-definition", }
CreateGatewayDefinitionCmd represents the gateway-definition command
var CreateGatewayInstanceCmd = &cobra.Command{ Example: " tptctl create gateway-instance --config path/to/config.yaml", Long: "Create a new gateway instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createGatewayInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var gatewayInstanceConfig config.GatewayInstanceConfig if err := yaml.UnmarshalStrict(configContent, &gatewayInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } gatewayInstance := gatewayInstanceConfig.GatewayInstance createdGatewayInstance, err := gatewayInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create gateway instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("gateway instance %s created", *createdGatewayInstance.Name)) }, Short: "Create a new gateway instance", SilenceUsage: true, Use: "gateway-instance", }
CreateGatewayInstanceCmd represents the gateway-instance command
var CreateHelmWorkloadCmd = &cobra.Command{ Example: " tptctl create helm-workload --config path/to/config.yaml", Long: "Create a new helm workload. This command creates a new helm workload definition and helm workload instance based on the helm workload config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createHelmWorkloadConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var helmWorkloadConfig config.HelmWorkloadConfig if err := yaml.UnmarshalStrict(configContent, &helmWorkloadConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } helmWorkload := helmWorkloadConfig.HelmWorkload helmWorkload.HelmWorkloadConfigPath = createHelmWorkloadConfigPath createdHelmWorkloadDefinition, createdHelmWorkloadInstance, err := helmWorkload.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create helm workload", err) os.Exit(1) } cli.Info(fmt.Sprintf("helm workload definition %s created", *createdHelmWorkloadDefinition.Name)) cli.Info(fmt.Sprintf("helm workload instance %s created", *createdHelmWorkloadInstance.Name)) cli.Complete(fmt.Sprintf("helm workload %s created", helmWorkloadConfig.HelmWorkload.Name)) }, Short: "Create a new helm workload", SilenceUsage: true, Use: "helm-workload", }
CreateHelmWorkloadCmd represents the helm-workload command
var CreateHelmWorkloadDefinitionCmd = &cobra.Command{ Example: " tptctl create helm-workload-definition --config path/to/config.yaml", Long: "Create a new helm workload definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createHelmWorkloadDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var helmWorkloadDefinitionConfig config.HelmWorkloadDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &helmWorkloadDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } helmWorkloadDefinition := helmWorkloadDefinitionConfig.HelmWorkloadDefinition helmWorkloadDefinition.HelmWorkloadConfigPath = createHelmWorkloadDefinitionConfigPath createdHelmWorkloadDefinition, err := helmWorkloadDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create helm workload definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("helm workload definition %s created", *createdHelmWorkloadDefinition.Name)) }, Short: "Create a new helm workload definition", SilenceUsage: true, Use: "helm-workload-definition", }
CreateHelmWorkloadDefinitionCmd represents the helm-workload-definition command
var CreateHelmWorkloadInstanceCmd = &cobra.Command{ Example: " tptctl create helm-workload-instance --config path/to/config.yaml", Long: "Create a new helm workload instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createHelmWorkloadInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var helmWorkloadInstanceConfig config.HelmWorkloadInstanceConfig if err := yaml.UnmarshalStrict(configContent, &helmWorkloadInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } helmWorkloadInstance := helmWorkloadInstanceConfig.HelmWorkloadInstance helmWorkloadInstance.HelmWorkloadConfigPath = createHelmWorkloadInstanceConfigPath createdHelmWorkloadInstance, err := helmWorkloadInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create helm workload instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("helm workload instance %s created", *createdHelmWorkloadInstance.Name)) }, Short: "Create a new helm workload instance", SilenceUsage: true, Use: "helm-workload-instance", }
CreateHelmWorkloadInstanceCmd represents the helm-workload-instance command
var CreateKubernetesRuntimeCmd = &cobra.Command{ Example: " tptctl create kubernetes-runtime --config path/to/config.yaml", Long: "Create a new kubernetes runtime. This command creates a new kubernetes runtime definition and kubernetes runtime instance based on the kubernetes runtime config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createKubernetesRuntimeConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var kubernetesRuntimeConfig config.KubernetesRuntimeConfig if err := yaml.UnmarshalStrict(configContent, &kubernetesRuntimeConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } kubernetesRuntime := kubernetesRuntimeConfig.KubernetesRuntime createdKubernetesRuntimeDefinition, createdKubernetesRuntimeInstance, err := kubernetesRuntime.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create kubernetes runtime", err) os.Exit(1) } cli.Info(fmt.Sprintf("kubernetes runtime definition %s created", *createdKubernetesRuntimeDefinition.Name)) cli.Info(fmt.Sprintf("kubernetes runtime instance %s created", *createdKubernetesRuntimeInstance.Name)) cli.Complete(fmt.Sprintf("kubernetes runtime %s created", kubernetesRuntimeConfig.KubernetesRuntime.Name)) }, Short: "Create a new kubernetes runtime", SilenceUsage: true, Use: "kubernetes-runtime", }
CreateKubernetesRuntimeCmd represents the kubernetes-runtime command
var CreateKubernetesRuntimeDefinitionCmd = &cobra.Command{ Example: " tptctl create kubernetes-runtime-definition --config path/to/config.yaml", Long: "Create a new kubernetes runtime definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createKubernetesRuntimeDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var kubernetesRuntimeDefinitionConfig config.KubernetesRuntimeDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &kubernetesRuntimeDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } kubernetesRuntimeDefinition := kubernetesRuntimeDefinitionConfig.KubernetesRuntimeDefinition createdKubernetesRuntimeDefinition, err := kubernetesRuntimeDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create kubernetes runtime definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("kubernetes runtime definition %s created", *createdKubernetesRuntimeDefinition.Name)) }, Short: "Create a new kubernetes runtime definition", SilenceUsage: true, Use: "kubernetes-runtime-definition", }
CreateKubernetesRuntimeDefinitionCmd represents the kubernetes-runtime-definition command
var CreateKubernetesRuntimeInstanceCmd = &cobra.Command{ Example: " tptctl create kubernetes-runtime-instance --config path/to/config.yaml", Long: "Create a new kubernetes runtime instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createKubernetesRuntimeInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var kubernetesRuntimeInstanceConfig config.KubernetesRuntimeInstanceConfig if err := yaml.UnmarshalStrict(configContent, &kubernetesRuntimeInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } kubernetesRuntimeInstance := kubernetesRuntimeInstanceConfig.KubernetesRuntimeInstance createdKubernetesRuntimeInstance, err := kubernetesRuntimeInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create kubernetes runtime instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("kubernetes runtime instance %s created", *createdKubernetesRuntimeInstance.Name)) }, Short: "Create a new kubernetes runtime instance", SilenceUsage: true, Use: "kubernetes-runtime-instance", }
CreateKubernetesRuntimeInstanceCmd represents the kubernetes-runtime-instance command
var CreateObservabilityStackCmd = &cobra.Command{ Example: " tptctl create observability-stack --config path/to/config.yaml", Long: "Create a new observability stack. This command creates a new observability stack definition and observability stack instance based on the observability stack config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createObservabilityStackConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var observabilityStackConfig config.ObservabilityStackConfig if err := yaml.UnmarshalStrict(configContent, &observabilityStackConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } observabilityStack := observabilityStackConfig.ObservabilityStack observabilityStack.ObservabilityConfigPath = createObservabilityStackConfigPath createdObservabilityStackDefinition, createdObservabilityStackInstance, err := observabilityStack.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create observability stack", err) os.Exit(1) } cli.Info(fmt.Sprintf("observability stack definition %s created", *createdObservabilityStackDefinition.Name)) cli.Info(fmt.Sprintf("observability stack instance %s created", *createdObservabilityStackInstance.Name)) cli.Complete(fmt.Sprintf("observability stack %s created", observabilityStackConfig.ObservabilityStack.Name)) }, Short: "Create a new observability stack", SilenceUsage: true, Use: "observability-stack", }
CreateObservabilityStackCmd represents the observability-stack command
var CreateObservabilityStackDefinitionCmd = &cobra.Command{ Example: " tptctl create observability-stack-definition --config path/to/config.yaml", Long: "Create a new observability stack definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createObservabilityStackDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var observabilityStackDefinitionConfig config.ObservabilityStackDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &observabilityStackDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } observabilityStackDefinition := observabilityStackDefinitionConfig.ObservabilityStackDefinition observabilityStackDefinition.ObservabilityConfigPath = createObservabilityStackDefinitionConfigPath createdObservabilityStackDefinition, err := observabilityStackDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create observability stack definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("observability stack definition %s created", *createdObservabilityStackDefinition.Name)) }, Short: "Create a new observability stack definition", SilenceUsage: true, Use: "observability-stack-definition", }
CreateObservabilityStackDefinitionCmd represents the observability-stack-definition command
var CreateObservabilityStackInstanceCmd = &cobra.Command{ Example: " tptctl create observability-stack-instance --config path/to/config.yaml", Long: "Create a new observability stack instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createObservabilityStackInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var observabilityStackInstanceConfig config.ObservabilityStackInstanceConfig if err := yaml.UnmarshalStrict(configContent, &observabilityStackInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } observabilityStackInstance := observabilityStackInstanceConfig.ObservabilityStackInstance observabilityStackInstance.ObservabilityConfigPath = createObservabilityStackInstanceConfigPath createdObservabilityStackInstance, err := observabilityStackInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create observability stack instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("observability stack instance %s created", *createdObservabilityStackInstance.Name)) }, Short: "Create a new observability stack instance", SilenceUsage: true, Use: "observability-stack-instance", }
CreateObservabilityStackInstanceCmd represents the observability-stack-instance command
var CreateSecretCmd = &cobra.Command{ Example: " tptctl create secret --config path/to/config.yaml", Long: "Create a new secret. This command creates a new secret definition and secret instance based on the secret config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createSecretConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var secretConfig config.SecretConfig if err := yaml.UnmarshalStrict(configContent, &secretConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } secret := secretConfig.Secret secret.SecretConfigPath = createSecretConfigPath createdSecretDefinition, createdSecretInstance, err := secret.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create secret", err) os.Exit(1) } cli.Info(fmt.Sprintf("secret definition %s created", *createdSecretDefinition.Name)) cli.Info(fmt.Sprintf("secret instance %s created", *createdSecretInstance.Name)) cli.Complete(fmt.Sprintf("secret %s created", secretConfig.Secret.Name)) }, Short: "Create a new secret", SilenceUsage: true, Use: "secret", }
CreateSecretCmd represents the secret command
var CreateSecretDefinitionCmd = &cobra.Command{ Example: " tptctl create secret-definition --config path/to/config.yaml", Long: "Create a new secret definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createSecretDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var secretDefinitionConfig config.SecretDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &secretDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } secretDefinition := secretDefinitionConfig.SecretDefinition secretDefinition.SecretConfigPath = createSecretDefinitionConfigPath createdSecretDefinition, err := secretDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create secret definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("secret definition %s created", *createdSecretDefinition.Name)) }, Short: "Create a new secret definition", SilenceUsage: true, Use: "secret-definition", }
CreateSecretDefinitionCmd represents the secret-definition command
var CreateSecretInstanceCmd = &cobra.Command{ Example: " tptctl create secret-instance --config path/to/config.yaml", Long: "Create a new secret instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createSecretInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var secretInstanceConfig config.SecretInstanceConfig if err := yaml.UnmarshalStrict(configContent, &secretInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } secretInstance := secretInstanceConfig.SecretInstance secretInstance.SecretConfigPath = createSecretInstanceConfigPath createdSecretInstance, err := secretInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create secret instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("secret instance %s created", *createdSecretInstance.Name)) }, Short: "Create a new secret instance", SilenceUsage: true, Use: "secret-instance", }
CreateSecretInstanceCmd represents the secret-instance command
var CreateTerraformCmd = &cobra.Command{ Example: " tptctl create terraform --config path/to/config.yaml", Long: "Create a new terraform. This command creates a new terraform definition and terraform instance based on the terraform config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createTerraformConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var terraformConfig config.TerraformConfig if err := yaml.UnmarshalStrict(configContent, &terraformConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } terraform := terraformConfig.Terraform terraform.TerraformConfigPath = createTerraformConfigPath createdTerraformDefinition, createdTerraformInstance, err := terraform.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create terraform", err) os.Exit(1) } cli.Info(fmt.Sprintf("terraform definition %s created", *createdTerraformDefinition.Name)) cli.Info(fmt.Sprintf("terraform instance %s created", *createdTerraformInstance.Name)) cli.Complete(fmt.Sprintf("terraform %s created", terraformConfig.Terraform.Name)) }, Short: "Create a new terraform", SilenceUsage: true, Use: "terraform", }
CreateTerraformCmd represents the terraform command
var CreateTerraformDefinitionCmd = &cobra.Command{ Example: " tptctl create terraform-definition --config path/to/config.yaml", Long: "Create a new terraform definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createTerraformDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var terraformDefinitionConfig config.TerraformDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &terraformDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } terraformDefinition := terraformDefinitionConfig.TerraformDefinition terraformDefinition.TerraformConfigPath = createTerraformDefinitionConfigPath createdTerraformDefinition, err := terraformDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create terraform definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("terraform definition %s created", *createdTerraformDefinition.Name)) }, Short: "Create a new terraform definition", SilenceUsage: true, Use: "terraform-definition", }
CreateTerraformDefinitionCmd represents the terraform-definition command
var CreateTerraformInstanceCmd = &cobra.Command{ Example: " tptctl create terraform-instance --config path/to/config.yaml", Long: "Create a new terraform instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createTerraformInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var terraformInstanceConfig config.TerraformInstanceConfig if err := yaml.UnmarshalStrict(configContent, &terraformInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } terraformInstance := terraformInstanceConfig.TerraformInstance terraformInstance.TerraformConfigPath = createTerraformInstanceConfigPath createdTerraformInstance, err := terraformInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create terraform instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("terraform instance %s created", *createdTerraformInstance.Name)) }, Short: "Create a new terraform instance", SilenceUsage: true, Use: "terraform-instance", }
CreateTerraformInstanceCmd represents the terraform-instance command
var CreateWorkloadCmd = &cobra.Command{ Example: " tptctl create workload --config path/to/config.yaml", Long: "Create a new workload. This command creates a new workload definition and workload instance based on the workload config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createWorkloadConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var workloadConfig config.WorkloadConfig if err := yaml.UnmarshalStrict(configContent, &workloadConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } workload := workloadConfig.Workload workload.WorkloadConfigPath = createWorkloadConfigPath createdWorkloadDefinition, createdWorkloadInstance, err := workload.Create( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to create workload", err) os.Exit(1) } cli.Info(fmt.Sprintf("workload definition %s created", *createdWorkloadDefinition.Name)) cli.Info(fmt.Sprintf("workload instance %s created", *createdWorkloadInstance.Name)) cli.Complete(fmt.Sprintf("workload %s created", workloadConfig.Workload.Name)) }, Short: "Create a new workload", SilenceUsage: true, Use: "workload", }
CreateWorkloadCmd represents the workload command
var CreateWorkloadDefinitionCmd = &cobra.Command{ Example: " tptctl create workload-definition --config path/to/config.yaml", Long: "Create a new workload definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createWorkloadDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var workloadDefinitionConfig config.WorkloadDefinitionConfig if err := yaml.UnmarshalStrict(configContent, &workloadDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } workloadDefinition := workloadDefinitionConfig.WorkloadDefinition workloadDefinition.WorkloadConfigPath = createWorkloadDefinitionConfigPath createdWorkloadDefinition, err := workloadDefinition.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create workload definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("workload definition %s created", *createdWorkloadDefinition.Name)) }, Short: "Create a new workload definition", SilenceUsage: true, Use: "workload-definition", }
CreateWorkloadDefinitionCmd represents the workload-definition command
var CreateWorkloadInstanceCmd = &cobra.Command{ Example: " tptctl create workload-instance --config path/to/config.yaml", Long: "Create a new workload instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) configContent, err := os.ReadFile(createWorkloadInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } var workloadInstanceConfig config.WorkloadInstanceConfig if err := yaml.UnmarshalStrict(configContent, &workloadInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } workloadInstance := workloadInstanceConfig.WorkloadInstance createdWorkloadInstance, err := workloadInstance.Create(apiClient, apiEndpoint) if err != nil { cli.Error("failed to create workload instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("workload instance %s created", *createdWorkloadInstance.Name)) }, Short: "Create a new workload instance", SilenceUsage: true, Use: "workload-instance", }
CreateWorkloadInstanceCmd represents the workload-instance command
var DeleteAwsAccountCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-account --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-account --name some-aws-account", Long: "Delete an existing aws account.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteAwsAccountConfigPath, deleteAwsAccountName, "aws account", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var awsAccountConfig config.AwsAccountConfig if deleteAwsAccountConfigPath != "" { configContent, err := os.ReadFile(deleteAwsAccountConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsAccountConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsAccountConfig = config.AwsAccountConfig{ AwsAccount: config.AwsAccountValues{ Name: deleteAwsAccountName, }, } } awsAccount := awsAccountConfig.AwsAccount deletedAwsAccount, err := awsAccount.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws account", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws account %s deleted", *deletedAwsAccount.Name)) }, Short: "Delete an existing aws account", SilenceUsage: true, Use: "aws-account", }
DeleteAwsAccountCmd represents the aws-account command
var DeleteAwsEksKubernetesRuntimeCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-eks-kubernetes-runtime --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-eks-kubernetes-runtime --name some-aws-eks-kubernetes-runtime", Long: "Delete an existing aws eks kubernetes runtime. This command deletes an existing aws eks kubernetes runtime definition and aws eks kubernetes runtime instance based on the aws eks kubernetes runtime config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteAwsEksKubernetesRuntimeConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var awsEksKubernetesRuntimeConfig config.AwsEksKubernetesRuntimeConfig configContent, err := os.ReadFile(deleteAwsEksKubernetesRuntimeConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsEksKubernetesRuntimeConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsEksKubernetesRuntime := awsEksKubernetesRuntimeConfig.AwsEksKubernetesRuntime _, _, err = awsEksKubernetesRuntime.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws eks kubernetes runtime", err) os.Exit(1) } cli.Info(fmt.Sprintf("aws eks kubernetes runtime definition %s deleted", awsEksKubernetesRuntime.Name)) cli.Info(fmt.Sprintf("aws eks kubernetes runtime instance %s deleted", awsEksKubernetesRuntime.Name)) cli.Complete(fmt.Sprintf("aws eks kubernetes runtime %s deleted", awsEksKubernetesRuntimeConfig.AwsEksKubernetesRuntime.Name)) }, Short: "Delete an existing aws eks kubernetes runtime", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime", }
DeleteAwsEksKubernetesRuntimeCmd represents the aws-eks-kubernetes-runtime command
var DeleteAwsEksKubernetesRuntimeDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-eks-kubernetes-runtime-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-eks-kubernetes-runtime-definition --name some-aws-eks-kubernetes-runtime-definition", Long: "Delete an existing aws eks kubernetes runtime definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteAwsEksKubernetesRuntimeDefinitionConfigPath, deleteAwsEksKubernetesRuntimeDefinitionName, "aws eks kubernetes runtime definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var awsEksKubernetesRuntimeDefinitionConfig config.AwsEksKubernetesRuntimeDefinitionConfig if deleteAwsEksKubernetesRuntimeDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteAwsEksKubernetesRuntimeDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsEksKubernetesRuntimeDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsEksKubernetesRuntimeDefinitionConfig = config.AwsEksKubernetesRuntimeDefinitionConfig{ AwsEksKubernetesRuntimeDefinition: config.AwsEksKubernetesRuntimeDefinitionValues{ Name: deleteAwsEksKubernetesRuntimeDefinitionName, }, } } awsEksKubernetesRuntimeDefinition := awsEksKubernetesRuntimeDefinitionConfig.AwsEksKubernetesRuntimeDefinition deletedAwsEksKubernetesRuntimeDefinition, err := awsEksKubernetesRuntimeDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws eks kubernetes runtime definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws eks kubernetes runtime definition %s deleted", *deletedAwsEksKubernetesRuntimeDefinition.Name)) }, Short: "Delete an existing aws eks kubernetes runtime definition", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime-definition", }
DeleteAwsEksKubernetesRuntimeDefinitionCmd represents the aws-eks-kubernetes-runtime-definition command
var DeleteAwsEksKubernetesRuntimeInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-eks-kubernetes-runtime-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-eks-kubernetes-runtime-instance --name some-aws-eks-kubernetes-runtime-instance", Long: "Delete an existing aws eks kubernetes runtime instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteAwsEksKubernetesRuntimeInstanceConfigPath, deleteAwsEksKubernetesRuntimeInstanceName, "aws eks kubernetes runtime instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var awsEksKubernetesRuntimeInstanceConfig config.AwsEksKubernetesRuntimeInstanceConfig if deleteAwsEksKubernetesRuntimeInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteAwsEksKubernetesRuntimeInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsEksKubernetesRuntimeInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsEksKubernetesRuntimeInstanceConfig = config.AwsEksKubernetesRuntimeInstanceConfig{ AwsEksKubernetesRuntimeInstance: config.AwsEksKubernetesRuntimeInstanceValues{ Name: deleteAwsEksKubernetesRuntimeInstanceName, }, } } awsEksKubernetesRuntimeInstance := awsEksKubernetesRuntimeInstanceConfig.AwsEksKubernetesRuntimeInstance deletedAwsEksKubernetesRuntimeInstance, err := awsEksKubernetesRuntimeInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws eks kubernetes runtime instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws eks kubernetes runtime instance %s deleted", *deletedAwsEksKubernetesRuntimeInstance.Name)) }, Short: "Delete an existing aws eks kubernetes runtime instance", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime-instance", }
DeleteAwsEksKubernetesRuntimeInstanceCmd represents the aws-eks-kubernetes-runtime-instance command
var DeleteAwsObjectStorageBucketCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-object-storage-bucket --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-object-storage-bucket --name some-aws-object-storage-bucket", Long: "Delete an existing aws object storage bucket. This command deletes an existing aws object storage bucket definition and aws object storage bucket instance based on the aws object storage bucket config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteAwsObjectStorageBucketConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var awsObjectStorageBucketConfig config.AwsObjectStorageBucketConfig configContent, err := os.ReadFile(deleteAwsObjectStorageBucketConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsObjectStorageBucketConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsObjectStorageBucket := awsObjectStorageBucketConfig.AwsObjectStorageBucket _, _, err = awsObjectStorageBucket.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws object storage bucket", err) os.Exit(1) } cli.Info(fmt.Sprintf("aws object storage bucket definition %s deleted", awsObjectStorageBucket.Name)) cli.Info(fmt.Sprintf("aws object storage bucket instance %s deleted", awsObjectStorageBucket.Name)) cli.Complete(fmt.Sprintf("aws object storage bucket %s deleted", awsObjectStorageBucketConfig.AwsObjectStorageBucket.Name)) }, Short: "Delete an existing aws object storage bucket", SilenceUsage: true, Use: "aws-object-storage-bucket", }
DeleteAwsObjectStorageBucketCmd represents the aws-object-storage-bucket command
var DeleteAwsObjectStorageBucketDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-object-storage-bucket-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-object-storage-bucket-definition --name some-aws-object-storage-bucket-definition", Long: "Delete an existing aws object storage bucket definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteAwsObjectStorageBucketDefinitionConfigPath, deleteAwsObjectStorageBucketDefinitionName, "aws object storage bucket definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var awsObjectStorageBucketDefinitionConfig config.AwsObjectStorageBucketDefinitionConfig if deleteAwsObjectStorageBucketDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteAwsObjectStorageBucketDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsObjectStorageBucketDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsObjectStorageBucketDefinitionConfig = config.AwsObjectStorageBucketDefinitionConfig{ AwsObjectStorageBucketDefinition: config.AwsObjectStorageBucketDefinitionValues{ Name: deleteAwsObjectStorageBucketDefinitionName, }, } } awsObjectStorageBucketDefinition := awsObjectStorageBucketDefinitionConfig.AwsObjectStorageBucketDefinition deletedAwsObjectStorageBucketDefinition, err := awsObjectStorageBucketDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws object storage bucket definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws object storage bucket definition %s deleted", *deletedAwsObjectStorageBucketDefinition.Name)) }, Short: "Delete an existing aws object storage bucket definition", SilenceUsage: true, Use: "aws-object-storage-bucket-definition", }
DeleteAwsObjectStorageBucketDefinitionCmd represents the aws-object-storage-bucket-definition command
var DeleteAwsObjectStorageBucketInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-object-storage-bucket-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-object-storage-bucket-instance --name some-aws-object-storage-bucket-instance", Long: "Delete an existing aws object storage bucket instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteAwsObjectStorageBucketInstanceConfigPath, deleteAwsObjectStorageBucketInstanceName, "aws object storage bucket instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var awsObjectStorageBucketInstanceConfig config.AwsObjectStorageBucketInstanceConfig if deleteAwsObjectStorageBucketInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteAwsObjectStorageBucketInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsObjectStorageBucketInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsObjectStorageBucketInstanceConfig = config.AwsObjectStorageBucketInstanceConfig{ AwsObjectStorageBucketInstance: config.AwsObjectStorageBucketInstanceValues{ Name: deleteAwsObjectStorageBucketInstanceName, }, } } awsObjectStorageBucketInstance := awsObjectStorageBucketInstanceConfig.AwsObjectStorageBucketInstance deletedAwsObjectStorageBucketInstance, err := awsObjectStorageBucketInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws object storage bucket instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws object storage bucket instance %s deleted", *deletedAwsObjectStorageBucketInstance.Name)) }, Short: "Delete an existing aws object storage bucket instance", SilenceUsage: true, Use: "aws-object-storage-bucket-instance", }
DeleteAwsObjectStorageBucketInstanceCmd represents the aws-object-storage-bucket-instance command
var DeleteAwsRelationalDatabaseCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-relational-database --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-relational-database --name some-aws-relational-database", Long: "Delete an existing aws relational database. This command deletes an existing aws relational database definition and aws relational database instance based on the aws relational database config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteAwsRelationalDatabaseConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var awsRelationalDatabaseConfig config.AwsRelationalDatabaseConfig configContent, err := os.ReadFile(deleteAwsRelationalDatabaseConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsRelationalDatabaseConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } awsRelationalDatabase := awsRelationalDatabaseConfig.AwsRelationalDatabase _, _, err = awsRelationalDatabase.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws relational database", err) os.Exit(1) } cli.Info(fmt.Sprintf("aws relational database definition %s deleted", awsRelationalDatabase.Name)) cli.Info(fmt.Sprintf("aws relational database instance %s deleted", awsRelationalDatabase.Name)) cli.Complete(fmt.Sprintf("aws relational database %s deleted", awsRelationalDatabaseConfig.AwsRelationalDatabase.Name)) }, Short: "Delete an existing aws relational database", SilenceUsage: true, Use: "aws-relational-database", }
DeleteAwsRelationalDatabaseCmd represents the aws-relational-database command
var DeleteAwsRelationalDatabaseDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-relational-database-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-relational-database-definition --name some-aws-relational-database-definition", Long: "Delete an existing aws relational database definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteAwsRelationalDatabaseDefinitionConfigPath, deleteAwsRelationalDatabaseDefinitionName, "aws relational database definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var awsRelationalDatabaseDefinitionConfig config.AwsRelationalDatabaseDefinitionConfig if deleteAwsRelationalDatabaseDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteAwsRelationalDatabaseDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsRelationalDatabaseDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsRelationalDatabaseDefinitionConfig = config.AwsRelationalDatabaseDefinitionConfig{ AwsRelationalDatabaseDefinition: config.AwsRelationalDatabaseDefinitionValues{ Name: deleteAwsRelationalDatabaseDefinitionName, }, } } awsRelationalDatabaseDefinition := awsRelationalDatabaseDefinitionConfig.AwsRelationalDatabaseDefinition deletedAwsRelationalDatabaseDefinition, err := awsRelationalDatabaseDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws relational database definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws relational database definition %s deleted", *deletedAwsRelationalDatabaseDefinition.Name)) }, Short: "Delete an existing aws relational database definition", SilenceUsage: true, Use: "aws-relational-database-definition", }
DeleteAwsRelationalDatabaseDefinitionCmd represents the aws-relational-database-definition command
var DeleteAwsRelationalDatabaseInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete aws-relational-database-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete aws-relational-database-instance --name some-aws-relational-database-instance", Long: "Delete an existing aws relational database instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteAwsRelationalDatabaseInstanceConfigPath, deleteAwsRelationalDatabaseInstanceName, "aws relational database instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var awsRelationalDatabaseInstanceConfig config.AwsRelationalDatabaseInstanceConfig if deleteAwsRelationalDatabaseInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteAwsRelationalDatabaseInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsRelationalDatabaseInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsRelationalDatabaseInstanceConfig = config.AwsRelationalDatabaseInstanceConfig{ AwsRelationalDatabaseInstance: config.AwsRelationalDatabaseInstanceValues{ Name: deleteAwsRelationalDatabaseInstanceName, }, } } awsRelationalDatabaseInstance := awsRelationalDatabaseInstanceConfig.AwsRelationalDatabaseInstance deletedAwsRelationalDatabaseInstance, err := awsRelationalDatabaseInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete aws relational database instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("aws relational database instance %s deleted", *deletedAwsRelationalDatabaseInstance.Name)) }, Short: "Delete an existing aws relational database instance", SilenceUsage: true, Use: "aws-relational-database-instance", }
DeleteAwsRelationalDatabaseInstanceCmd represents the aws-relational-database-instance command
var DeleteCmd = &cobra.Command{
Use: "delete",
Short: "Delete Threeport objects",
Long: `Delete Threeport objects.
The delete command does nothing by itself. Use one of the avilable subcommands
to delete different objects in the system.`,
}
DeleteCmd represents the delete command
var DeleteControlPlaneCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete control-plane --config path/to/config.yaml\n\n # delete based on name\n tptctl delete control-plane --name some-control-plane", Long: "Delete an existing control plane. This command deletes an existing control plane definition and control plane instance based on the control plane config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteControlPlaneConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var controlPlaneConfig config.ControlPlaneConfig configContent, err := os.ReadFile(deleteControlPlaneConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &controlPlaneConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } controlPlane := controlPlaneConfig.ControlPlane _, _, err = controlPlane.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete control plane", err) os.Exit(1) } cli.Info(fmt.Sprintf("control plane definition %s deleted", controlPlane.Name)) cli.Info(fmt.Sprintf("control plane instance %s deleted", controlPlane.Name)) cli.Complete(fmt.Sprintf("control plane %s deleted", controlPlaneConfig.ControlPlane.Name)) }, Short: "Delete an existing control plane", SilenceUsage: true, Use: "control-plane", }
DeleteControlPlaneCmd represents the control-plane command
var DeleteControlPlaneDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete control-plane-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete control-plane-definition --name some-control-plane-definition", Long: "Delete an existing control plane definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteControlPlaneDefinitionConfigPath, deleteControlPlaneDefinitionName, "control plane definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var controlPlaneDefinitionConfig config.ControlPlaneDefinitionConfig if deleteControlPlaneDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteControlPlaneDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &controlPlaneDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { controlPlaneDefinitionConfig = config.ControlPlaneDefinitionConfig{ ControlPlaneDefinition: config.ControlPlaneDefinitionValues{ Name: deleteControlPlaneDefinitionName, }, } } controlPlaneDefinition := controlPlaneDefinitionConfig.ControlPlaneDefinition deletedControlPlaneDefinition, err := controlPlaneDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete control plane definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("control plane definition %s deleted", *deletedControlPlaneDefinition.Name)) }, Short: "Delete an existing control plane definition", SilenceUsage: true, Use: "control-plane-definition", }
DeleteControlPlaneDefinitionCmd represents the control-plane-definition command
var DeleteControlPlaneInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete control-plane-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete control-plane-instance --name some-control-plane-instance", Long: "Delete an existing control plane instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteControlPlaneInstanceConfigPath, deleteControlPlaneInstanceName, "control plane instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var controlPlaneInstanceConfig config.ControlPlaneInstanceConfig if deleteControlPlaneInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteControlPlaneInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &controlPlaneInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { controlPlaneInstanceConfig = config.ControlPlaneInstanceConfig{ ControlPlaneInstance: config.ControlPlaneInstanceValues{ Name: deleteControlPlaneInstanceName, }, } } controlPlaneInstance := controlPlaneInstanceConfig.ControlPlaneInstance deletedControlPlaneInstance, err := controlPlaneInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete control plane instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("control plane instance %s deleted", *deletedControlPlaneInstance.Name)) }, Short: "Delete an existing control plane instance", SilenceUsage: true, Use: "control-plane-instance", }
DeleteControlPlaneInstanceCmd represents the control-plane-instance command
var DeleteDomainNameCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete domain-name --config path/to/config.yaml\n\n # delete based on name\n tptctl delete domain-name --name some-domain-name", Long: "Delete an existing domain name. This command deletes an existing domain name definition and domain name instance based on the domain name config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteDomainNameConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var domainNameConfig config.DomainNameConfig configContent, err := os.ReadFile(deleteDomainNameConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &domainNameConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } domainName := domainNameConfig.DomainName _, _, err = domainName.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete domain name", err) os.Exit(1) } cli.Info(fmt.Sprintf("domain name definition %s deleted", domainName.Name)) cli.Info(fmt.Sprintf("domain name instance %s deleted", domainName.Name)) cli.Complete(fmt.Sprintf("domain name %s deleted", domainNameConfig.DomainName.Name)) }, Short: "Delete an existing domain name", SilenceUsage: true, Use: "domain-name", }
DeleteDomainNameCmd represents the domain-name command
var DeleteDomainNameDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete domain-name-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete domain-name-definition --name some-domain-name-definition", Long: "Delete an existing domain name definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteDomainNameDefinitionConfigPath, deleteDomainNameDefinitionName, "domain name definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var domainNameDefinitionConfig config.DomainNameDefinitionConfig if deleteDomainNameDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteDomainNameDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &domainNameDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { domainNameDefinitionConfig = config.DomainNameDefinitionConfig{ DomainNameDefinition: config.DomainNameDefinitionValues{ Name: deleteDomainNameDefinitionName, }, } } domainNameDefinition := domainNameDefinitionConfig.DomainNameDefinition deletedDomainNameDefinition, err := domainNameDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete domain name definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("domain name definition %s deleted", *deletedDomainNameDefinition.Name)) }, Short: "Delete an existing domain name definition", SilenceUsage: true, Use: "domain-name-definition", }
DeleteDomainNameDefinitionCmd represents the domain-name-definition command
var DeleteDomainNameInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete domain-name-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete domain-name-instance --name some-domain-name-instance", Long: "Delete an existing domain name instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteDomainNameInstanceConfigPath, deleteDomainNameInstanceName, "domain name instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var domainNameInstanceConfig config.DomainNameInstanceConfig if deleteDomainNameInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteDomainNameInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &domainNameInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { domainNameInstanceConfig = config.DomainNameInstanceConfig{ DomainNameInstance: config.DomainNameInstanceValues{ Name: deleteDomainNameInstanceName, }, } } domainNameInstance := domainNameInstanceConfig.DomainNameInstance deletedDomainNameInstance, err := domainNameInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete domain name instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("domain name instance %s deleted", *deletedDomainNameInstance.Name)) }, Short: "Delete an existing domain name instance", SilenceUsage: true, Use: "domain-name-instance", }
DeleteDomainNameInstanceCmd represents the domain-name-instance command
var DeleteGatewayCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete gateway --config path/to/config.yaml\n\n # delete based on name\n tptctl delete gateway --name some-gateway", Long: "Delete an existing gateway. This command deletes an existing gateway definition and gateway instance based on the gateway config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteGatewayConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var gatewayConfig config.GatewayConfig configContent, err := os.ReadFile(deleteGatewayConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &gatewayConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } gateway := gatewayConfig.Gateway _, _, err = gateway.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete gateway", err) os.Exit(1) } cli.Info(fmt.Sprintf("gateway definition %s deleted", gateway.Name)) cli.Info(fmt.Sprintf("gateway instance %s deleted", gateway.Name)) cli.Complete(fmt.Sprintf("gateway %s deleted", gatewayConfig.Gateway.Name)) }, Short: "Delete an existing gateway", SilenceUsage: true, Use: "gateway", }
DeleteGatewayCmd represents the gateway command
var DeleteGatewayDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete gateway-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete gateway-definition --name some-gateway-definition", Long: "Delete an existing gateway definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteGatewayDefinitionConfigPath, deleteGatewayDefinitionName, "gateway definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var gatewayDefinitionConfig config.GatewayDefinitionConfig if deleteGatewayDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteGatewayDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &gatewayDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { gatewayDefinitionConfig = config.GatewayDefinitionConfig{ GatewayDefinition: config.GatewayDefinitionValues{ Name: deleteGatewayDefinitionName, }, } } gatewayDefinition := gatewayDefinitionConfig.GatewayDefinition deletedGatewayDefinition, err := gatewayDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete gateway definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("gateway definition %s deleted", *deletedGatewayDefinition.Name)) }, Short: "Delete an existing gateway definition", SilenceUsage: true, Use: "gateway-definition", }
DeleteGatewayDefinitionCmd represents the gateway-definition command
var DeleteGatewayInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete gateway-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete gateway-instance --name some-gateway-instance", Long: "Delete an existing gateway instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteGatewayInstanceConfigPath, deleteGatewayInstanceName, "gateway instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var gatewayInstanceConfig config.GatewayInstanceConfig if deleteGatewayInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteGatewayInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &gatewayInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { gatewayInstanceConfig = config.GatewayInstanceConfig{ GatewayInstance: config.GatewayInstanceValues{ Name: deleteGatewayInstanceName, }, } } gatewayInstance := gatewayInstanceConfig.GatewayInstance deletedGatewayInstance, err := gatewayInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete gateway instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("gateway instance %s deleted", *deletedGatewayInstance.Name)) }, Short: "Delete an existing gateway instance", SilenceUsage: true, Use: "gateway-instance", }
DeleteGatewayInstanceCmd represents the gateway-instance command
var DeleteHelmWorkloadCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete helm-workload --config path/to/config.yaml\n\n # delete based on name\n tptctl delete helm-workload --name some-helm-workload", Long: "Delete an existing helm workload. This command deletes an existing helm workload definition and helm workload instance based on the helm workload config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteHelmWorkloadConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var helmWorkloadConfig config.HelmWorkloadConfig configContent, err := os.ReadFile(deleteHelmWorkloadConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &helmWorkloadConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } helmWorkload := helmWorkloadConfig.HelmWorkload helmWorkload.HelmWorkloadConfigPath = deleteHelmWorkloadConfigPath _, _, err = helmWorkload.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete helm workload", err) os.Exit(1) } cli.Info(fmt.Sprintf("helm workload definition %s deleted", helmWorkload.Name)) cli.Info(fmt.Sprintf("helm workload instance %s deleted", helmWorkload.Name)) cli.Complete(fmt.Sprintf("helm workload %s deleted", helmWorkloadConfig.HelmWorkload.Name)) }, Short: "Delete an existing helm workload", SilenceUsage: true, Use: "helm-workload", }
DeleteHelmWorkloadCmd represents the helm-workload command
var DeleteHelmWorkloadDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete helm-workload-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete helm-workload-definition --name some-helm-workload-definition", Long: "Delete an existing helm workload definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteHelmWorkloadDefinitionConfigPath, deleteHelmWorkloadDefinitionName, "helm workload definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var helmWorkloadDefinitionConfig config.HelmWorkloadDefinitionConfig if deleteHelmWorkloadDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteHelmWorkloadDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &helmWorkloadDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { helmWorkloadDefinitionConfig = config.HelmWorkloadDefinitionConfig{ HelmWorkloadDefinition: config.HelmWorkloadDefinitionValues{ Name: deleteHelmWorkloadDefinitionName, }, } } helmWorkloadDefinition := helmWorkloadDefinitionConfig.HelmWorkloadDefinition helmWorkloadDefinition.HelmWorkloadConfigPath = deleteHelmWorkloadDefinitionConfigPath deletedHelmWorkloadDefinition, err := helmWorkloadDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete helm workload definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("helm workload definition %s deleted", *deletedHelmWorkloadDefinition.Name)) }, Short: "Delete an existing helm workload definition", SilenceUsage: true, Use: "helm-workload-definition", }
DeleteHelmWorkloadDefinitionCmd represents the helm-workload-definition command
var DeleteHelmWorkloadInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete helm-workload-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete helm-workload-instance --name some-helm-workload-instance", Long: "Delete an existing helm workload instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteHelmWorkloadInstanceConfigPath, deleteHelmWorkloadInstanceName, "helm workload instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var helmWorkloadInstanceConfig config.HelmWorkloadInstanceConfig if deleteHelmWorkloadInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteHelmWorkloadInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &helmWorkloadInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { helmWorkloadInstanceConfig = config.HelmWorkloadInstanceConfig{ HelmWorkloadInstance: config.HelmWorkloadInstanceValues{ Name: deleteHelmWorkloadInstanceName, }, } } helmWorkloadInstance := helmWorkloadInstanceConfig.HelmWorkloadInstance helmWorkloadInstance.HelmWorkloadConfigPath = deleteHelmWorkloadInstanceConfigPath deletedHelmWorkloadInstance, err := helmWorkloadInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete helm workload instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("helm workload instance %s deleted", *deletedHelmWorkloadInstance.Name)) }, Short: "Delete an existing helm workload instance", SilenceUsage: true, Use: "helm-workload-instance", }
DeleteHelmWorkloadInstanceCmd represents the helm-workload-instance command
var DeleteKubernetesRuntimeCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete kubernetes-runtime --config path/to/config.yaml\n\n # delete based on name\n tptctl delete kubernetes-runtime --name some-kubernetes-runtime", Long: "Delete an existing kubernetes runtime. This command deletes an existing kubernetes runtime definition and kubernetes runtime instance based on the kubernetes runtime config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteKubernetesRuntimeConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var kubernetesRuntimeConfig config.KubernetesRuntimeConfig configContent, err := os.ReadFile(deleteKubernetesRuntimeConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &kubernetesRuntimeConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } kubernetesRuntime := kubernetesRuntimeConfig.KubernetesRuntime _, _, err = kubernetesRuntime.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete kubernetes runtime", err) os.Exit(1) } cli.Info(fmt.Sprintf("kubernetes runtime definition %s deleted", kubernetesRuntime.Name)) cli.Info(fmt.Sprintf("kubernetes runtime instance %s deleted", kubernetesRuntime.Name)) cli.Complete(fmt.Sprintf("kubernetes runtime %s deleted", kubernetesRuntimeConfig.KubernetesRuntime.Name)) }, Short: "Delete an existing kubernetes runtime", SilenceUsage: true, Use: "kubernetes-runtime", }
DeleteKubernetesRuntimeCmd represents the kubernetes-runtime command
var DeleteKubernetesRuntimeDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete kubernetes-runtime-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete kubernetes-runtime-definition --name some-kubernetes-runtime-definition", Long: "Delete an existing kubernetes runtime definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteKubernetesRuntimeDefinitionConfigPath, deleteKubernetesRuntimeDefinitionName, "kubernetes runtime definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var kubernetesRuntimeDefinitionConfig config.KubernetesRuntimeDefinitionConfig if deleteKubernetesRuntimeDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteKubernetesRuntimeDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &kubernetesRuntimeDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { kubernetesRuntimeDefinitionConfig = config.KubernetesRuntimeDefinitionConfig{ KubernetesRuntimeDefinition: config.KubernetesRuntimeDefinitionValues{ Name: deleteKubernetesRuntimeDefinitionName, }, } } kubernetesRuntimeDefinition := kubernetesRuntimeDefinitionConfig.KubernetesRuntimeDefinition deletedKubernetesRuntimeDefinition, err := kubernetesRuntimeDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete kubernetes runtime definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("kubernetes runtime definition %s deleted", *deletedKubernetesRuntimeDefinition.Name)) }, Short: "Delete an existing kubernetes runtime definition", SilenceUsage: true, Use: "kubernetes-runtime-definition", }
DeleteKubernetesRuntimeDefinitionCmd represents the kubernetes-runtime-definition command
var DeleteKubernetesRuntimeInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete kubernetes-runtime-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete kubernetes-runtime-instance --name some-kubernetes-runtime-instance", Long: "Delete an existing kubernetes runtime instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteKubernetesRuntimeInstanceConfigPath, deleteKubernetesRuntimeInstanceName, "kubernetes runtime instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var kubernetesRuntimeInstanceConfig config.KubernetesRuntimeInstanceConfig if deleteKubernetesRuntimeInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteKubernetesRuntimeInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &kubernetesRuntimeInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { kubernetesRuntimeInstanceConfig = config.KubernetesRuntimeInstanceConfig{ KubernetesRuntimeInstance: config.KubernetesRuntimeInstanceValues{ Name: deleteKubernetesRuntimeInstanceName, }, } } kubernetesRuntimeInstance := kubernetesRuntimeInstanceConfig.KubernetesRuntimeInstance deletedKubernetesRuntimeInstance, err := kubernetesRuntimeInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete kubernetes runtime instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("kubernetes runtime instance %s deleted", *deletedKubernetesRuntimeInstance.Name)) }, Short: "Delete an existing kubernetes runtime instance", SilenceUsage: true, Use: "kubernetes-runtime-instance", }
DeleteKubernetesRuntimeInstanceCmd represents the kubernetes-runtime-instance command
var DeleteObservabilityStackCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete observability-stack --config path/to/config.yaml\n\n # delete based on name\n tptctl delete observability-stack --name some-observability-stack", Long: "Delete an existing observability stack. This command deletes an existing observability stack definition and observability stack instance based on the observability stack config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteObservabilityStackConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var observabilityStackConfig config.ObservabilityStackConfig configContent, err := os.ReadFile(deleteObservabilityStackConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &observabilityStackConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } observabilityStack := observabilityStackConfig.ObservabilityStack observabilityStack.ObservabilityConfigPath = deleteObservabilityStackConfigPath _, _, err = observabilityStack.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete observability stack", err) os.Exit(1) } cli.Info(fmt.Sprintf("observability stack definition %s deleted", observabilityStack.Name)) cli.Info(fmt.Sprintf("observability stack instance %s deleted", observabilityStack.Name)) cli.Complete(fmt.Sprintf("observability stack %s deleted", observabilityStackConfig.ObservabilityStack.Name)) }, Short: "Delete an existing observability stack", SilenceUsage: true, Use: "observability-stack", }
DeleteObservabilityStackCmd represents the observability-stack command
var DeleteObservabilityStackDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete observability-stack-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete observability-stack-definition --name some-observability-stack-definition", Long: "Delete an existing observability stack definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteObservabilityStackDefinitionConfigPath, deleteObservabilityStackDefinitionName, "observability stack definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var observabilityStackDefinitionConfig config.ObservabilityStackDefinitionConfig if deleteObservabilityStackDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteObservabilityStackDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &observabilityStackDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { observabilityStackDefinitionConfig = config.ObservabilityStackDefinitionConfig{ ObservabilityStackDefinition: config.ObservabilityStackDefinitionValues{ Name: deleteObservabilityStackDefinitionName, }, } } observabilityStackDefinition := observabilityStackDefinitionConfig.ObservabilityStackDefinition observabilityStackDefinition.ObservabilityConfigPath = deleteObservabilityStackDefinitionConfigPath deletedObservabilityStackDefinition, err := observabilityStackDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete observability stack definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("observability stack definition %s deleted", *deletedObservabilityStackDefinition.Name)) }, Short: "Delete an existing observability stack definition", SilenceUsage: true, Use: "observability-stack-definition", }
DeleteObservabilityStackDefinitionCmd represents the observability-stack-definition command
var DeleteObservabilityStackInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete observability-stack-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete observability-stack-instance --name some-observability-stack-instance", Long: "Delete an existing observability stack instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteObservabilityStackInstanceConfigPath, deleteObservabilityStackInstanceName, "observability stack instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var observabilityStackInstanceConfig config.ObservabilityStackInstanceConfig if deleteObservabilityStackInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteObservabilityStackInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &observabilityStackInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { observabilityStackInstanceConfig = config.ObservabilityStackInstanceConfig{ ObservabilityStackInstance: config.ObservabilityStackInstanceValues{ Name: deleteObservabilityStackInstanceName, }, } } observabilityStackInstance := observabilityStackInstanceConfig.ObservabilityStackInstance observabilityStackInstance.ObservabilityConfigPath = deleteObservabilityStackInstanceConfigPath deletedObservabilityStackInstance, err := observabilityStackInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete observability stack instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("observability stack instance %s deleted", *deletedObservabilityStackInstance.Name)) }, Short: "Delete an existing observability stack instance", SilenceUsage: true, Use: "observability-stack-instance", }
DeleteObservabilityStackInstanceCmd represents the observability-stack-instance command
var DeleteSecretCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete secret --config path/to/config.yaml\n\n # delete based on name\n tptctl delete secret --name some-secret", Long: "Delete an existing secret. This command deletes an existing secret definition and secret instance based on the secret config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteSecretConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var secretConfig config.SecretConfig configContent, err := os.ReadFile(deleteSecretConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &secretConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } secret := secretConfig.Secret secret.SecretConfigPath = deleteSecretConfigPath _, _, err = secret.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete secret", err) os.Exit(1) } cli.Info(fmt.Sprintf("secret definition %s deleted", secret.Name)) cli.Info(fmt.Sprintf("secret instance %s deleted", secret.Name)) cli.Complete(fmt.Sprintf("secret %s deleted", secretConfig.Secret.Name)) }, Short: "Delete an existing secret", SilenceUsage: true, Use: "secret", }
DeleteSecretCmd represents the secret command
var DeleteSecretDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete secret-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete secret-definition --name some-secret-definition", Long: "Delete an existing secret definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteSecretDefinitionConfigPath, deleteSecretDefinitionName, "secret definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var secretDefinitionConfig config.SecretDefinitionConfig if deleteSecretDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteSecretDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &secretDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { secretDefinitionConfig = config.SecretDefinitionConfig{ SecretDefinition: config.SecretDefinitionValues{ Name: deleteSecretDefinitionName, }, } } secretDefinition := secretDefinitionConfig.SecretDefinition secretDefinition.SecretConfigPath = deleteSecretDefinitionConfigPath deletedSecretDefinition, err := secretDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete secret definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("secret definition %s deleted", *deletedSecretDefinition.Name)) }, Short: "Delete an existing secret definition", SilenceUsage: true, Use: "secret-definition", }
DeleteSecretDefinitionCmd represents the secret-definition command
var DeleteSecretInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete secret-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete secret-instance --name some-secret-instance", Long: "Delete an existing secret instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteSecretInstanceConfigPath, deleteSecretInstanceName, "secret instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var secretInstanceConfig config.SecretInstanceConfig if deleteSecretInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteSecretInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &secretInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { secretInstanceConfig = config.SecretInstanceConfig{ SecretInstance: config.SecretInstanceValues{ Name: deleteSecretInstanceName, }, } } secretInstance := secretInstanceConfig.SecretInstance secretInstance.SecretConfigPath = deleteSecretInstanceConfigPath deletedSecretInstance, err := secretInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete secret instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("secret instance %s deleted", *deletedSecretInstance.Name)) }, Short: "Delete an existing secret instance", SilenceUsage: true, Use: "secret-instance", }
DeleteSecretInstanceCmd represents the secret-instance command
var DeleteTerraformCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete terraform --config path/to/config.yaml\n\n # delete based on name\n tptctl delete terraform --name some-terraform", Long: "Delete an existing terraform. This command deletes an existing terraform definition and terraform instance based on the terraform config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteTerraformConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var terraformConfig config.TerraformConfig configContent, err := os.ReadFile(deleteTerraformConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &terraformConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } terraform := terraformConfig.Terraform terraform.TerraformConfigPath = deleteTerraformConfigPath _, _, err = terraform.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete terraform", err) os.Exit(1) } cli.Info(fmt.Sprintf("terraform definition %s deleted", terraform.Name)) cli.Info(fmt.Sprintf("terraform instance %s deleted", terraform.Name)) cli.Complete(fmt.Sprintf("terraform %s deleted", terraformConfig.Terraform.Name)) }, Short: "Delete an existing terraform", SilenceUsage: true, Use: "terraform", }
DeleteTerraformCmd represents the terraform command
var DeleteTerraformDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete terraform-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete terraform-definition --name some-terraform-definition", Long: "Delete an existing terraform definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteTerraformDefinitionConfigPath, deleteTerraformDefinitionName, "terraform definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var terraformDefinitionConfig config.TerraformDefinitionConfig if deleteTerraformDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteTerraformDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &terraformDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { terraformDefinitionConfig = config.TerraformDefinitionConfig{ TerraformDefinition: config.TerraformDefinitionValues{ Name: deleteTerraformDefinitionName, }, } } terraformDefinition := terraformDefinitionConfig.TerraformDefinition terraformDefinition.TerraformConfigPath = deleteTerraformDefinitionConfigPath deletedTerraformDefinition, err := terraformDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete terraform definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("terraform definition %s deleted", *deletedTerraformDefinition.Name)) }, Short: "Delete an existing terraform definition", SilenceUsage: true, Use: "terraform-definition", }
DeleteTerraformDefinitionCmd represents the terraform-definition command
var DeleteTerraformInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete terraform-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete terraform-instance --name some-terraform-instance", Long: "Delete an existing terraform instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteTerraformInstanceConfigPath, deleteTerraformInstanceName, "terraform instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var terraformInstanceConfig config.TerraformInstanceConfig if deleteTerraformInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteTerraformInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &terraformInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { terraformInstanceConfig = config.TerraformInstanceConfig{ TerraformInstance: config.TerraformInstanceValues{ Name: deleteTerraformInstanceName, }, } } terraformInstance := terraformInstanceConfig.TerraformInstance terraformInstance.TerraformConfigPath = deleteTerraformInstanceConfigPath deletedTerraformInstance, err := terraformInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete terraform instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("terraform instance %s deleted", *deletedTerraformInstance.Name)) }, Short: "Delete an existing terraform instance", SilenceUsage: true, Use: "terraform-instance", }
DeleteTerraformInstanceCmd represents the terraform-instance command
var DeleteWorkloadCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete workload --config path/to/config.yaml\n\n # delete based on name\n tptctl delete workload --name some-workload", Long: "Delete an existing workload. This command deletes an existing workload definition and workload instance based on the workload config.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if deleteWorkloadConfigPath == "" { cli.Error("flag validation failed", errors.New("config file path is required")) } var workloadConfig config.WorkloadConfig configContent, err := os.ReadFile(deleteWorkloadConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &workloadConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } workload := workloadConfig.Workload workload.WorkloadConfigPath = deleteWorkloadConfigPath _, _, err = workload.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete workload", err) os.Exit(1) } cli.Info(fmt.Sprintf("workload definition %s deleted", workload.Name)) cli.Info(fmt.Sprintf("workload instance %s deleted", workload.Name)) cli.Complete(fmt.Sprintf("workload %s deleted", workloadConfig.Workload.Name)) }, Short: "Delete an existing workload", SilenceUsage: true, Use: "workload", }
DeleteWorkloadCmd represents the workload command
var DeleteWorkloadDefinitionCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete workload-definition --config path/to/config.yaml\n\n # delete based on name\n tptctl delete workload-definition --name some-workload-definition", Long: "Delete an existing workload definition.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteWorkloadDefinitionConfigPath, deleteWorkloadDefinitionName, "workload definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var workloadDefinitionConfig config.WorkloadDefinitionConfig if deleteWorkloadDefinitionConfigPath != "" { configContent, err := os.ReadFile(deleteWorkloadDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &workloadDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { workloadDefinitionConfig = config.WorkloadDefinitionConfig{ WorkloadDefinition: config.WorkloadDefinitionValues{ Name: deleteWorkloadDefinitionName, }, } } workloadDefinition := workloadDefinitionConfig.WorkloadDefinition workloadDefinition.WorkloadConfigPath = deleteWorkloadDefinitionConfigPath deletedWorkloadDefinition, err := workloadDefinition.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete workload definition", err) os.Exit(1) } cli.Complete(fmt.Sprintf("workload definition %s deleted", *deletedWorkloadDefinition.Name)) }, Short: "Delete an existing workload definition", SilenceUsage: true, Use: "workload-definition", }
DeleteWorkloadDefinitionCmd represents the workload-definition command
var DeleteWorkloadInstanceCmd = &cobra.Command{ Example: " # delete based on config file\n tptctl delete workload-instance --config path/to/config.yaml\n\n # delete based on name\n tptctl delete workload-instance --name some-workload-instance", Long: "Delete an existing workload instance.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( deleteWorkloadInstanceConfigPath, deleteWorkloadInstanceName, "workload instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } var workloadInstanceConfig config.WorkloadInstanceConfig if deleteWorkloadInstanceConfigPath != "" { configContent, err := os.ReadFile(deleteWorkloadInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &workloadInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { workloadInstanceConfig = config.WorkloadInstanceConfig{ WorkloadInstance: config.WorkloadInstanceValues{ Name: deleteWorkloadInstanceName, }, } } workloadInstance := workloadInstanceConfig.WorkloadInstance deletedWorkloadInstance, err := workloadInstance.Delete(apiClient, apiEndpoint) if err != nil { cli.Error("failed to delete workload instance", err) os.Exit(1) } cli.Complete(fmt.Sprintf("workload instance %s deleted", *deletedWorkloadInstance.Name)) }, Short: "Delete an existing workload instance", SilenceUsage: true, Use: "workload-instance", }
DeleteWorkloadInstanceCmd represents the workload-instance command
var DescribeAwsAccountCmd = &cobra.Command{ Example: " # Get the plain output description for a aws account\n tptctl describe aws-account -n some-aws-account\n\n # Get JSON output for a aws account\n tptctl describe aws-account -n some-aws-account -o json\n\n # Get the value of the Name field for a aws account\n tptctl describe aws-account -n some-aws-account -f Name ", Long: "Describe a aws account. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeAwsAccountConfigPath, describeAwsAccountName, "aws account", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeAwsAccountOutput, "aws account", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load aws account config by name or config file var awsAccountConfig config.AwsAccountConfig if describeAwsAccountConfigPath != "" { configContent, err := os.ReadFile(describeAwsAccountConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsAccountConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsAccountConfig = config.AwsAccountConfig{ AwsAccount: config.AwsAccountValues{ Name: describeAwsAccountName, }, } } awsAccount, err := client.GetAwsAccountByName( apiClient, apiEndpoint, awsAccountConfig.AwsAccount.Name, ) if err != nil { cli.Error("failed to retrieve aws account details", err) os.Exit(1) } if describeAwsAccountField != "" { fieldVal, err := util.GetObjectFieldValue( awsAccount, describeAwsAccountField, ) if err != nil { cli.Error("failed to get field value from aws account", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(awsAccount, describeAwsAccountField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeAwsAccountOutput { case "plain": if err := outputDescribeAwsAccountCmd( awsAccount, &awsAccountConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe aws account", err) os.Exit(1) } case "json": redactedAwsAccount := encryption.RedactEncryptedValues(awsAccount) awsAccountJson, err := json.MarshalIndent(redactedAwsAccount, "", " ") if err != nil { cli.Error("failed to marshal aws account into JSON", err) os.Exit(1) } fmt.Println(string(awsAccountJson)) case "yaml": redactedAwsAccount := encryption.RedactEncryptedValues(awsAccount) awsAccountJson, err := json.MarshalIndent(redactedAwsAccount, "", " ") if err != nil { cli.Error("failed to marshal aws account into JSON", err) os.Exit(1) } awsAccountYaml, err := ghodss_yaml.JSONToYAML(awsAccountJson) if err != nil { cli.Error("failed to convert aws account JSON to YAML", err) os.Exit(1) } fmt.Println(string(awsAccountYaml)) } }, Short: "Describe a aws account", SilenceUsage: true, Use: "aws-account", }
DescribeAwsAccountCmd representes the aws-account command
var DescribeAwsEksKubernetesRuntimeDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a aws eks kubernetes runtime definition\n tptctl describe aws-eks-kubernetes-runtime-definition -n some-aws-eks-kubernetes-runtime-definition\n\n # Get JSON output for a aws eks kubernetes runtime definition\n tptctl describe aws-eks-kubernetes-runtime-definition -n some-aws-eks-kubernetes-runtime-definition -o json\n\n # Get the value of the Name field for a aws eks kubernetes runtime definition\n tptctl describe aws-eks-kubernetes-runtime-definition -n some-aws-eks-kubernetes-runtime-definition -f Name ", Long: "Describe a aws eks kubernetes runtime definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeAwsEksKubernetesRuntimeDefinitionConfigPath, describeAwsEksKubernetesRuntimeDefinitionName, "aws eks kubernetes runtime definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeAwsEksKubernetesRuntimeDefinitionOutput, "aws eks kubernetes runtime definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load aws eks kubernetes runtime definition config by name or config file var awsEksKubernetesRuntimeDefinitionConfig config.AwsEksKubernetesRuntimeDefinitionConfig if describeAwsEksKubernetesRuntimeDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeAwsEksKubernetesRuntimeDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsEksKubernetesRuntimeDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsEksKubernetesRuntimeDefinitionConfig = config.AwsEksKubernetesRuntimeDefinitionConfig{ AwsEksKubernetesRuntimeDefinition: config.AwsEksKubernetesRuntimeDefinitionValues{ Name: describeAwsEksKubernetesRuntimeDefinitionName, }, } } awsEksKubernetesRuntimeDefinition, err := client.GetAwsEksKubernetesRuntimeDefinitionByName( apiClient, apiEndpoint, awsEksKubernetesRuntimeDefinitionConfig.AwsEksKubernetesRuntimeDefinition.Name, ) if err != nil { cli.Error("failed to retrieve aws eks kubernetes runtime definition details", err) os.Exit(1) } if describeAwsEksKubernetesRuntimeDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( awsEksKubernetesRuntimeDefinition, describeAwsEksKubernetesRuntimeDefinitionField, ) if err != nil { cli.Error("failed to get field value from aws eks kubernetes runtime definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(awsEksKubernetesRuntimeDefinition, describeAwsEksKubernetesRuntimeDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeAwsEksKubernetesRuntimeDefinitionOutput { case "plain": if err := outputDescribeAwsEksKubernetesRuntimeDefinitionCmd( awsEksKubernetesRuntimeDefinition, &awsEksKubernetesRuntimeDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe aws eks kubernetes runtime definition", err) os.Exit(1) } case "json": redactedAwsEksKubernetesRuntimeDefinition := encryption.RedactEncryptedValues(awsEksKubernetesRuntimeDefinition) awsEksKubernetesRuntimeDefinitionJson, err := json.MarshalIndent(redactedAwsEksKubernetesRuntimeDefinition, "", " ") if err != nil { cli.Error("failed to marshal aws eks kubernetes runtime definition into JSON", err) os.Exit(1) } fmt.Println(string(awsEksKubernetesRuntimeDefinitionJson)) case "yaml": redactedAwsEksKubernetesRuntimeDefinition := encryption.RedactEncryptedValues(awsEksKubernetesRuntimeDefinition) awsEksKubernetesRuntimeDefinitionJson, err := json.MarshalIndent(redactedAwsEksKubernetesRuntimeDefinition, "", " ") if err != nil { cli.Error("failed to marshal aws eks kubernetes runtime definition into JSON", err) os.Exit(1) } awsEksKubernetesRuntimeDefinitionYaml, err := ghodss_yaml.JSONToYAML(awsEksKubernetesRuntimeDefinitionJson) if err != nil { cli.Error("failed to convert aws eks kubernetes runtime definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(awsEksKubernetesRuntimeDefinitionYaml)) } }, Short: "Describe a aws eks kubernetes runtime definition", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime-definition", }
DescribeAwsEksKubernetesRuntimeDefinitionCmd representes the aws-eks-kubernetes-runtime-definition command
var DescribeAwsEksKubernetesRuntimeInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a aws eks kubernetes runtime instance\n tptctl describe aws-eks-kubernetes-runtime-instance -n some-aws-eks-kubernetes-runtime-instance\n\n # Get JSON output for a aws eks kubernetes runtime instance\n tptctl describe aws-eks-kubernetes-runtime-instance -n some-aws-eks-kubernetes-runtime-instance -o json\n\n # Get the value of the Name field for a aws eks kubernetes runtime instance\n tptctl describe aws-eks-kubernetes-runtime-instance -n some-aws-eks-kubernetes-runtime-instance -f Name ", Long: "Describe a aws eks kubernetes runtime instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeAwsEksKubernetesRuntimeInstanceConfigPath, describeAwsEksKubernetesRuntimeInstanceName, "aws eks kubernetes runtime instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeAwsEksKubernetesRuntimeInstanceOutput, "aws eks kubernetes runtime instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load aws eks kubernetes runtime instance config by name or config file var awsEksKubernetesRuntimeInstanceConfig config.AwsEksKubernetesRuntimeInstanceConfig if describeAwsEksKubernetesRuntimeInstanceConfigPath != "" { configContent, err := os.ReadFile(describeAwsEksKubernetesRuntimeInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsEksKubernetesRuntimeInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsEksKubernetesRuntimeInstanceConfig = config.AwsEksKubernetesRuntimeInstanceConfig{ AwsEksKubernetesRuntimeInstance: config.AwsEksKubernetesRuntimeInstanceValues{ Name: describeAwsEksKubernetesRuntimeInstanceName, }, } } awsEksKubernetesRuntimeInstance, err := client.GetAwsEksKubernetesRuntimeInstanceByName( apiClient, apiEndpoint, awsEksKubernetesRuntimeInstanceConfig.AwsEksKubernetesRuntimeInstance.Name, ) if err != nil { cli.Error("failed to retrieve aws eks kubernetes runtime instance details", err) os.Exit(1) } if describeAwsEksKubernetesRuntimeInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( awsEksKubernetesRuntimeInstance, describeAwsEksKubernetesRuntimeInstanceField, ) if err != nil { cli.Error("failed to get field value from aws eks kubernetes runtime instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(awsEksKubernetesRuntimeInstance, describeAwsEksKubernetesRuntimeInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeAwsEksKubernetesRuntimeInstanceOutput { case "plain": if err := outputDescribeAwsEksKubernetesRuntimeInstanceCmd( awsEksKubernetesRuntimeInstance, &awsEksKubernetesRuntimeInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe aws eks kubernetes runtime instance", err) os.Exit(1) } case "json": redactedAwsEksKubernetesRuntimeInstance := encryption.RedactEncryptedValues(awsEksKubernetesRuntimeInstance) awsEksKubernetesRuntimeInstanceJson, err := json.MarshalIndent(redactedAwsEksKubernetesRuntimeInstance, "", " ") if err != nil { cli.Error("failed to marshal aws eks kubernetes runtime instance into JSON", err) os.Exit(1) } fmt.Println(string(awsEksKubernetesRuntimeInstanceJson)) case "yaml": redactedAwsEksKubernetesRuntimeInstance := encryption.RedactEncryptedValues(awsEksKubernetesRuntimeInstance) awsEksKubernetesRuntimeInstanceJson, err := json.MarshalIndent(redactedAwsEksKubernetesRuntimeInstance, "", " ") if err != nil { cli.Error("failed to marshal aws eks kubernetes runtime instance into JSON", err) os.Exit(1) } awsEksKubernetesRuntimeInstanceYaml, err := ghodss_yaml.JSONToYAML(awsEksKubernetesRuntimeInstanceJson) if err != nil { cli.Error("failed to convert aws eks kubernetes runtime instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(awsEksKubernetesRuntimeInstanceYaml)) } }, Short: "Describe a aws eks kubernetes runtime instance", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime-instance", }
DescribeAwsEksKubernetesRuntimeInstanceCmd representes the aws-eks-kubernetes-runtime-instance command
var DescribeAwsObjectStorageBucketDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a aws object storage bucket definition\n tptctl describe aws-object-storage-bucket-definition -n some-aws-object-storage-bucket-definition\n\n # Get JSON output for a aws object storage bucket definition\n tptctl describe aws-object-storage-bucket-definition -n some-aws-object-storage-bucket-definition -o json\n\n # Get the value of the Name field for a aws object storage bucket definition\n tptctl describe aws-object-storage-bucket-definition -n some-aws-object-storage-bucket-definition -f Name ", Long: "Describe a aws object storage bucket definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeAwsObjectStorageBucketDefinitionConfigPath, describeAwsObjectStorageBucketDefinitionName, "aws object storage bucket definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeAwsObjectStorageBucketDefinitionOutput, "aws object storage bucket definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load aws object storage bucket definition config by name or config file var awsObjectStorageBucketDefinitionConfig config.AwsObjectStorageBucketDefinitionConfig if describeAwsObjectStorageBucketDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeAwsObjectStorageBucketDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsObjectStorageBucketDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsObjectStorageBucketDefinitionConfig = config.AwsObjectStorageBucketDefinitionConfig{ AwsObjectStorageBucketDefinition: config.AwsObjectStorageBucketDefinitionValues{ Name: describeAwsObjectStorageBucketDefinitionName, }, } } awsObjectStorageBucketDefinition, err := client.GetAwsObjectStorageBucketDefinitionByName( apiClient, apiEndpoint, awsObjectStorageBucketDefinitionConfig.AwsObjectStorageBucketDefinition.Name, ) if err != nil { cli.Error("failed to retrieve aws object storage bucket definition details", err) os.Exit(1) } if describeAwsObjectStorageBucketDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( awsObjectStorageBucketDefinition, describeAwsObjectStorageBucketDefinitionField, ) if err != nil { cli.Error("failed to get field value from aws object storage bucket definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(awsObjectStorageBucketDefinition, describeAwsObjectStorageBucketDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeAwsObjectStorageBucketDefinitionOutput { case "plain": if err := outputDescribeAwsObjectStorageBucketDefinitionCmd( awsObjectStorageBucketDefinition, &awsObjectStorageBucketDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe aws object storage bucket definition", err) os.Exit(1) } case "json": redactedAwsObjectStorageBucketDefinition := encryption.RedactEncryptedValues(awsObjectStorageBucketDefinition) awsObjectStorageBucketDefinitionJson, err := json.MarshalIndent(redactedAwsObjectStorageBucketDefinition, "", " ") if err != nil { cli.Error("failed to marshal aws object storage bucket definition into JSON", err) os.Exit(1) } fmt.Println(string(awsObjectStorageBucketDefinitionJson)) case "yaml": redactedAwsObjectStorageBucketDefinition := encryption.RedactEncryptedValues(awsObjectStorageBucketDefinition) awsObjectStorageBucketDefinitionJson, err := json.MarshalIndent(redactedAwsObjectStorageBucketDefinition, "", " ") if err != nil { cli.Error("failed to marshal aws object storage bucket definition into JSON", err) os.Exit(1) } awsObjectStorageBucketDefinitionYaml, err := ghodss_yaml.JSONToYAML(awsObjectStorageBucketDefinitionJson) if err != nil { cli.Error("failed to convert aws object storage bucket definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(awsObjectStorageBucketDefinitionYaml)) } }, Short: "Describe a aws object storage bucket definition", SilenceUsage: true, Use: "aws-object-storage-bucket-definition", }
DescribeAwsObjectStorageBucketDefinitionCmd representes the aws-object-storage-bucket-definition command
var DescribeAwsObjectStorageBucketInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a aws object storage bucket instance\n tptctl describe aws-object-storage-bucket-instance -n some-aws-object-storage-bucket-instance\n\n # Get JSON output for a aws object storage bucket instance\n tptctl describe aws-object-storage-bucket-instance -n some-aws-object-storage-bucket-instance -o json\n\n # Get the value of the Name field for a aws object storage bucket instance\n tptctl describe aws-object-storage-bucket-instance -n some-aws-object-storage-bucket-instance -f Name ", Long: "Describe a aws object storage bucket instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeAwsObjectStorageBucketInstanceConfigPath, describeAwsObjectStorageBucketInstanceName, "aws object storage bucket instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeAwsObjectStorageBucketInstanceOutput, "aws object storage bucket instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load aws object storage bucket instance config by name or config file var awsObjectStorageBucketInstanceConfig config.AwsObjectStorageBucketInstanceConfig if describeAwsObjectStorageBucketInstanceConfigPath != "" { configContent, err := os.ReadFile(describeAwsObjectStorageBucketInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsObjectStorageBucketInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsObjectStorageBucketInstanceConfig = config.AwsObjectStorageBucketInstanceConfig{ AwsObjectStorageBucketInstance: config.AwsObjectStorageBucketInstanceValues{ Name: describeAwsObjectStorageBucketInstanceName, }, } } awsObjectStorageBucketInstance, err := client.GetAwsObjectStorageBucketInstanceByName( apiClient, apiEndpoint, awsObjectStorageBucketInstanceConfig.AwsObjectStorageBucketInstance.Name, ) if err != nil { cli.Error("failed to retrieve aws object storage bucket instance details", err) os.Exit(1) } if describeAwsObjectStorageBucketInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( awsObjectStorageBucketInstance, describeAwsObjectStorageBucketInstanceField, ) if err != nil { cli.Error("failed to get field value from aws object storage bucket instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(awsObjectStorageBucketInstance, describeAwsObjectStorageBucketInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeAwsObjectStorageBucketInstanceOutput { case "plain": if err := outputDescribeAwsObjectStorageBucketInstanceCmd( awsObjectStorageBucketInstance, &awsObjectStorageBucketInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe aws object storage bucket instance", err) os.Exit(1) } case "json": redactedAwsObjectStorageBucketInstance := encryption.RedactEncryptedValues(awsObjectStorageBucketInstance) awsObjectStorageBucketInstanceJson, err := json.MarshalIndent(redactedAwsObjectStorageBucketInstance, "", " ") if err != nil { cli.Error("failed to marshal aws object storage bucket instance into JSON", err) os.Exit(1) } fmt.Println(string(awsObjectStorageBucketInstanceJson)) case "yaml": redactedAwsObjectStorageBucketInstance := encryption.RedactEncryptedValues(awsObjectStorageBucketInstance) awsObjectStorageBucketInstanceJson, err := json.MarshalIndent(redactedAwsObjectStorageBucketInstance, "", " ") if err != nil { cli.Error("failed to marshal aws object storage bucket instance into JSON", err) os.Exit(1) } awsObjectStorageBucketInstanceYaml, err := ghodss_yaml.JSONToYAML(awsObjectStorageBucketInstanceJson) if err != nil { cli.Error("failed to convert aws object storage bucket instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(awsObjectStorageBucketInstanceYaml)) } }, Short: "Describe a aws object storage bucket instance", SilenceUsage: true, Use: "aws-object-storage-bucket-instance", }
DescribeAwsObjectStorageBucketInstanceCmd representes the aws-object-storage-bucket-instance command
var DescribeAwsRelationalDatabaseDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a aws relational database definition\n tptctl describe aws-relational-database-definition -n some-aws-relational-database-definition\n\n # Get JSON output for a aws relational database definition\n tptctl describe aws-relational-database-definition -n some-aws-relational-database-definition -o json\n\n # Get the value of the Name field for a aws relational database definition\n tptctl describe aws-relational-database-definition -n some-aws-relational-database-definition -f Name ", Long: "Describe a aws relational database definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeAwsRelationalDatabaseDefinitionConfigPath, describeAwsRelationalDatabaseDefinitionName, "aws relational database definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeAwsRelationalDatabaseDefinitionOutput, "aws relational database definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load aws relational database definition config by name or config file var awsRelationalDatabaseDefinitionConfig config.AwsRelationalDatabaseDefinitionConfig if describeAwsRelationalDatabaseDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeAwsRelationalDatabaseDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsRelationalDatabaseDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsRelationalDatabaseDefinitionConfig = config.AwsRelationalDatabaseDefinitionConfig{ AwsRelationalDatabaseDefinition: config.AwsRelationalDatabaseDefinitionValues{ Name: describeAwsRelationalDatabaseDefinitionName, }, } } awsRelationalDatabaseDefinition, err := client.GetAwsRelationalDatabaseDefinitionByName( apiClient, apiEndpoint, awsRelationalDatabaseDefinitionConfig.AwsRelationalDatabaseDefinition.Name, ) if err != nil { cli.Error("failed to retrieve aws relational database definition details", err) os.Exit(1) } if describeAwsRelationalDatabaseDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( awsRelationalDatabaseDefinition, describeAwsRelationalDatabaseDefinitionField, ) if err != nil { cli.Error("failed to get field value from aws relational database definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(awsRelationalDatabaseDefinition, describeAwsRelationalDatabaseDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeAwsRelationalDatabaseDefinitionOutput { case "plain": if err := outputDescribeAwsRelationalDatabaseDefinitionCmd( awsRelationalDatabaseDefinition, &awsRelationalDatabaseDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe aws relational database definition", err) os.Exit(1) } case "json": redactedAwsRelationalDatabaseDefinition := encryption.RedactEncryptedValues(awsRelationalDatabaseDefinition) awsRelationalDatabaseDefinitionJson, err := json.MarshalIndent(redactedAwsRelationalDatabaseDefinition, "", " ") if err != nil { cli.Error("failed to marshal aws relational database definition into JSON", err) os.Exit(1) } fmt.Println(string(awsRelationalDatabaseDefinitionJson)) case "yaml": redactedAwsRelationalDatabaseDefinition := encryption.RedactEncryptedValues(awsRelationalDatabaseDefinition) awsRelationalDatabaseDefinitionJson, err := json.MarshalIndent(redactedAwsRelationalDatabaseDefinition, "", " ") if err != nil { cli.Error("failed to marshal aws relational database definition into JSON", err) os.Exit(1) } awsRelationalDatabaseDefinitionYaml, err := ghodss_yaml.JSONToYAML(awsRelationalDatabaseDefinitionJson) if err != nil { cli.Error("failed to convert aws relational database definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(awsRelationalDatabaseDefinitionYaml)) } }, Short: "Describe a aws relational database definition", SilenceUsage: true, Use: "aws-relational-database-definition", }
DescribeAwsRelationalDatabaseDefinitionCmd representes the aws-relational-database-definition command
var DescribeAwsRelationalDatabaseInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a aws relational database instance\n tptctl describe aws-relational-database-instance -n some-aws-relational-database-instance\n\n # Get JSON output for a aws relational database instance\n tptctl describe aws-relational-database-instance -n some-aws-relational-database-instance -o json\n\n # Get the value of the Name field for a aws relational database instance\n tptctl describe aws-relational-database-instance -n some-aws-relational-database-instance -f Name ", Long: "Describe a aws relational database instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeAwsRelationalDatabaseInstanceConfigPath, describeAwsRelationalDatabaseInstanceName, "aws relational database instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeAwsRelationalDatabaseInstanceOutput, "aws relational database instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load aws relational database instance config by name or config file var awsRelationalDatabaseInstanceConfig config.AwsRelationalDatabaseInstanceConfig if describeAwsRelationalDatabaseInstanceConfigPath != "" { configContent, err := os.ReadFile(describeAwsRelationalDatabaseInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &awsRelationalDatabaseInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { awsRelationalDatabaseInstanceConfig = config.AwsRelationalDatabaseInstanceConfig{ AwsRelationalDatabaseInstance: config.AwsRelationalDatabaseInstanceValues{ Name: describeAwsRelationalDatabaseInstanceName, }, } } awsRelationalDatabaseInstance, err := client.GetAwsRelationalDatabaseInstanceByName( apiClient, apiEndpoint, awsRelationalDatabaseInstanceConfig.AwsRelationalDatabaseInstance.Name, ) if err != nil { cli.Error("failed to retrieve aws relational database instance details", err) os.Exit(1) } if describeAwsRelationalDatabaseInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( awsRelationalDatabaseInstance, describeAwsRelationalDatabaseInstanceField, ) if err != nil { cli.Error("failed to get field value from aws relational database instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(awsRelationalDatabaseInstance, describeAwsRelationalDatabaseInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeAwsRelationalDatabaseInstanceOutput { case "plain": if err := outputDescribeAwsRelationalDatabaseInstanceCmd( awsRelationalDatabaseInstance, &awsRelationalDatabaseInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe aws relational database instance", err) os.Exit(1) } case "json": redactedAwsRelationalDatabaseInstance := encryption.RedactEncryptedValues(awsRelationalDatabaseInstance) awsRelationalDatabaseInstanceJson, err := json.MarshalIndent(redactedAwsRelationalDatabaseInstance, "", " ") if err != nil { cli.Error("failed to marshal aws relational database instance into JSON", err) os.Exit(1) } fmt.Println(string(awsRelationalDatabaseInstanceJson)) case "yaml": redactedAwsRelationalDatabaseInstance := encryption.RedactEncryptedValues(awsRelationalDatabaseInstance) awsRelationalDatabaseInstanceJson, err := json.MarshalIndent(redactedAwsRelationalDatabaseInstance, "", " ") if err != nil { cli.Error("failed to marshal aws relational database instance into JSON", err) os.Exit(1) } awsRelationalDatabaseInstanceYaml, err := ghodss_yaml.JSONToYAML(awsRelationalDatabaseInstanceJson) if err != nil { cli.Error("failed to convert aws relational database instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(awsRelationalDatabaseInstanceYaml)) } }, Short: "Describe a aws relational database instance", SilenceUsage: true, Use: "aws-relational-database-instance", }
DescribeAwsRelationalDatabaseInstanceCmd representes the aws-relational-database-instance command
var DescribeCmd = &cobra.Command{
Use: "describe",
Short: "Describe a Threeport object",
Long: `Describe a Threeport object.
The describe command does nothing by itself. Use one of the avilable subcommands
to describe different objects from the system.`,
}
DescribeCmd represents the describe command
var DescribeControlPlaneDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a control plane definition\n tptctl describe control-plane-definition -n some-control-plane-definition\n\n # Get JSON output for a control plane definition\n tptctl describe control-plane-definition -n some-control-plane-definition -o json\n\n # Get the value of the Name field for a control plane definition\n tptctl describe control-plane-definition -n some-control-plane-definition -f Name ", Long: "Describe a control plane definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeControlPlaneDefinitionConfigPath, describeControlPlaneDefinitionName, "control plane definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeControlPlaneDefinitionOutput, "control plane definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load control plane definition config by name or config file var controlPlaneDefinitionConfig config.ControlPlaneDefinitionConfig if describeControlPlaneDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeControlPlaneDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &controlPlaneDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { controlPlaneDefinitionConfig = config.ControlPlaneDefinitionConfig{ ControlPlaneDefinition: config.ControlPlaneDefinitionValues{ Name: describeControlPlaneDefinitionName, }, } } controlPlaneDefinition, err := client.GetControlPlaneDefinitionByName( apiClient, apiEndpoint, controlPlaneDefinitionConfig.ControlPlaneDefinition.Name, ) if err != nil { cli.Error("failed to retrieve control plane definition details", err) os.Exit(1) } if describeControlPlaneDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( controlPlaneDefinition, describeControlPlaneDefinitionField, ) if err != nil { cli.Error("failed to get field value from control plane definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(controlPlaneDefinition, describeControlPlaneDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeControlPlaneDefinitionOutput { case "plain": if err := outputDescribeControlPlaneDefinitionCmd( controlPlaneDefinition, &controlPlaneDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe control plane definition", err) os.Exit(1) } case "json": redactedControlPlaneDefinition := encryption.RedactEncryptedValues(controlPlaneDefinition) controlPlaneDefinitionJson, err := json.MarshalIndent(redactedControlPlaneDefinition, "", " ") if err != nil { cli.Error("failed to marshal control plane definition into JSON", err) os.Exit(1) } fmt.Println(string(controlPlaneDefinitionJson)) case "yaml": redactedControlPlaneDefinition := encryption.RedactEncryptedValues(controlPlaneDefinition) controlPlaneDefinitionJson, err := json.MarshalIndent(redactedControlPlaneDefinition, "", " ") if err != nil { cli.Error("failed to marshal control plane definition into JSON", err) os.Exit(1) } controlPlaneDefinitionYaml, err := ghodss_yaml.JSONToYAML(controlPlaneDefinitionJson) if err != nil { cli.Error("failed to convert control plane definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(controlPlaneDefinitionYaml)) } }, Short: "Describe a control plane definition", SilenceUsage: true, Use: "control-plane-definition", }
DescribeControlPlaneDefinitionCmd representes the control-plane-definition command
var DescribeControlPlaneInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a control plane instance\n tptctl describe control-plane-instance -n some-control-plane-instance\n\n # Get JSON output for a control plane instance\n tptctl describe control-plane-instance -n some-control-plane-instance -o json\n\n # Get the value of the Name field for a control plane instance\n tptctl describe control-plane-instance -n some-control-plane-instance -f Name ", Long: "Describe a control plane instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeControlPlaneInstanceConfigPath, describeControlPlaneInstanceName, "control plane instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeControlPlaneInstanceOutput, "control plane instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load control plane instance config by name or config file var controlPlaneInstanceConfig config.ControlPlaneInstanceConfig if describeControlPlaneInstanceConfigPath != "" { configContent, err := os.ReadFile(describeControlPlaneInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &controlPlaneInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { controlPlaneInstanceConfig = config.ControlPlaneInstanceConfig{ ControlPlaneInstance: config.ControlPlaneInstanceValues{ Name: describeControlPlaneInstanceName, }, } } controlPlaneInstance, err := client.GetControlPlaneInstanceByName( apiClient, apiEndpoint, controlPlaneInstanceConfig.ControlPlaneInstance.Name, ) if err != nil { cli.Error("failed to retrieve control plane instance details", err) os.Exit(1) } if describeControlPlaneInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( controlPlaneInstance, describeControlPlaneInstanceField, ) if err != nil { cli.Error("failed to get field value from control plane instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(controlPlaneInstance, describeControlPlaneInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeControlPlaneInstanceOutput { case "plain": if err := outputDescribeControlPlaneInstanceCmd( controlPlaneInstance, &controlPlaneInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe control plane instance", err) os.Exit(1) } case "json": redactedControlPlaneInstance := encryption.RedactEncryptedValues(controlPlaneInstance) controlPlaneInstanceJson, err := json.MarshalIndent(redactedControlPlaneInstance, "", " ") if err != nil { cli.Error("failed to marshal control plane instance into JSON", err) os.Exit(1) } fmt.Println(string(controlPlaneInstanceJson)) case "yaml": redactedControlPlaneInstance := encryption.RedactEncryptedValues(controlPlaneInstance) controlPlaneInstanceJson, err := json.MarshalIndent(redactedControlPlaneInstance, "", " ") if err != nil { cli.Error("failed to marshal control plane instance into JSON", err) os.Exit(1) } controlPlaneInstanceYaml, err := ghodss_yaml.JSONToYAML(controlPlaneInstanceJson) if err != nil { cli.Error("failed to convert control plane instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(controlPlaneInstanceYaml)) } }, Short: "Describe a control plane instance", SilenceUsage: true, Use: "control-plane-instance", }
DescribeControlPlaneInstanceCmd representes the control-plane-instance command
var DescribeDomainNameDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a domain name definition\n tptctl describe domain-name-definition -n some-domain-name-definition\n\n # Get JSON output for a domain name definition\n tptctl describe domain-name-definition -n some-domain-name-definition -o json\n\n # Get the value of the Name field for a domain name definition\n tptctl describe domain-name-definition -n some-domain-name-definition -f Name ", Long: "Describe a domain name definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeDomainNameDefinitionConfigPath, describeDomainNameDefinitionName, "domain name definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeDomainNameDefinitionOutput, "domain name definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load domain name definition config by name or config file var domainNameDefinitionConfig config.DomainNameDefinitionConfig if describeDomainNameDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeDomainNameDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &domainNameDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { domainNameDefinitionConfig = config.DomainNameDefinitionConfig{ DomainNameDefinition: config.DomainNameDefinitionValues{ Name: describeDomainNameDefinitionName, }, } } domainNameDefinition, err := client.GetDomainNameDefinitionByName( apiClient, apiEndpoint, domainNameDefinitionConfig.DomainNameDefinition.Name, ) if err != nil { cli.Error("failed to retrieve domain name definition details", err) os.Exit(1) } if describeDomainNameDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( domainNameDefinition, describeDomainNameDefinitionField, ) if err != nil { cli.Error("failed to get field value from domain name definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(domainNameDefinition, describeDomainNameDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeDomainNameDefinitionOutput { case "plain": if err := outputDescribeDomainNameDefinitionCmd( domainNameDefinition, &domainNameDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe domain name definition", err) os.Exit(1) } case "json": redactedDomainNameDefinition := encryption.RedactEncryptedValues(domainNameDefinition) domainNameDefinitionJson, err := json.MarshalIndent(redactedDomainNameDefinition, "", " ") if err != nil { cli.Error("failed to marshal domain name definition into JSON", err) os.Exit(1) } fmt.Println(string(domainNameDefinitionJson)) case "yaml": redactedDomainNameDefinition := encryption.RedactEncryptedValues(domainNameDefinition) domainNameDefinitionJson, err := json.MarshalIndent(redactedDomainNameDefinition, "", " ") if err != nil { cli.Error("failed to marshal domain name definition into JSON", err) os.Exit(1) } domainNameDefinitionYaml, err := ghodss_yaml.JSONToYAML(domainNameDefinitionJson) if err != nil { cli.Error("failed to convert domain name definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(domainNameDefinitionYaml)) } }, Short: "Describe a domain name definition", SilenceUsage: true, Use: "domain-name-definition", }
DescribeDomainNameDefinitionCmd representes the domain-name-definition command
var DescribeDomainNameInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a domain name instance\n tptctl describe domain-name-instance -n some-domain-name-instance\n\n # Get JSON output for a domain name instance\n tptctl describe domain-name-instance -n some-domain-name-instance -o json\n\n # Get the value of the Name field for a domain name instance\n tptctl describe domain-name-instance -n some-domain-name-instance -f Name ", Long: "Describe a domain name instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeDomainNameInstanceConfigPath, describeDomainNameInstanceName, "domain name instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeDomainNameInstanceOutput, "domain name instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load domain name instance config by name or config file var domainNameInstanceConfig config.DomainNameInstanceConfig if describeDomainNameInstanceConfigPath != "" { configContent, err := os.ReadFile(describeDomainNameInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &domainNameInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { domainNameInstanceConfig = config.DomainNameInstanceConfig{ DomainNameInstance: config.DomainNameInstanceValues{ Name: describeDomainNameInstanceName, }, } } domainNameInstance, err := client.GetDomainNameInstanceByName( apiClient, apiEndpoint, domainNameInstanceConfig.DomainNameInstance.Name, ) if err != nil { cli.Error("failed to retrieve domain name instance details", err) os.Exit(1) } if describeDomainNameInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( domainNameInstance, describeDomainNameInstanceField, ) if err != nil { cli.Error("failed to get field value from domain name instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(domainNameInstance, describeDomainNameInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeDomainNameInstanceOutput { case "plain": if err := outputDescribeDomainNameInstanceCmd( domainNameInstance, &domainNameInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe domain name instance", err) os.Exit(1) } case "json": redactedDomainNameInstance := encryption.RedactEncryptedValues(domainNameInstance) domainNameInstanceJson, err := json.MarshalIndent(redactedDomainNameInstance, "", " ") if err != nil { cli.Error("failed to marshal domain name instance into JSON", err) os.Exit(1) } fmt.Println(string(domainNameInstanceJson)) case "yaml": redactedDomainNameInstance := encryption.RedactEncryptedValues(domainNameInstance) domainNameInstanceJson, err := json.MarshalIndent(redactedDomainNameInstance, "", " ") if err != nil { cli.Error("failed to marshal domain name instance into JSON", err) os.Exit(1) } domainNameInstanceYaml, err := ghodss_yaml.JSONToYAML(domainNameInstanceJson) if err != nil { cli.Error("failed to convert domain name instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(domainNameInstanceYaml)) } }, Short: "Describe a domain name instance", SilenceUsage: true, Use: "domain-name-instance", }
DescribeDomainNameInstanceCmd representes the domain-name-instance command
var DescribeGatewayDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a gateway definition\n tptctl describe gateway-definition -n some-gateway-definition\n\n # Get JSON output for a gateway definition\n tptctl describe gateway-definition -n some-gateway-definition -o json\n\n # Get the value of the Name field for a gateway definition\n tptctl describe gateway-definition -n some-gateway-definition -f Name ", Long: "Describe a gateway definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeGatewayDefinitionConfigPath, describeGatewayDefinitionName, "gateway definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeGatewayDefinitionOutput, "gateway definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load gateway definition config by name or config file var gatewayDefinitionConfig config.GatewayDefinitionConfig if describeGatewayDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeGatewayDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &gatewayDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { gatewayDefinitionConfig = config.GatewayDefinitionConfig{ GatewayDefinition: config.GatewayDefinitionValues{ Name: describeGatewayDefinitionName, }, } } gatewayDefinition, err := client.GetGatewayDefinitionByName( apiClient, apiEndpoint, gatewayDefinitionConfig.GatewayDefinition.Name, ) if err != nil { cli.Error("failed to retrieve gateway definition details", err) os.Exit(1) } if describeGatewayDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( gatewayDefinition, describeGatewayDefinitionField, ) if err != nil { cli.Error("failed to get field value from gateway definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(gatewayDefinition, describeGatewayDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeGatewayDefinitionOutput { case "plain": if err := outputDescribeGatewayDefinitionCmd( gatewayDefinition, &gatewayDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe gateway definition", err) os.Exit(1) } case "json": redactedGatewayDefinition := encryption.RedactEncryptedValues(gatewayDefinition) gatewayDefinitionJson, err := json.MarshalIndent(redactedGatewayDefinition, "", " ") if err != nil { cli.Error("failed to marshal gateway definition into JSON", err) os.Exit(1) } fmt.Println(string(gatewayDefinitionJson)) case "yaml": redactedGatewayDefinition := encryption.RedactEncryptedValues(gatewayDefinition) gatewayDefinitionJson, err := json.MarshalIndent(redactedGatewayDefinition, "", " ") if err != nil { cli.Error("failed to marshal gateway definition into JSON", err) os.Exit(1) } gatewayDefinitionYaml, err := ghodss_yaml.JSONToYAML(gatewayDefinitionJson) if err != nil { cli.Error("failed to convert gateway definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(gatewayDefinitionYaml)) } }, Short: "Describe a gateway definition", SilenceUsage: true, Use: "gateway-definition", }
DescribeGatewayDefinitionCmd representes the gateway-definition command
var DescribeGatewayInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a gateway instance\n tptctl describe gateway-instance -n some-gateway-instance\n\n # Get JSON output for a gateway instance\n tptctl describe gateway-instance -n some-gateway-instance -o json\n\n # Get the value of the Name field for a gateway instance\n tptctl describe gateway-instance -n some-gateway-instance -f Name ", Long: "Describe a gateway instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeGatewayInstanceConfigPath, describeGatewayInstanceName, "gateway instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeGatewayInstanceOutput, "gateway instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load gateway instance config by name or config file var gatewayInstanceConfig config.GatewayInstanceConfig if describeGatewayInstanceConfigPath != "" { configContent, err := os.ReadFile(describeGatewayInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &gatewayInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { gatewayInstanceConfig = config.GatewayInstanceConfig{ GatewayInstance: config.GatewayInstanceValues{ Name: describeGatewayInstanceName, }, } } gatewayInstance, err := client.GetGatewayInstanceByName( apiClient, apiEndpoint, gatewayInstanceConfig.GatewayInstance.Name, ) if err != nil { cli.Error("failed to retrieve gateway instance details", err) os.Exit(1) } if describeGatewayInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( gatewayInstance, describeGatewayInstanceField, ) if err != nil { cli.Error("failed to get field value from gateway instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(gatewayInstance, describeGatewayInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeGatewayInstanceOutput { case "plain": if err := outputDescribeGatewayInstanceCmd( gatewayInstance, &gatewayInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe gateway instance", err) os.Exit(1) } case "json": redactedGatewayInstance := encryption.RedactEncryptedValues(gatewayInstance) gatewayInstanceJson, err := json.MarshalIndent(redactedGatewayInstance, "", " ") if err != nil { cli.Error("failed to marshal gateway instance into JSON", err) os.Exit(1) } fmt.Println(string(gatewayInstanceJson)) case "yaml": redactedGatewayInstance := encryption.RedactEncryptedValues(gatewayInstance) gatewayInstanceJson, err := json.MarshalIndent(redactedGatewayInstance, "", " ") if err != nil { cli.Error("failed to marshal gateway instance into JSON", err) os.Exit(1) } gatewayInstanceYaml, err := ghodss_yaml.JSONToYAML(gatewayInstanceJson) if err != nil { cli.Error("failed to convert gateway instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(gatewayInstanceYaml)) } }, Short: "Describe a gateway instance", SilenceUsage: true, Use: "gateway-instance", }
DescribeGatewayInstanceCmd representes the gateway-instance command
var DescribeHelmWorkloadDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a helm workload definition\n tptctl describe helm-workload-definition -n some-helm-workload-definition\n\n # Get JSON output for a helm workload definition\n tptctl describe helm-workload-definition -n some-helm-workload-definition -o json\n\n # Get the value of the Name field for a helm workload definition\n tptctl describe helm-workload-definition -n some-helm-workload-definition -f Name ", Long: "Describe a helm workload definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeHelmWorkloadDefinitionConfigPath, describeHelmWorkloadDefinitionName, "helm workload definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeHelmWorkloadDefinitionOutput, "helm workload definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load helm workload definition config by name or config file var helmWorkloadDefinitionConfig config.HelmWorkloadDefinitionConfig if describeHelmWorkloadDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeHelmWorkloadDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &helmWorkloadDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { helmWorkloadDefinitionConfig = config.HelmWorkloadDefinitionConfig{ HelmWorkloadDefinition: config.HelmWorkloadDefinitionValues{ Name: describeHelmWorkloadDefinitionName, }, } } helmWorkloadDefinition, err := client.GetHelmWorkloadDefinitionByName( apiClient, apiEndpoint, helmWorkloadDefinitionConfig.HelmWorkloadDefinition.Name, ) if err != nil { cli.Error("failed to retrieve helm workload definition details", err) os.Exit(1) } if describeHelmWorkloadDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( helmWorkloadDefinition, describeHelmWorkloadDefinitionField, ) if err != nil { cli.Error("failed to get field value from helm workload definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(helmWorkloadDefinition, describeHelmWorkloadDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeHelmWorkloadDefinitionOutput { case "plain": if err := outputDescribeHelmWorkloadDefinitionCmd( helmWorkloadDefinition, &helmWorkloadDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe helm workload definition", err) os.Exit(1) } case "json": redactedHelmWorkloadDefinition := encryption.RedactEncryptedValues(helmWorkloadDefinition) helmWorkloadDefinitionJson, err := json.MarshalIndent(redactedHelmWorkloadDefinition, "", " ") if err != nil { cli.Error("failed to marshal helm workload definition into JSON", err) os.Exit(1) } fmt.Println(string(helmWorkloadDefinitionJson)) case "yaml": redactedHelmWorkloadDefinition := encryption.RedactEncryptedValues(helmWorkloadDefinition) helmWorkloadDefinitionJson, err := json.MarshalIndent(redactedHelmWorkloadDefinition, "", " ") if err != nil { cli.Error("failed to marshal helm workload definition into JSON", err) os.Exit(1) } helmWorkloadDefinitionYaml, err := ghodss_yaml.JSONToYAML(helmWorkloadDefinitionJson) if err != nil { cli.Error("failed to convert helm workload definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(helmWorkloadDefinitionYaml)) } }, Short: "Describe a helm workload definition", SilenceUsage: true, Use: "helm-workload-definition", }
DescribeHelmWorkloadDefinitionCmd representes the helm-workload-definition command
var DescribeHelmWorkloadInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a helm workload instance\n tptctl describe helm-workload-instance -n some-helm-workload-instance\n\n # Get JSON output for a helm workload instance\n tptctl describe helm-workload-instance -n some-helm-workload-instance -o json\n\n # Get the value of the Name field for a helm workload instance\n tptctl describe helm-workload-instance -n some-helm-workload-instance -f Name ", Long: "Describe a helm workload instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeHelmWorkloadInstanceConfigPath, describeHelmWorkloadInstanceName, "helm workload instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeHelmWorkloadInstanceOutput, "helm workload instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load helm workload instance config by name or config file var helmWorkloadInstanceConfig config.HelmWorkloadInstanceConfig if describeHelmWorkloadInstanceConfigPath != "" { configContent, err := os.ReadFile(describeHelmWorkloadInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &helmWorkloadInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { helmWorkloadInstanceConfig = config.HelmWorkloadInstanceConfig{ HelmWorkloadInstance: config.HelmWorkloadInstanceValues{ Name: describeHelmWorkloadInstanceName, }, } } helmWorkloadInstance, err := client.GetHelmWorkloadInstanceByName( apiClient, apiEndpoint, helmWorkloadInstanceConfig.HelmWorkloadInstance.Name, ) if err != nil { cli.Error("failed to retrieve helm workload instance details", err) os.Exit(1) } if describeHelmWorkloadInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( helmWorkloadInstance, describeHelmWorkloadInstanceField, ) if err != nil { cli.Error("failed to get field value from helm workload instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(helmWorkloadInstance, describeHelmWorkloadInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeHelmWorkloadInstanceOutput { case "plain": if err := outputDescribeHelmWorkloadInstanceCmd( helmWorkloadInstance, &helmWorkloadInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe helm workload instance", err) os.Exit(1) } case "json": redactedHelmWorkloadInstance := encryption.RedactEncryptedValues(helmWorkloadInstance) helmWorkloadInstanceJson, err := json.MarshalIndent(redactedHelmWorkloadInstance, "", " ") if err != nil { cli.Error("failed to marshal helm workload instance into JSON", err) os.Exit(1) } fmt.Println(string(helmWorkloadInstanceJson)) case "yaml": redactedHelmWorkloadInstance := encryption.RedactEncryptedValues(helmWorkloadInstance) helmWorkloadInstanceJson, err := json.MarshalIndent(redactedHelmWorkloadInstance, "", " ") if err != nil { cli.Error("failed to marshal helm workload instance into JSON", err) os.Exit(1) } helmWorkloadInstanceYaml, err := ghodss_yaml.JSONToYAML(helmWorkloadInstanceJson) if err != nil { cli.Error("failed to convert helm workload instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(helmWorkloadInstanceYaml)) } }, Short: "Describe a helm workload instance", SilenceUsage: true, Use: "helm-workload-instance", }
DescribeHelmWorkloadInstanceCmd representes the helm-workload-instance command
var DescribeKubernetesRuntimeDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a kubernetes runtime definition\n tptctl describe kubernetes-runtime-definition -n some-kubernetes-runtime-definition\n\n # Get JSON output for a kubernetes runtime definition\n tptctl describe kubernetes-runtime-definition -n some-kubernetes-runtime-definition -o json\n\n # Get the value of the Name field for a kubernetes runtime definition\n tptctl describe kubernetes-runtime-definition -n some-kubernetes-runtime-definition -f Name ", Long: "Describe a kubernetes runtime definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeKubernetesRuntimeDefinitionConfigPath, describeKubernetesRuntimeDefinitionName, "kubernetes runtime definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeKubernetesRuntimeDefinitionOutput, "kubernetes runtime definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load kubernetes runtime definition config by name or config file var kubernetesRuntimeDefinitionConfig config.KubernetesRuntimeDefinitionConfig if describeKubernetesRuntimeDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeKubernetesRuntimeDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &kubernetesRuntimeDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { kubernetesRuntimeDefinitionConfig = config.KubernetesRuntimeDefinitionConfig{ KubernetesRuntimeDefinition: config.KubernetesRuntimeDefinitionValues{ Name: describeKubernetesRuntimeDefinitionName, }, } } kubernetesRuntimeDefinition, err := client.GetKubernetesRuntimeDefinitionByName( apiClient, apiEndpoint, kubernetesRuntimeDefinitionConfig.KubernetesRuntimeDefinition.Name, ) if err != nil { cli.Error("failed to retrieve kubernetes runtime definition details", err) os.Exit(1) } if describeKubernetesRuntimeDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( kubernetesRuntimeDefinition, describeKubernetesRuntimeDefinitionField, ) if err != nil { cli.Error("failed to get field value from kubernetes runtime definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(kubernetesRuntimeDefinition, describeKubernetesRuntimeDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeKubernetesRuntimeDefinitionOutput { case "plain": if err := outputDescribeKubernetesRuntimeDefinitionCmd( kubernetesRuntimeDefinition, &kubernetesRuntimeDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe kubernetes runtime definition", err) os.Exit(1) } case "json": redactedKubernetesRuntimeDefinition := encryption.RedactEncryptedValues(kubernetesRuntimeDefinition) kubernetesRuntimeDefinitionJson, err := json.MarshalIndent(redactedKubernetesRuntimeDefinition, "", " ") if err != nil { cli.Error("failed to marshal kubernetes runtime definition into JSON", err) os.Exit(1) } fmt.Println(string(kubernetesRuntimeDefinitionJson)) case "yaml": redactedKubernetesRuntimeDefinition := encryption.RedactEncryptedValues(kubernetesRuntimeDefinition) kubernetesRuntimeDefinitionJson, err := json.MarshalIndent(redactedKubernetesRuntimeDefinition, "", " ") if err != nil { cli.Error("failed to marshal kubernetes runtime definition into JSON", err) os.Exit(1) } kubernetesRuntimeDefinitionYaml, err := ghodss_yaml.JSONToYAML(kubernetesRuntimeDefinitionJson) if err != nil { cli.Error("failed to convert kubernetes runtime definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(kubernetesRuntimeDefinitionYaml)) } }, Short: "Describe a kubernetes runtime definition", SilenceUsage: true, Use: "kubernetes-runtime-definition", }
DescribeKubernetesRuntimeDefinitionCmd representes the kubernetes-runtime-definition command
var DescribeKubernetesRuntimeInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a kubernetes runtime instance\n tptctl describe kubernetes-runtime-instance -n some-kubernetes-runtime-instance\n\n # Get JSON output for a kubernetes runtime instance\n tptctl describe kubernetes-runtime-instance -n some-kubernetes-runtime-instance -o json\n\n # Get the value of the Name field for a kubernetes runtime instance\n tptctl describe kubernetes-runtime-instance -n some-kubernetes-runtime-instance -f Name ", Long: "Describe a kubernetes runtime instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeKubernetesRuntimeInstanceConfigPath, describeKubernetesRuntimeInstanceName, "kubernetes runtime instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeKubernetesRuntimeInstanceOutput, "kubernetes runtime instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load kubernetes runtime instance config by name or config file var kubernetesRuntimeInstanceConfig config.KubernetesRuntimeInstanceConfig if describeKubernetesRuntimeInstanceConfigPath != "" { configContent, err := os.ReadFile(describeKubernetesRuntimeInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &kubernetesRuntimeInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { kubernetesRuntimeInstanceConfig = config.KubernetesRuntimeInstanceConfig{ KubernetesRuntimeInstance: config.KubernetesRuntimeInstanceValues{ Name: describeKubernetesRuntimeInstanceName, }, } } kubernetesRuntimeInstance, err := client.GetKubernetesRuntimeInstanceByName( apiClient, apiEndpoint, kubernetesRuntimeInstanceConfig.KubernetesRuntimeInstance.Name, ) if err != nil { cli.Error("failed to retrieve kubernetes runtime instance details", err) os.Exit(1) } if describeKubernetesRuntimeInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( kubernetesRuntimeInstance, describeKubernetesRuntimeInstanceField, ) if err != nil { cli.Error("failed to get field value from kubernetes runtime instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(kubernetesRuntimeInstance, describeKubernetesRuntimeInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeKubernetesRuntimeInstanceOutput { case "plain": if err := outputDescribeKubernetesRuntimeInstanceCmd( kubernetesRuntimeInstance, &kubernetesRuntimeInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe kubernetes runtime instance", err) os.Exit(1) } case "json": redactedKubernetesRuntimeInstance := encryption.RedactEncryptedValues(kubernetesRuntimeInstance) kubernetesRuntimeInstanceJson, err := json.MarshalIndent(redactedKubernetesRuntimeInstance, "", " ") if err != nil { cli.Error("failed to marshal kubernetes runtime instance into JSON", err) os.Exit(1) } fmt.Println(string(kubernetesRuntimeInstanceJson)) case "yaml": redactedKubernetesRuntimeInstance := encryption.RedactEncryptedValues(kubernetesRuntimeInstance) kubernetesRuntimeInstanceJson, err := json.MarshalIndent(redactedKubernetesRuntimeInstance, "", " ") if err != nil { cli.Error("failed to marshal kubernetes runtime instance into JSON", err) os.Exit(1) } kubernetesRuntimeInstanceYaml, err := ghodss_yaml.JSONToYAML(kubernetesRuntimeInstanceJson) if err != nil { cli.Error("failed to convert kubernetes runtime instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(kubernetesRuntimeInstanceYaml)) } }, Short: "Describe a kubernetes runtime instance", SilenceUsage: true, Use: "kubernetes-runtime-instance", }
DescribeKubernetesRuntimeInstanceCmd representes the kubernetes-runtime-instance command
var DescribeObservabilityStackDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a observability stack definition\n tptctl describe observability-stack-definition -n some-observability-stack-definition\n\n # Get JSON output for a observability stack definition\n tptctl describe observability-stack-definition -n some-observability-stack-definition -o json\n\n # Get the value of the Name field for a observability stack definition\n tptctl describe observability-stack-definition -n some-observability-stack-definition -f Name ", Long: "Describe a observability stack definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeObservabilityStackDefinitionConfigPath, describeObservabilityStackDefinitionName, "observability stack definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeObservabilityStackDefinitionOutput, "observability stack definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load observability stack definition config by name or config file var observabilityStackDefinitionConfig config.ObservabilityStackDefinitionConfig if describeObservabilityStackDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeObservabilityStackDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &observabilityStackDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { observabilityStackDefinitionConfig = config.ObservabilityStackDefinitionConfig{ ObservabilityStackDefinition: config.ObservabilityStackDefinitionValues{ Name: describeObservabilityStackDefinitionName, }, } } observabilityStackDefinition, err := client.GetObservabilityStackDefinitionByName( apiClient, apiEndpoint, observabilityStackDefinitionConfig.ObservabilityStackDefinition.Name, ) if err != nil { cli.Error("failed to retrieve observability stack definition details", err) os.Exit(1) } if describeObservabilityStackDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( observabilityStackDefinition, describeObservabilityStackDefinitionField, ) if err != nil { cli.Error("failed to get field value from observability stack definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(observabilityStackDefinition, describeObservabilityStackDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeObservabilityStackDefinitionOutput { case "plain": if err := outputDescribeObservabilityStackDefinitionCmd( observabilityStackDefinition, &observabilityStackDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe observability stack definition", err) os.Exit(1) } case "json": redactedObservabilityStackDefinition := encryption.RedactEncryptedValues(observabilityStackDefinition) observabilityStackDefinitionJson, err := json.MarshalIndent(redactedObservabilityStackDefinition, "", " ") if err != nil { cli.Error("failed to marshal observability stack definition into JSON", err) os.Exit(1) } fmt.Println(string(observabilityStackDefinitionJson)) case "yaml": redactedObservabilityStackDefinition := encryption.RedactEncryptedValues(observabilityStackDefinition) observabilityStackDefinitionJson, err := json.MarshalIndent(redactedObservabilityStackDefinition, "", " ") if err != nil { cli.Error("failed to marshal observability stack definition into JSON", err) os.Exit(1) } observabilityStackDefinitionYaml, err := ghodss_yaml.JSONToYAML(observabilityStackDefinitionJson) if err != nil { cli.Error("failed to convert observability stack definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(observabilityStackDefinitionYaml)) } }, Short: "Describe a observability stack definition", SilenceUsage: true, Use: "observability-stack-definition", }
DescribeObservabilityStackDefinitionCmd representes the observability-stack-definition command
var DescribeObservabilityStackInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a observability stack instance\n tptctl describe observability-stack-instance -n some-observability-stack-instance\n\n # Get JSON output for a observability stack instance\n tptctl describe observability-stack-instance -n some-observability-stack-instance -o json\n\n # Get the value of the Name field for a observability stack instance\n tptctl describe observability-stack-instance -n some-observability-stack-instance -f Name ", Long: "Describe a observability stack instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeObservabilityStackInstanceConfigPath, describeObservabilityStackInstanceName, "observability stack instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeObservabilityStackInstanceOutput, "observability stack instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load observability stack instance config by name or config file var observabilityStackInstanceConfig config.ObservabilityStackInstanceConfig if describeObservabilityStackInstanceConfigPath != "" { configContent, err := os.ReadFile(describeObservabilityStackInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &observabilityStackInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { observabilityStackInstanceConfig = config.ObservabilityStackInstanceConfig{ ObservabilityStackInstance: config.ObservabilityStackInstanceValues{ Name: describeObservabilityStackInstanceName, }, } } observabilityStackInstance, err := client.GetObservabilityStackInstanceByName( apiClient, apiEndpoint, observabilityStackInstanceConfig.ObservabilityStackInstance.Name, ) if err != nil { cli.Error("failed to retrieve observability stack instance details", err) os.Exit(1) } if describeObservabilityStackInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( observabilityStackInstance, describeObservabilityStackInstanceField, ) if err != nil { cli.Error("failed to get field value from observability stack instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(observabilityStackInstance, describeObservabilityStackInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeObservabilityStackInstanceOutput { case "plain": if err := outputDescribeObservabilityStackInstanceCmd( observabilityStackInstance, &observabilityStackInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe observability stack instance", err) os.Exit(1) } case "json": redactedObservabilityStackInstance := encryption.RedactEncryptedValues(observabilityStackInstance) observabilityStackInstanceJson, err := json.MarshalIndent(redactedObservabilityStackInstance, "", " ") if err != nil { cli.Error("failed to marshal observability stack instance into JSON", err) os.Exit(1) } fmt.Println(string(observabilityStackInstanceJson)) case "yaml": redactedObservabilityStackInstance := encryption.RedactEncryptedValues(observabilityStackInstance) observabilityStackInstanceJson, err := json.MarshalIndent(redactedObservabilityStackInstance, "", " ") if err != nil { cli.Error("failed to marshal observability stack instance into JSON", err) os.Exit(1) } observabilityStackInstanceYaml, err := ghodss_yaml.JSONToYAML(observabilityStackInstanceJson) if err != nil { cli.Error("failed to convert observability stack instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(observabilityStackInstanceYaml)) } }, Short: "Describe a observability stack instance", SilenceUsage: true, Use: "observability-stack-instance", }
DescribeObservabilityStackInstanceCmd representes the observability-stack-instance command
var DescribeSecretDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a secret definition\n tptctl describe secret-definition -n some-secret-definition\n\n # Get JSON output for a secret definition\n tptctl describe secret-definition -n some-secret-definition -o json\n\n # Get the value of the Name field for a secret definition\n tptctl describe secret-definition -n some-secret-definition -f Name ", Long: "Describe a secret definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeSecretDefinitionConfigPath, describeSecretDefinitionName, "secret definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeSecretDefinitionOutput, "secret definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load secret definition config by name or config file var secretDefinitionConfig config.SecretDefinitionConfig if describeSecretDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeSecretDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &secretDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { secretDefinitionConfig = config.SecretDefinitionConfig{ SecretDefinition: config.SecretDefinitionValues{ Name: describeSecretDefinitionName, }, } } secretDefinition, err := client.GetSecretDefinitionByName( apiClient, apiEndpoint, secretDefinitionConfig.SecretDefinition.Name, ) if err != nil { cli.Error("failed to retrieve secret definition details", err) os.Exit(1) } if describeSecretDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( secretDefinition, describeSecretDefinitionField, ) if err != nil { cli.Error("failed to get field value from secret definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(secretDefinition, describeSecretDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeSecretDefinitionOutput { case "plain": if err := outputDescribeSecretDefinitionCmd( secretDefinition, &secretDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe secret definition", err) os.Exit(1) } case "json": redactedSecretDefinition := encryption.RedactEncryptedValues(secretDefinition) secretDefinitionJson, err := json.MarshalIndent(redactedSecretDefinition, "", " ") if err != nil { cli.Error("failed to marshal secret definition into JSON", err) os.Exit(1) } fmt.Println(string(secretDefinitionJson)) case "yaml": redactedSecretDefinition := encryption.RedactEncryptedValues(secretDefinition) secretDefinitionJson, err := json.MarshalIndent(redactedSecretDefinition, "", " ") if err != nil { cli.Error("failed to marshal secret definition into JSON", err) os.Exit(1) } secretDefinitionYaml, err := ghodss_yaml.JSONToYAML(secretDefinitionJson) if err != nil { cli.Error("failed to convert secret definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(secretDefinitionYaml)) } }, Short: "Describe a secret definition", SilenceUsage: true, Use: "secret-definition", }
DescribeSecretDefinitionCmd representes the secret-definition command
var DescribeSecretInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a secret instance\n tptctl describe secret-instance -n some-secret-instance\n\n # Get JSON output for a secret instance\n tptctl describe secret-instance -n some-secret-instance -o json\n\n # Get the value of the Name field for a secret instance\n tptctl describe secret-instance -n some-secret-instance -f Name ", Long: "Describe a secret instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeSecretInstanceConfigPath, describeSecretInstanceName, "secret instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeSecretInstanceOutput, "secret instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load secret instance config by name or config file var secretInstanceConfig config.SecretInstanceConfig if describeSecretInstanceConfigPath != "" { configContent, err := os.ReadFile(describeSecretInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &secretInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { secretInstanceConfig = config.SecretInstanceConfig{ SecretInstance: config.SecretInstanceValues{ Name: describeSecretInstanceName, }, } } secretInstance, err := client.GetSecretInstanceByName( apiClient, apiEndpoint, secretInstanceConfig.SecretInstance.Name, ) if err != nil { cli.Error("failed to retrieve secret instance details", err) os.Exit(1) } if describeSecretInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( secretInstance, describeSecretInstanceField, ) if err != nil { cli.Error("failed to get field value from secret instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(secretInstance, describeSecretInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeSecretInstanceOutput { case "plain": if err := outputDescribeSecretInstanceCmd( secretInstance, &secretInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe secret instance", err) os.Exit(1) } case "json": redactedSecretInstance := encryption.RedactEncryptedValues(secretInstance) secretInstanceJson, err := json.MarshalIndent(redactedSecretInstance, "", " ") if err != nil { cli.Error("failed to marshal secret instance into JSON", err) os.Exit(1) } fmt.Println(string(secretInstanceJson)) case "yaml": redactedSecretInstance := encryption.RedactEncryptedValues(secretInstance) secretInstanceJson, err := json.MarshalIndent(redactedSecretInstance, "", " ") if err != nil { cli.Error("failed to marshal secret instance into JSON", err) os.Exit(1) } secretInstanceYaml, err := ghodss_yaml.JSONToYAML(secretInstanceJson) if err != nil { cli.Error("failed to convert secret instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(secretInstanceYaml)) } }, Short: "Describe a secret instance", SilenceUsage: true, Use: "secret-instance", }
DescribeSecretInstanceCmd representes the secret-instance command
var DescribeTerraformDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a terraform definition\n tptctl describe terraform-definition -n some-terraform-definition\n\n # Get JSON output for a terraform definition\n tptctl describe terraform-definition -n some-terraform-definition -o json\n\n # Get the value of the Name field for a terraform definition\n tptctl describe terraform-definition -n some-terraform-definition -f Name ", Long: "Describe a terraform definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeTerraformDefinitionConfigPath, describeTerraformDefinitionName, "terraform definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeTerraformDefinitionOutput, "terraform definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load terraform definition config by name or config file var terraformDefinitionConfig config.TerraformDefinitionConfig if describeTerraformDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeTerraformDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &terraformDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { terraformDefinitionConfig = config.TerraformDefinitionConfig{ TerraformDefinition: config.TerraformDefinitionValues{ Name: describeTerraformDefinitionName, }, } } terraformDefinition, err := client.GetTerraformDefinitionByName( apiClient, apiEndpoint, terraformDefinitionConfig.TerraformDefinition.Name, ) if err != nil { cli.Error("failed to retrieve terraform definition details", err) os.Exit(1) } if describeTerraformDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( terraformDefinition, describeTerraformDefinitionField, ) if err != nil { cli.Error("failed to get field value from terraform definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(terraformDefinition, describeTerraformDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeTerraformDefinitionOutput { case "plain": if err := outputDescribeTerraformDefinitionCmd( terraformDefinition, &terraformDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe terraform definition", err) os.Exit(1) } case "json": redactedTerraformDefinition := encryption.RedactEncryptedValues(terraformDefinition) terraformDefinitionJson, err := json.MarshalIndent(redactedTerraformDefinition, "", " ") if err != nil { cli.Error("failed to marshal terraform definition into JSON", err) os.Exit(1) } fmt.Println(string(terraformDefinitionJson)) case "yaml": redactedTerraformDefinition := encryption.RedactEncryptedValues(terraformDefinition) terraformDefinitionJson, err := json.MarshalIndent(redactedTerraformDefinition, "", " ") if err != nil { cli.Error("failed to marshal terraform definition into JSON", err) os.Exit(1) } terraformDefinitionYaml, err := ghodss_yaml.JSONToYAML(terraformDefinitionJson) if err != nil { cli.Error("failed to convert terraform definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(terraformDefinitionYaml)) } }, Short: "Describe a terraform definition", SilenceUsage: true, Use: "terraform-definition", }
DescribeTerraformDefinitionCmd representes the terraform-definition command
var DescribeTerraformInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a terraform instance\n tptctl describe terraform-instance -n some-terraform-instance\n\n # Get JSON output for a terraform instance\n tptctl describe terraform-instance -n some-terraform-instance -o json\n\n # Get the value of the Name field for a terraform instance\n tptctl describe terraform-instance -n some-terraform-instance -f Name ", Long: "Describe a terraform instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeTerraformInstanceConfigPath, describeTerraformInstanceName, "terraform instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeTerraformInstanceOutput, "terraform instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load terraform instance config by name or config file var terraformInstanceConfig config.TerraformInstanceConfig if describeTerraformInstanceConfigPath != "" { configContent, err := os.ReadFile(describeTerraformInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &terraformInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { terraformInstanceConfig = config.TerraformInstanceConfig{ TerraformInstance: config.TerraformInstanceValues{ Name: describeTerraformInstanceName, }, } } terraformInstance, err := client.GetTerraformInstanceByName( apiClient, apiEndpoint, terraformInstanceConfig.TerraformInstance.Name, ) if err != nil { cli.Error("failed to retrieve terraform instance details", err) os.Exit(1) } if describeTerraformInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( terraformInstance, describeTerraformInstanceField, ) if err != nil { cli.Error("failed to get field value from terraform instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(terraformInstance, describeTerraformInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeTerraformInstanceOutput { case "plain": if err := outputDescribeTerraformInstanceCmd( terraformInstance, &terraformInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe terraform instance", err) os.Exit(1) } case "json": redactedTerraformInstance := encryption.RedactEncryptedValues(terraformInstance) terraformInstanceJson, err := json.MarshalIndent(redactedTerraformInstance, "", " ") if err != nil { cli.Error("failed to marshal terraform instance into JSON", err) os.Exit(1) } fmt.Println(string(terraformInstanceJson)) case "yaml": redactedTerraformInstance := encryption.RedactEncryptedValues(terraformInstance) terraformInstanceJson, err := json.MarshalIndent(redactedTerraformInstance, "", " ") if err != nil { cli.Error("failed to marshal terraform instance into JSON", err) os.Exit(1) } terraformInstanceYaml, err := ghodss_yaml.JSONToYAML(terraformInstanceJson) if err != nil { cli.Error("failed to convert terraform instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(terraformInstanceYaml)) } }, Short: "Describe a terraform instance", SilenceUsage: true, Use: "terraform-instance", }
DescribeTerraformInstanceCmd representes the terraform-instance command
var DescribeWorkloadDefinitionCmd = &cobra.Command{ Example: " # Get the plain output description for a workload definition\n tptctl describe workload-definition -n some-workload-definition\n\n # Get JSON output for a workload definition\n tptctl describe workload-definition -n some-workload-definition -o json\n\n # Get the value of the Name field for a workload definition\n tptctl describe workload-definition -n some-workload-definition -f Name ", Long: "Describe a workload definition. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeWorkloadDefinitionConfigPath, describeWorkloadDefinitionName, "workload definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeWorkloadDefinitionOutput, "workload definition", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load workload definition config by name or config file var workloadDefinitionConfig config.WorkloadDefinitionConfig if describeWorkloadDefinitionConfigPath != "" { configContent, err := os.ReadFile(describeWorkloadDefinitionConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &workloadDefinitionConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { workloadDefinitionConfig = config.WorkloadDefinitionConfig{ WorkloadDefinition: config.WorkloadDefinitionValues{ Name: describeWorkloadDefinitionName, }, } } workloadDefinition, err := client.GetWorkloadDefinitionByName( apiClient, apiEndpoint, workloadDefinitionConfig.WorkloadDefinition.Name, ) if err != nil { cli.Error("failed to retrieve workload definition details", err) os.Exit(1) } if describeWorkloadDefinitionField != "" { fieldVal, err := util.GetObjectFieldValue( workloadDefinition, describeWorkloadDefinitionField, ) if err != nil { cli.Error("failed to get field value from workload definition", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(workloadDefinition, describeWorkloadDefinitionField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeWorkloadDefinitionOutput { case "plain": if err := outputDescribeWorkloadDefinitionCmd( workloadDefinition, &workloadDefinitionConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe workload definition", err) os.Exit(1) } case "json": redactedWorkloadDefinition := encryption.RedactEncryptedValues(workloadDefinition) workloadDefinitionJson, err := json.MarshalIndent(redactedWorkloadDefinition, "", " ") if err != nil { cli.Error("failed to marshal workload definition into JSON", err) os.Exit(1) } fmt.Println(string(workloadDefinitionJson)) case "yaml": redactedWorkloadDefinition := encryption.RedactEncryptedValues(workloadDefinition) workloadDefinitionJson, err := json.MarshalIndent(redactedWorkloadDefinition, "", " ") if err != nil { cli.Error("failed to marshal workload definition into JSON", err) os.Exit(1) } workloadDefinitionYaml, err := ghodss_yaml.JSONToYAML(workloadDefinitionJson) if err != nil { cli.Error("failed to convert workload definition JSON to YAML", err) os.Exit(1) } fmt.Println(string(workloadDefinitionYaml)) } }, Short: "Describe a workload definition", SilenceUsage: true, Use: "workload-definition", }
DescribeWorkloadDefinitionCmd representes the workload-definition command
var DescribeWorkloadInstanceCmd = &cobra.Command{ Example: " # Get the plain output description for a workload instance\n tptctl describe workload-instance -n some-workload-instance\n\n # Get JSON output for a workload instance\n tptctl describe workload-instance -n some-workload-instance -o json\n\n # Get the value of the Name field for a workload instance\n tptctl describe workload-instance -n some-workload-instance -f Name ", Long: "Describe a workload instance. This command can give you a plain output description, output all fields in JSON or YAML format, or provide the value of any specific field.\n\nNote: any values that are encrypted in the database will be redacted unless the field is specifically requested with the --field flag.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, _ := getClientContext(cmd) if err := cli.ValidateConfigNameFlags( describeWorkloadInstanceConfigPath, describeWorkloadInstanceName, "workload instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } if err := cli.ValidateDescribeOutputFlag( describeWorkloadInstanceOutput, "workload instance", ); err != nil { cli.Error("flag validation failed", err) os.Exit(1) } // load workload instance config by name or config file var workloadInstanceConfig config.WorkloadInstanceConfig if describeWorkloadInstanceConfigPath != "" { configContent, err := os.ReadFile(describeWorkloadInstanceConfigPath) if err != nil { cli.Error("failed to read config file", err) os.Exit(1) } if err := yaml.UnmarshalStrict(configContent, &workloadInstanceConfig); err != nil { cli.Error("failed to unmarshal config file yaml content", err) os.Exit(1) } } else { workloadInstanceConfig = config.WorkloadInstanceConfig{ WorkloadInstance: config.WorkloadInstanceValues{ Name: describeWorkloadInstanceName, }, } } workloadInstance, err := client_v1.GetWorkloadInstanceByName( apiClient, apiEndpoint, workloadInstanceConfig.WorkloadInstance.Name, ) if err != nil { cli.Error("failed to retrieve workload instance details", err) os.Exit(1) } if describeWorkloadInstanceField != "" { fieldVal, err := util.GetObjectFieldValue( workloadInstance, describeWorkloadInstanceField, ) if err != nil { cli.Error("failed to get field value from workload instance", err) os.Exit(1) } encrypted, err := encryption.IsEncryptedField(workloadInstance, describeWorkloadInstanceField) if err != nil { cli.Error("", err) } if encrypted { threeportConfig, requestedControlPlane, err := config.GetThreeportConfig(cliArgs.ControlPlaneName) if err != nil { cli.Error("failed to get threeport config: %w", err) os.Exit(1) } encryptionKey, err := threeportConfig.GetThreeportEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to get encryption key from threeport config: %w", err) os.Exit(1) } decryptedVal, err := encryption.Decrypt(encryptionKey, fieldVal.String()) if err != nil { cli.Error("failed to decrypt value: %w", err) } fmt.Println(decryptedVal) os.Exit(0) } else { fmt.Println(fieldVal.Interface()) os.Exit(0) } } switch describeWorkloadInstanceOutput { case "plain": if err := outputDescribeWorkloadInstanceCmd( workloadInstance, &workloadInstanceConfig, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to describe workload instance", err) os.Exit(1) } case "json": redactedWorkloadInstance := encryption.RedactEncryptedValues(workloadInstance) workloadInstanceJson, err := json.MarshalIndent(redactedWorkloadInstance, "", " ") if err != nil { cli.Error("failed to marshal workload instance into JSON", err) os.Exit(1) } fmt.Println(string(workloadInstanceJson)) case "yaml": redactedWorkloadInstance := encryption.RedactEncryptedValues(workloadInstance) workloadInstanceJson, err := json.MarshalIndent(redactedWorkloadInstance, "", " ") if err != nil { cli.Error("failed to marshal workload instance into JSON", err) os.Exit(1) } workloadInstanceYaml, err := ghodss_yaml.JSONToYAML(workloadInstanceJson) if err != nil { cli.Error("failed to convert workload instance JSON to YAML", err) os.Exit(1) } fmt.Println(string(workloadInstanceYaml)) } }, Short: "Describe a workload instance", SilenceUsage: true, Use: "workload-instance", }
DescribeWorkloadInstanceCmd representes the workload-instance command
var DownCmd = &cobra.Command{ Use: "down", Example: "tptctl down --name my-threeport", Short: "Spin down a deployment of the Threeport control plane", Long: `Spin down a deployment of the Threeport control plane.`, SilenceUsage: true, Run: func(cmd *cobra.Command, args []string) { cpi, err := cliArgs.CreateInstaller() if err != nil { cli.Error("failed to create threeport control plane installer", err) os.Exit(1) } err = cli.DeleteGenesisControlPlane(cpi) if err != nil { cli.Error("failed to delete threeport control plane", err) os.Exit(1) } }, }
DownCmd represents the delete threeports
var GetAwsAccountsCmd = &cobra.Command{ Example: " tptctl get aws-accounts", Long: "Get aws accounts from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsAccounts, err := client.GetAwsAccounts(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws accounts", err) os.Exit(1) } if len(*awsAccounts) == 0 { cli.Info(fmt.Sprintf( "No aws accounts currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsAccountsCmd( awsAccounts, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get aws accounts from the system", SilenceUsage: true, Use: "aws-accounts", }
GetAwsAccountsCmd represents the aws-account command
var GetAwsEksKubernetesRuntimeDefinitionsCmd = &cobra.Command{ Example: " tptctl get aws-eks-kubernetes-runtime-definitions", Long: "Get aws eks kubernetes runtime definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsEksKubernetesRuntimeDefinitions, err := client.GetAwsEksKubernetesRuntimeDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws eks kubernetes runtime definitions", err) os.Exit(1) } if len(*awsEksKubernetesRuntimeDefinitions) == 0 { cli.Info(fmt.Sprintf( "No aws eks kubernetes runtime definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsEksKubernetesRuntimeDefinitionsCmd( awsEksKubernetesRuntimeDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get aws eks kubernetes runtime definitions from the system", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime-definitions", }
GetAwsEksKubernetesRuntimeDefinitionsCmd represents the aws-eks-kubernetes-runtime-definition command
var GetAwsEksKubernetesRuntimeInstancesCmd = &cobra.Command{ Example: " tptctl get aws-eks-kubernetes-runtime-instances", Long: "Get aws eks kubernetes runtime instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsEksKubernetesRuntimeInstances, err := client.GetAwsEksKubernetesRuntimeInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws eks kubernetes runtime instances", err) os.Exit(1) } if len(*awsEksKubernetesRuntimeInstances) == 0 { cli.Info(fmt.Sprintf( "No aws eks kubernetes runtime instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsEksKubernetesRuntimeInstancesCmd( awsEksKubernetesRuntimeInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get aws eks kubernetes runtime instances from the system", SilenceUsage: true, Use: "aws-eks-kubernetes-runtime-instances", }
GetAwsEksKubernetesRuntimeInstancesCmd represents the aws-eks-kubernetes-runtime-instance command
var GetAwsEksKubernetesRuntimesCmd = &cobra.Command{ Example: " tptctl get aws-eks-kubernetes-runtimes", Long: "Get aws eks kubernetes runtimes from the system.\n\nA aws eks kubernetes runtime is a simple abstraction of aws eks kubernetes runtime definitions and aws eks kubernetes runtime instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsEksKubernetesRuntimeInstances, err := client.GetAwsEksKubernetesRuntimeInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws eks kubernetes runtime instances", err) os.Exit(1) } if len(*awsEksKubernetesRuntimeInstances) == 0 { cli.Info(fmt.Sprintf( "No aws eks kubernetes runtime instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsEksKubernetesRuntimesCmd( awsEksKubernetesRuntimeInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get aws eks kubernetes runtimes from the system", SilenceUsage: true, Use: "aws-eks-kubernetes-runtimes", }
GetAwsEksKubernetesRuntimesCmd represents the aws-eks-kubernetes-runtime command
var GetAwsObjectStorageBucketDefinitionsCmd = &cobra.Command{ Example: " tptctl get aws-object-storage-bucket-definitions", Long: "Get aws object storage bucket definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsObjectStorageBucketDefinitions, err := client.GetAwsObjectStorageBucketDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws object storage bucket definitions", err) os.Exit(1) } if len(*awsObjectStorageBucketDefinitions) == 0 { cli.Info(fmt.Sprintf( "No aws object storage bucket definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsObjectStorageBucketDefinitionsCmd( awsObjectStorageBucketDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get aws object storage bucket definitions from the system", SilenceUsage: true, Use: "aws-object-storage-bucket-definitions", }
GetAwsObjectStorageBucketDefinitionsCmd represents the aws-object-storage-bucket-definition command
var GetAwsObjectStorageBucketInstancesCmd = &cobra.Command{ Example: " tptctl get aws-object-storage-bucket-instances", Long: "Get aws object storage bucket instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsObjectStorageBucketInstances, err := client.GetAwsObjectStorageBucketInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws object storage bucket instances", err) os.Exit(1) } if len(*awsObjectStorageBucketInstances) == 0 { cli.Info(fmt.Sprintf( "No aws object storage bucket instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsObjectStorageBucketInstancesCmd( awsObjectStorageBucketInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get aws object storage bucket instances from the system", SilenceUsage: true, Use: "aws-object-storage-bucket-instances", }
GetAwsObjectStorageBucketInstancesCmd represents the aws-object-storage-bucket-instance command
var GetAwsObjectStorageBucketsCmd = &cobra.Command{ Example: " tptctl get aws-object-storage-buckets", Long: "Get aws object storage buckets from the system.\n\nA aws object storage bucket is a simple abstraction of aws object storage bucket definitions and aws object storage bucket instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsObjectStorageBucketInstances, err := client.GetAwsObjectStorageBucketInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws object storage bucket instances", err) os.Exit(1) } if len(*awsObjectStorageBucketInstances) == 0 { cli.Info(fmt.Sprintf( "No aws object storage bucket instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsObjectStorageBucketsCmd( awsObjectStorageBucketInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get aws object storage buckets from the system", SilenceUsage: true, Use: "aws-object-storage-buckets", }
GetAwsObjectStorageBucketsCmd represents the aws-object-storage-bucket command
var GetAwsRelationalDatabaseDefinitionsCmd = &cobra.Command{ Example: " tptctl get aws-relational-database-definitions", Long: "Get aws relational database definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsRelationalDatabaseDefinitions, err := client.GetAwsRelationalDatabaseDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws relational database definitions", err) os.Exit(1) } if len(*awsRelationalDatabaseDefinitions) == 0 { cli.Info(fmt.Sprintf( "No aws relational database definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsRelationalDatabaseDefinitionsCmd( awsRelationalDatabaseDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get aws relational database definitions from the system", SilenceUsage: true, Use: "aws-relational-database-definitions", }
GetAwsRelationalDatabaseDefinitionsCmd represents the aws-relational-database-definition command
var GetAwsRelationalDatabaseInstancesCmd = &cobra.Command{ Example: " tptctl get aws-relational-database-instances", Long: "Get aws relational database instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsRelationalDatabaseInstances, err := client.GetAwsRelationalDatabaseInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws relational database instances", err) os.Exit(1) } if len(*awsRelationalDatabaseInstances) == 0 { cli.Info(fmt.Sprintf( "No aws relational database instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsRelationalDatabaseInstancesCmd( awsRelationalDatabaseInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get aws relational database instances from the system", SilenceUsage: true, Use: "aws-relational-database-instances", }
GetAwsRelationalDatabaseInstancesCmd represents the aws-relational-database-instance command
var GetAwsRelationalDatabasesCmd = &cobra.Command{ Example: " tptctl get aws-relational-databases", Long: "Get aws relational databases from the system.\n\nA aws relational database is a simple abstraction of aws relational database definitions and aws relational database instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) awsRelationalDatabaseInstances, err := client.GetAwsRelationalDatabaseInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve aws relational database instances", err) os.Exit(1) } if len(*awsRelationalDatabaseInstances) == 0 { cli.Info(fmt.Sprintf( "No aws relational database instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetAwsRelationalDatabasesCmd( awsRelationalDatabaseInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get aws relational databases from the system", SilenceUsage: true, Use: "aws-relational-databases", }
GetAwsRelationalDatabasesCmd represents the aws-relational-database command
var GetCmd = &cobra.Command{
Use: "get",
Short: "Get Threeport objects",
Long: `Get Threeport objects.
The get command does nothing by itself. Use one of the avilable subcommands
to get different objects from the system.`,
}
GetCmd represents the get command
var GetControlPlaneDefinitionsCmd = &cobra.Command{ Example: " tptctl get control-plane-definitions", Long: "Get control plane definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) controlPlaneDefinitions, err := client.GetControlPlaneDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve control plane definitions", err) os.Exit(1) } if len(*controlPlaneDefinitions) == 0 { cli.Info(fmt.Sprintf( "No control plane definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetControlPlaneDefinitionsCmd( controlPlaneDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get control plane definitions from the system", SilenceUsage: true, Use: "control-plane-definitions", }
GetControlPlaneDefinitionsCmd represents the control-plane-definition command
var GetControlPlaneInstancesCmd = &cobra.Command{ Example: " tptctl get control-plane-instances", Long: "Get control plane instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) controlPlaneInstances, err := client.GetControlPlaneInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve control plane instances", err) os.Exit(1) } if len(*controlPlaneInstances) == 0 { cli.Info(fmt.Sprintf( "No control plane instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetControlPlaneInstancesCmd( controlPlaneInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get control plane instances from the system", SilenceUsage: true, Use: "control-plane-instances", }
GetControlPlaneInstancesCmd represents the control-plane-instance command
var GetControlPlanesCmd = &cobra.Command{ Example: " tptctl get control-planes", Long: "Get control planes from the system.\n\nA control plane is a simple abstraction of control plane definitions and control plane instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) controlPlaneInstances, err := client.GetControlPlaneInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve control plane instances", err) os.Exit(1) } if len(*controlPlaneInstances) == 0 { cli.Info(fmt.Sprintf( "No control plane instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetControlPlanesCmd( controlPlaneInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get control planes from the system", SilenceUsage: true, Use: "control-planes", }
GetControlPlanesCmd represents the control-plane command
var GetDomainNameDefinitionsCmd = &cobra.Command{ Example: " tptctl get domain-name-definitions", Long: "Get domain name definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) domainNameDefinitions, err := client.GetDomainNameDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve domain name definitions", err) os.Exit(1) } if len(*domainNameDefinitions) == 0 { cli.Info(fmt.Sprintf( "No domain name definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetDomainNameDefinitionsCmd( domainNameDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get domain name definitions from the system", SilenceUsage: true, Use: "domain-name-definitions", }
GetDomainNameDefinitionsCmd represents the domain-name-definition command
var GetDomainNameInstancesCmd = &cobra.Command{ Example: " tptctl get domain-name-instances", Long: "Get domain name instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) domainNameInstances, err := client.GetDomainNameInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve domain name instances", err) os.Exit(1) } if len(*domainNameInstances) == 0 { cli.Info(fmt.Sprintf( "No domain name instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetDomainNameInstancesCmd( domainNameInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get domain name instances from the system", SilenceUsage: true, Use: "domain-name-instances", }
GetDomainNameInstancesCmd represents the domain-name-instance command
var GetDomainNamesCmd = &cobra.Command{ Example: " tptctl get domain-names", Long: "Get domain names from the system.\n\nA domain name is a simple abstraction of domain name definitions and domain name instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) domainNameInstances, err := client.GetDomainNameInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve domain name instances", err) os.Exit(1) } if len(*domainNameInstances) == 0 { cli.Info(fmt.Sprintf( "No domain name instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetDomainNamesCmd( domainNameInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get domain names from the system", SilenceUsage: true, Use: "domain-names", }
GetDomainNamesCmd represents the domain-name command
var GetGatewayDefinitionsCmd = &cobra.Command{ Example: " tptctl get gateway-definitions", Long: "Get gateway definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) gatewayDefinitions, err := client.GetGatewayDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve gateway definitions", err) os.Exit(1) } if len(*gatewayDefinitions) == 0 { cli.Info(fmt.Sprintf( "No gateway definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetGatewayDefinitionsCmd( gatewayDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get gateway definitions from the system", SilenceUsage: true, Use: "gateway-definitions", }
GetGatewayDefinitionsCmd represents the gateway-definition command
var GetGatewayInstancesCmd = &cobra.Command{ Example: " tptctl get gateway-instances", Long: "Get gateway instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) gatewayInstances, err := client.GetGatewayInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve gateway instances", err) os.Exit(1) } if len(*gatewayInstances) == 0 { cli.Info(fmt.Sprintf( "No gateway instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetGatewayInstancesCmd( gatewayInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get gateway instances from the system", SilenceUsage: true, Use: "gateway-instances", }
GetGatewayInstancesCmd represents the gateway-instance command
var GetGatewaysCmd = &cobra.Command{ Example: " tptctl get gateways", Long: "Get gateways from the system.\n\nA gateway is a simple abstraction of gateway definitions and gateway instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) gatewayInstances, err := client.GetGatewayInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve gateway instances", err) os.Exit(1) } if len(*gatewayInstances) == 0 { cli.Info(fmt.Sprintf( "No gateway instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetGatewaysCmd( gatewayInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get gateways from the system", SilenceUsage: true, Use: "gateways", }
GetGatewaysCmd represents the gateway command
var GetHelmWorkloadDefinitionsCmd = &cobra.Command{ Example: " tptctl get helm-workload-definitions", Long: "Get helm workload definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) helmWorkloadDefinitions, err := client.GetHelmWorkloadDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve helm workload definitions", err) os.Exit(1) } if len(*helmWorkloadDefinitions) == 0 { cli.Info(fmt.Sprintf( "No helm workload definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetHelmWorkloadDefinitionsCmd( helmWorkloadDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get helm workload definitions from the system", SilenceUsage: true, Use: "helm-workload-definitions", }
GetHelmWorkloadDefinitionsCmd represents the helm-workload-definition command
var GetHelmWorkloadInstancesCmd = &cobra.Command{ Example: " tptctl get helm-workload-instances", Long: "Get helm workload instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) helmWorkloadInstances, err := client.GetHelmWorkloadInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve helm workload instances", err) os.Exit(1) } if len(*helmWorkloadInstances) == 0 { cli.Info(fmt.Sprintf( "No helm workload instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetHelmWorkloadInstancesCmd( helmWorkloadInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get helm workload instances from the system", SilenceUsage: true, Use: "helm-workload-instances", }
GetHelmWorkloadInstancesCmd represents the helm-workload-instance command
var GetHelmWorkloadsCmd = &cobra.Command{ Example: " tptctl get helm-workloads", Long: "Get helm workloads from the system.\n\nA helm workload is a simple abstraction of helm workload definitions and helm workload instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) helmWorkloadInstances, err := client.GetHelmWorkloadInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve helm workload instances", err) os.Exit(1) } if len(*helmWorkloadInstances) == 0 { cli.Info(fmt.Sprintf( "No helm workload instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetHelmWorkloadsCmd( helmWorkloadInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get helm workloads from the system", SilenceUsage: true, Use: "helm-workloads", }
GetHelmWorkloadsCmd represents the helm-workload command
var GetKubernetesRuntimeDefinitionsCmd = &cobra.Command{ Example: " tptctl get kubernetes-runtime-definitions", Long: "Get kubernetes runtime definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) kubernetesRuntimeDefinitions, err := client.GetKubernetesRuntimeDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve kubernetes runtime definitions", err) os.Exit(1) } if len(*kubernetesRuntimeDefinitions) == 0 { cli.Info(fmt.Sprintf( "No kubernetes runtime definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetKubernetesRuntimeDefinitionsCmd( kubernetesRuntimeDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get kubernetes runtime definitions from the system", SilenceUsage: true, Use: "kubernetes-runtime-definitions", }
GetKubernetesRuntimeDefinitionsCmd represents the kubernetes-runtime-definition command
var GetKubernetesRuntimeInstancesCmd = &cobra.Command{ Example: " tptctl get kubernetes-runtime-instances", Long: "Get kubernetes runtime instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) kubernetesRuntimeInstances, err := client.GetKubernetesRuntimeInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve kubernetes runtime instances", err) os.Exit(1) } if len(*kubernetesRuntimeInstances) == 0 { cli.Info(fmt.Sprintf( "No kubernetes runtime instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetKubernetesRuntimeInstancesCmd( kubernetesRuntimeInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get kubernetes runtime instances from the system", SilenceUsage: true, Use: "kubernetes-runtime-instances", }
GetKubernetesRuntimeInstancesCmd represents the kubernetes-runtime-instance command
var GetKubernetesRuntimesCmd = &cobra.Command{ Example: " tptctl get kubernetes-runtimes", Long: "Get kubernetes runtimes from the system.\n\nA kubernetes runtime is a simple abstraction of kubernetes runtime definitions and kubernetes runtime instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) kubernetesRuntimeInstances, err := client.GetKubernetesRuntimeInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve kubernetes runtime instances", err) os.Exit(1) } if len(*kubernetesRuntimeInstances) == 0 { cli.Info(fmt.Sprintf( "No kubernetes runtime instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetKubernetesRuntimesCmd( kubernetesRuntimeInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get kubernetes runtimes from the system", SilenceUsage: true, Use: "kubernetes-runtimes", }
GetKubernetesRuntimesCmd represents the kubernetes-runtime command
var GetObservabilityStackDefinitionsCmd = &cobra.Command{ Example: " tptctl get observability-stack-definitions", Long: "Get observability stack definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) observabilityStackDefinitions, err := client.GetObservabilityStackDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve observability stack definitions", err) os.Exit(1) } if len(*observabilityStackDefinitions) == 0 { cli.Info(fmt.Sprintf( "No observability stack definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetObservabilityStackDefinitionsCmd( observabilityStackDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get observability stack definitions from the system", SilenceUsage: true, Use: "observability-stack-definitions", }
GetObservabilityStackDefinitionsCmd represents the observability-stack-definition command
var GetObservabilityStackInstancesCmd = &cobra.Command{ Example: " tptctl get observability-stack-instances", Long: "Get observability stack instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) observabilityStackInstances, err := client.GetObservabilityStackInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve observability stack instances", err) os.Exit(1) } if len(*observabilityStackInstances) == 0 { cli.Info(fmt.Sprintf( "No observability stack instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetObservabilityStackInstancesCmd( observabilityStackInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get observability stack instances from the system", SilenceUsage: true, Use: "observability-stack-instances", }
GetObservabilityStackInstancesCmd represents the observability-stack-instance command
var GetObservabilityStacksCmd = &cobra.Command{ Example: " tptctl get observability-stacks", Long: "Get observability stacks from the system.\n\nA observability stack is a simple abstraction of observability stack definitions and observability stack instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) observabilityStackInstances, err := client.GetObservabilityStackInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve observability stack instances", err) os.Exit(1) } if len(*observabilityStackInstances) == 0 { cli.Info(fmt.Sprintf( "No observability stack instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetObservabilityStacksCmd( observabilityStackInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get observability stacks from the system", SilenceUsage: true, Use: "observability-stacks", }
GetObservabilityStacksCmd represents the observability-stack command
var GetSecretDefinitionsCmd = &cobra.Command{ Example: " tptctl get secret-definitions", Long: "Get secret definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) secretDefinitions, err := client.GetSecretDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve secret definitions", err) os.Exit(1) } if len(*secretDefinitions) == 0 { cli.Info(fmt.Sprintf( "No secret definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetSecretDefinitionsCmd( secretDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get secret definitions from the system", SilenceUsage: true, Use: "secret-definitions", }
GetSecretDefinitionsCmd represents the secret-definition command
var GetSecretInstancesCmd = &cobra.Command{ Example: " tptctl get secret-instances", Long: "Get secret instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) secretInstances, err := client.GetSecretInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve secret instances", err) os.Exit(1) } if len(*secretInstances) == 0 { cli.Info(fmt.Sprintf( "No secret instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetSecretInstancesCmd( secretInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get secret instances from the system", SilenceUsage: true, Use: "secret-instances", }
GetSecretInstancesCmd represents the secret-instance command
var GetSecretsCmd = &cobra.Command{ Example: " tptctl get secrets", Long: "Get secrets from the system.\n\nA secret is a simple abstraction of secret definitions and secret instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) secretInstances, err := client.GetSecretInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve secret instances", err) os.Exit(1) } if len(*secretInstances) == 0 { cli.Info(fmt.Sprintf( "No secret instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetSecretsCmd( secretInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get secrets from the system", SilenceUsage: true, Use: "secrets", }
GetSecretsCmd represents the secret command
var GetTerraformDefinitionsCmd = &cobra.Command{ Example: " tptctl get terraform-definitions", Long: "Get terraform definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) terraformDefinitions, err := client.GetTerraformDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve terraform definitions", err) os.Exit(1) } if len(*terraformDefinitions) == 0 { cli.Info(fmt.Sprintf( "No terraform definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetTerraformDefinitionsCmd( terraformDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get terraform definitions from the system", SilenceUsage: true, Use: "terraform-definitions", }
GetTerraformDefinitionsCmd represents the terraform-definition command
var GetTerraformInstancesCmd = &cobra.Command{ Example: " tptctl get terraform-instances", Long: "Get terraform instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) terraformInstances, err := client.GetTerraformInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve terraform instances", err) os.Exit(1) } if len(*terraformInstances) == 0 { cli.Info(fmt.Sprintf( "No terraform instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetTerraformInstancesCmd( terraformInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get terraform instances from the system", SilenceUsage: true, Use: "terraform-instances", }
GetTerraformInstancesCmd represents the terraform-instance command
var GetTerraformsCmd = &cobra.Command{ Example: " tptctl get terraforms", Long: "Get terraforms from the system.\n\nA terraform is a simple abstraction of terraform definitions and terraform instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) terraformInstances, err := client.GetTerraformInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve terraform instances", err) os.Exit(1) } if len(*terraformInstances) == 0 { cli.Info(fmt.Sprintf( "No terraform instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetTerraformsCmd( terraformInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get terraforms from the system", SilenceUsage: true, Use: "terraforms", }
GetTerraformsCmd represents the terraform command
var GetWorkloadDefinitionsCmd = &cobra.Command{ Example: " tptctl get workload-definitions", Long: "Get workload definitions from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) workloadDefinitions, err := client.GetWorkloadDefinitions(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve workload definitions", err) os.Exit(1) } if len(*workloadDefinitions) == 0 { cli.Info(fmt.Sprintf( "No workload definitions currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetWorkloadDefinitionsCmd( workloadDefinitions, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get workload definitions from the system", SilenceUsage: true, Use: "workload-definitions", }
GetWorkloadDefinitionsCmd represents the workload-definition command
var GetWorkloadInstancesCmd = &cobra.Command{ Example: " tptctl get workload-instances", Long: "Get workload instances from the system.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) workloadInstances, err := client_v1.GetWorkloadInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve workload instances", err) os.Exit(1) } if len(*workloadInstances) == 0 { cli.Info(fmt.Sprintf( "No workload instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetWorkloadInstancesCmd( workloadInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output", err) os.Exit(0) } }, Short: "Get workload instances from the system", SilenceUsage: true, Use: "workload-instances", }
GetWorkloadInstancesCmd represents the workload-instance command
var GetWorkloadsCmd = &cobra.Command{ Example: " tptctl get workloads", Long: "Get workloads from the system.\n\nA workload is a simple abstraction of workload definitions and workload instances.\nThis command displays all instances and the definitions used to configure them.", PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, _, apiEndpoint, requestedControlPlane := getClientContext(cmd) workloadInstances, err := client_v1.GetWorkloadInstances(apiClient, apiEndpoint) if err != nil { cli.Error("failed to retrieve workload instances", err) os.Exit(1) } if len(*workloadInstances) == 0 { cli.Info(fmt.Sprintf( "No workload instances currently managed by %s threeport control plane", requestedControlPlane, )) os.Exit(0) } if err := outputGetWorkloadsCmd( workloadInstances, apiClient, apiEndpoint, ); err != nil { cli.Error("failed to produce output: %s", err) os.Exit(0) } }, Short: "Get workloads from the system", SilenceUsage: true, Use: "workloads", }
GetWorkloadsCmd represents the workload command
var UpCmd = &cobra.Command{ Use: "up", Example: "tptctl up --name my-threeport", Short: "Spin up a new deployment of the Threeport control plane", Long: `Spin up a new deployment of the Threeport control plane.`, SilenceUsage: true, PreRun: func(cmd *cobra.Command, args []string) { switch cliArgs.InfraProvider { case v0.KubernetesRuntimeInfraProviderEKS: cmd.MarkFlagRequired("aws-region") } }, Run: func(cmd *cobra.Command, args []string) { if err := cli.ValidateCreateGenesisControlPlaneFlags( cliArgs.ControlPlaneName, cliArgs.InfraProvider, cliArgs.CreateRootDomain, cliArgs.AuthEnabled, ); err != nil { cli.Error("flag validation failed:", err) os.Exit(1) } cpi, err := cliArgs.CreateInstaller() if err != nil { cli.Error("failed to create threeport control plane installer", err) os.Exit(1) } err = cli.CreateGenesisControlPlane(cpi) if err != nil { cli.Error("failed to create threeport control plane", err) if errors.Is(cli.ErrThreeportConfigAlreadyExists, err) { cli.Info("if you wish to overwrite the existing config use --force-overwrite-config flag") cli.Warning("you will lose the ability to connect to the existing threeport control planes if they are still running") } os.Exit(1) } }, }
UpCmd represents the create threeport command
var UpgradeCmd = &cobra.Command{
Use: "upgrade",
Short: "Upgrade Threeport related compoments",
Long: `Upgrade Threeport related aspects.
The upgrade command does nothing by itself. Use one of the avilable subcommands
to upgrade different aspects of the system.`,
}
UpgradeCmd represents the get command
var UpgradeControlPlaneCmd = &cobra.Command{ Use: "control-plane", Example: "tptctl upgrade control-plane --version=v0.5.0", Short: "Upgrades the version of the Threeport control plane", Long: `Upgrades the version of the Threeport control plane. The version should be a valid image tag.`, SilenceUsage: true, PreRun: commandPreRunFunc, Run: func(cmd *cobra.Command, args []string) { apiClient, config, apiEndpoint, requestedControlPlane := getClientContext(cmd) encyptionKey, err := config.GetEncryptionKey(requestedControlPlane) if err != nil { cli.Error("failed to retrieve encryption key for control plane:", err) os.Exit(1) } kubernetesRuntimeInstance, err := client.GetThreeportControlPlaneKubernetesRuntimeInstance( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to retrieve kubernetes runtime instance from threeport API:", err) os.Exit(1) } controlPlaneInstance, err := client.GetSelfControlPlaneInstance( apiClient, apiEndpoint, ) if err != nil { cli.Error("failed to retrieve self control plane instance from threeport API:", err) os.Exit(1) } var dynamicKubeClient dynamic.Interface var mapper *meta.RESTMapper dynamicKubeClient, mapper, err = kube.GetClient( kubernetesRuntimeInstance, false, apiClient, apiEndpoint, encyptionKey, ) if err != nil { cli.Error("failed to get kube client:", err) os.Exit(1) } err = updateDeploymentImageTag(updateImageTag, *controlPlaneInstance.Namespace, dynamicKubeClient, mapper) if err != nil { cli.Error("failed to update threeport deployment image tag", err) os.Exit(1) } cli.Complete(fmt.Sprintf("Succesfully updates all threeport deployments to image: %s", updateImageTag)) }, }
UpCmd represents the create threeport command
Functions ¶
Types ¶
This section is empty.
Source Files ¶
- aws_describe_output.go
- aws_gen.go
- aws_get_output.go
- config.go
- config_aws_cloud_account.go
- config_current_control_plane.go
- config_get_control_planes.go
- control_plane_describe_output.go
- control_plane_gen.go
- control_plane_get_output.go
- create.go
- delete.go
- describe.go
- down.go
- gateway_describe_output.go
- gateway_gen.go
- gateway_get_output.go
- get.go
- helm_workload_describe_output.go
- helm_workload_gen.go
- helm_workload_get_output.go
- kubernetes_runtime_describe_output.go
- kubernetes_runtime_gen.go
- kubernetes_runtime_get_output.go
- observability_describe_output.go
- observability_gen.go
- observability_get_output.go
- root.go
- secret_describe_output.go
- secret_gen.go
- secret_get_output.go
- terraform_describe_output.go
- terraform_gen.go
- terraform_get_output.go
- up.go
- upgrade.go
- upgrade_control_plane.go
- version.go
- workload_describe_output.go
- workload_gen.go
- workload_get_output.go