diff --git a/cmd/createApplication.go b/cmd/createApplication.go index 737fb27..db705c3 100644 --- a/cmd/createApplication.go +++ b/cmd/createApplication.go @@ -24,30 +24,28 @@ import ( "github.com/equinor/radix-cli/generated-client/client/platform" "github.com/equinor/radix-cli/generated-client/models" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) // createApplicationCmd represents the create application command var createApplicationCmd = &cobra.Command{ - Use: "application", - Short: "Create application", - Long: `Creates a Radix application in the cluster - -Example: -rx create application --application your-application-name --repository https://github.com/your-repository --config-branch main --ad-groups abcdef-1234-5678-9aaa-abcdefgf --reader-ad-groups=23456789--9123-4567-8901-23456701 --shared-secret someSecretPhrase12345 --acknowledge-warnings --configuration-item "YOUR PROJECT CONFIG ITEM" --context playground -`, + Use: "application", + Short: "Create application", + Long: "Creates a Radix application in the cluster", + Example: `rx create application --application your-application-name --repository https://github.com/your-repository --config-branch main --ad-groups abcdef-1234-5678-9aaa-abcdefgf --reader-ad-groups=23456789--9123-4567-8901-23456701 --shared-secret someSecretPhrase12345 --acknowledge-warnings --configuration-item "YOUR PROJECT CONFIG ITEM" --context playground`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - repository, _ := cmd.Flags().GetString("repository") - sharedSecret, _ := cmd.Flags().GetString("shared-secret") - configBranch, _ := cmd.Flags().GetString("config-branch") - configFile, _ := cmd.Flags().GetString("config-file") - configurationItem, _ := cmd.Flags().GetString("configuration-item") - acknowledgeWarnings, err := cmd.Flags().GetBool("acknowledge-warnings") + repository, _ := cmd.Flags().GetString(flagnames.Repository) + sharedSecret, _ := cmd.Flags().GetString(flagnames.SharedSecret) + configBranch, _ := cmd.Flags().GetString(flagnames.ConfigBranch) + configFile, _ := cmd.Flags().GetString(flagnames.ConfigFile) + configurationItem, _ := cmd.Flags().GetString(flagnames.ConfigurationItem) + acknowledgeWarnings, err := cmd.Flags().GetBool(flagnames.AcknowledgeWarnings) if err != nil { println(fmt.Sprintf("invalid argument %s: %v", "acknowledge-warnings", err)) return err @@ -57,8 +55,8 @@ rx create application --application your-application-name --repository https://g return errors.New("application name, repository, configuration item and config branch are required fields") } - adGroups, _ := cmd.Flags().GetStringSlice("ad-groups") - readerAdGroups, _ := cmd.Flags().GetStringSlice("reader-ad-groups") + adGroups, _ := cmd.Flags().GetStringSlice(flagnames.AdminADGroups) + readerAdGroups, _ := cmd.Flags().GetStringSlice(flagnames.ReaderADGroups) cmd.SilenceUsage = true @@ -125,14 +123,14 @@ rx create application --application your-application-name --repository https://g func init() { createCmd.AddCommand(createApplicationCmd) - createApplicationCmd.Flags().StringP("application", "a", "", "Name of the application to create") - createApplicationCmd.Flags().StringP("repository", "", "", "Repository path") - createApplicationCmd.Flags().StringP("shared-secret", "", "", "Shared secret for the webhook") - createApplicationCmd.Flags().StringP("config-branch", "", "", "Name of the branch where Radix will read your radixconfig.yaml from") - createApplicationCmd.Flags().StringP("config-file", "", "", "Name of the radix config file. Optional, defaults to radixconfig.yaml") - createApplicationCmd.Flags().StringSliceP("ad-groups", "", []string{}, "Admin groups") - createApplicationCmd.Flags().StringSliceP("reader-ad-groups", "", []string{}, "Reader groups") - createApplicationCmd.Flags().StringP("configuration-item", "", "", "Configuration item") - createApplicationCmd.Flags().Bool("acknowledge-warnings", false, "Acknowledge warnings and proceed") + createApplicationCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application to create") + createApplicationCmd.Flags().StringP(flagnames.Repository, "", "", "Repository path") + createApplicationCmd.Flags().StringP(flagnames.SharedSecret, "", "", "Shared secret for the webhook") + createApplicationCmd.Flags().StringP(flagnames.ConfigBranch, "", "", "Name of the branch where Radix will read your radixconfig.yaml from") + createApplicationCmd.Flags().StringP(flagnames.ConfigFile, "", "", "Name of the radix config file. Optional, defaults to radixconfig.yaml") + createApplicationCmd.Flags().StringSliceP(flagnames.AdminADGroups, "", []string{}, "Admin groups") + createApplicationCmd.Flags().StringSliceP(flagnames.ReaderADGroups, "", []string{}, "Reader groups") + createApplicationCmd.Flags().StringP(flagnames.ConfigurationItem, "", "", "Configuration item") + createApplicationCmd.Flags().Bool(flagnames.AcknowledgeWarnings, false, "Acknowledge warnings and proceed") setContextSpecificPersistentFlags(createApplicationCmd) } diff --git a/cmd/createBuildDeployPipelineJob.go b/cmd/createBuildDeployPipelineJob.go index a65fca2..86a36c5 100644 --- a/cmd/createBuildDeployPipelineJob.go +++ b/cmd/createBuildDeployPipelineJob.go @@ -16,11 +16,13 @@ package cmd import ( "errors" + log "github.com/sirupsen/logrus" "github.com/equinor/radix-cli/generated-client/client/application" "github.com/equinor/radix-cli/generated-client/models" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -30,14 +32,14 @@ var createBuildDeployApplicationCmd = &cobra.Command{ Short: "Will trigger build-deploy of a Radix application", Long: `Triggers build-deploy of Radix application, if branch to environment map exists for the branch in the Radix config`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - branch, _ := cmd.Flags().GetString("branch") - commitID, _ := cmd.Flags().GetString("commitID") - follow, _ := cmd.Flags().GetBool("follow") + branch, _ := cmd.Flags().GetString(flagnames.Branch) + commitID, _ := cmd.Flags().GetString(flagnames.CommitID) + follow, _ := cmd.Flags().GetBool(flagnames.Follow) if appName == nil || *appName == "" || branch == "" { return errors.New("application name and branch are required") @@ -73,9 +75,9 @@ var createBuildDeployApplicationCmd = &cobra.Command{ func init() { createJobCmd.AddCommand(createBuildDeployApplicationCmd) - createBuildDeployApplicationCmd.Flags().StringP("application", "a", "", "Name of the application to build-deploy") - createBuildDeployApplicationCmd.Flags().StringP("branch", "b", "master", "Branch to build-deploy from") - createBuildDeployApplicationCmd.Flags().StringP("commitID", "i", "", "Commit id") - createBuildDeployApplicationCmd.Flags().BoolP("follow", "f", false, "Follow build-deploy") + createBuildDeployApplicationCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application to build-deploy") + createBuildDeployApplicationCmd.Flags().StringP(flagnames.Branch, "b", "master", "Branch to build-deploy from") + createBuildDeployApplicationCmd.Flags().StringP(flagnames.CommitID, "i", "", "Commit id") + createBuildDeployApplicationCmd.Flags().BoolP(flagnames.Follow, "f", false, "Follow build-deploy") setContextSpecificPersistentFlags(createBuildDeployApplicationCmd) } diff --git a/cmd/createDeployPipelineJob.go b/cmd/createDeployPipelineJob.go index c4e4785..6f985c8 100644 --- a/cmd/createDeployPipelineJob.go +++ b/cmd/createDeployPipelineJob.go @@ -24,6 +24,7 @@ import ( "github.com/equinor/radix-cli/generated-client/client/application" "github.com/equinor/radix-cli/generated-client/models" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -47,23 +48,23 @@ Examples: `, RunE: func(cmd *cobra.Command, args []string) error { var errs []error - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { errs = append(errs, err) } - targetEnvironment, err := cmd.Flags().GetString("environment") + targetEnvironment, err := cmd.Flags().GetString(flagnames.Environment) if err != nil { errs = append(errs, err) } - triggeredByUser, err := cmd.Flags().GetString("user") + triggeredByUser, err := cmd.Flags().GetString(flagnames.User) if err != nil { errs = append(errs, err) } - follow, err := cmd.Flags().GetBool("follow") + follow, err := cmd.Flags().GetBool(flagnames.Follow) if err != nil { errs = append(errs, err) } - imageTagNames, err := cmd.Flags().GetStringToString("image-tag-name") + imageTagNames, err := cmd.Flags().GetStringToString(flagnames.ImageTagName) if err != nil { errs = append(errs, err) } @@ -73,7 +74,7 @@ Examples: if appName == nil || *appName == "" || targetEnvironment == "" { return errors.New("application name and target environment are required") } - commitID, _ := cmd.Flags().GetString("commitID") + commitID, _ := cmd.Flags().GetString(flagnames.CommitID) err2 := validateCommitID(commitID) if err2 != nil { return err2 @@ -125,11 +126,10 @@ func validateCommitID(commitID string) error { func init() { createJobCmd.AddCommand(createDeployPipelineJobCmd) - createDeployPipelineJobCmd.Flags().StringP("application", "a", "", "Name of the application to deploy") - createDeployPipelineJobCmd.Flags().StringP("environment", "e", "", "Target environment to deploy in ('prod', 'dev', 'playground')") - createDeployPipelineJobCmd.Flags().StringP("user", "u", "", "The user who triggered the deploy") - createDeployPipelineJobCmd.Flags().StringToStringP("image-tag-name", "t", map[string]string{}, "Image tag name for a component: component-name=tag-name. Multiple pairs can be specified.") - createDeployPipelineJobCmd.Flags().StringP("commitID", "i", "", "An optional 40 character commit id to tag the new pipeline job") - createDeployPipelineJobCmd.Flags().BoolP("follow", "f", false, "Follow deploy") + createDeployPipelineJobCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application to deploy") + createDeployPipelineJobCmd.Flags().StringP(flagnames.User, "u", "", "The user who triggered the deploy") + createDeployPipelineJobCmd.Flags().StringToStringP(flagnames.ImageTagName, "t", map[string]string{}, "Image tag name for a component: component-name=tag-name. Multiple pairs can be specified.") + createDeployPipelineJobCmd.Flags().StringP(flagnames.CommitID, "i", "", "An optional 40 character commit id to tag the new pipeline job") + createDeployPipelineJobCmd.Flags().BoolP(flagnames.Follow, "f", false, "Follow deploy") setContextSpecificPersistentFlags(createDeployPipelineJobCmd) } diff --git a/cmd/createEnvironment.go b/cmd/createEnvironment.go index d3379d8..5c723be 100644 --- a/cmd/createEnvironment.go +++ b/cmd/createEnvironment.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/environment" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -27,12 +29,12 @@ var createEnvironmentCmd = &cobra.Command{ Short: "Create environment", Long: `Creates a Radix environment for the application`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil || appName == nil || *appName == "" { return errors.New("environment name and application name are required fields") @@ -56,7 +58,7 @@ var createEnvironmentCmd = &cobra.Command{ func init() { createCmd.AddCommand(createEnvironmentCmd) - createEnvironmentCmd.Flags().StringP("application", "a", "", "Name of the application namespace") - createEnvironmentCmd.Flags().StringP("environment", "e", "", "Name of the environment to create") + createEnvironmentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") + createEnvironmentCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment to create") setContextSpecificPersistentFlags(createEnvironmentCmd) } diff --git a/cmd/createPromotePipelineJob.go b/cmd/createPromotePipelineJob.go index 63df42f..d2c5766 100644 --- a/cmd/createPromotePipelineJob.go +++ b/cmd/createPromotePipelineJob.go @@ -23,6 +23,7 @@ import ( "github.com/equinor/radix-cli/generated-client/client/application" "github.com/equinor/radix-cli/generated-client/models" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -32,17 +33,17 @@ var createPromotePipelineJobCmd = &cobra.Command{ Short: "Will trigger promote of a Radix application", Long: `Triggers promote of a Radix application deployment`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - useActiveDeployment, _ := cmd.Flags().GetBool("use-active-deployment") - deploymentName, _ := cmd.Flags().GetString("deployment") - fromEnvironment, _ := cmd.Flags().GetString("from-environment") - toEnvironment, _ := cmd.Flags().GetString("to-environment") - triggeredByUser, _ := cmd.Flags().GetString("user") - follow, _ := cmd.Flags().GetBool("follow") + useActiveDeployment, _ := cmd.Flags().GetBool(flagnames.UseActiveDeployment) + deploymentName, _ := cmd.Flags().GetString(flagnames.Deployment) + fromEnvironment, _ := cmd.Flags().GetString(flagnames.FromEnvironment) + toEnvironment, _ := cmd.Flags().GetString(flagnames.ToEnvironment) + triggeredByUser, _ := cmd.Flags().GetString(flagnames.User) + follow, _ := cmd.Flags().GetBool(flagnames.Follow) if !useActiveDeployment && deploymentName == "" { return errors.New("Specifying deployment name or setting use-active-deployment is required") @@ -114,12 +115,12 @@ func getActiveDeploymentName(apiClient *apiclient.Radixapi, appName, envName str func init() { createJobCmd.AddCommand(createPromotePipelineJobCmd) - createPromotePipelineJobCmd.Flags().StringP("application", "a", "", "Name of the application to be promoted") - createPromotePipelineJobCmd.Flags().StringP("deployment", "d", "", "Name of a deployment to be promoted") - createPromotePipelineJobCmd.Flags().StringP("from-environment", "", "", "The deployment source environment") - createPromotePipelineJobCmd.Flags().StringP("to-environment", "", "", "The deployment target environment") - createPromotePipelineJobCmd.Flags().StringP("user", "u", "", "The user who triggered the promote pipeline job") - createPromotePipelineJobCmd.Flags().BoolP("follow", "f", false, "Follow the promote pipeline job log") - createPromotePipelineJobCmd.Flags().BoolP("use-active-deployment", "", false, "Promote the active deployment") + createPromotePipelineJobCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application to be promoted") + createPromotePipelineJobCmd.Flags().StringP(flagnames.Deployment, "d", "", "Name of a deployment to be promoted") + createPromotePipelineJobCmd.Flags().StringP(flagnames.FromEnvironment, "", "", "The deployment source environment") + createPromotePipelineJobCmd.Flags().StringP(flagnames.ToEnvironment, "", "", "The deployment target environment") + createPromotePipelineJobCmd.Flags().StringP(flagnames.User, "u", "", "The user who triggered the promote pipeline job") + createPromotePipelineJobCmd.Flags().BoolP(flagnames.Follow, "f", false, "Follow the promote pipeline job log") + createPromotePipelineJobCmd.Flags().BoolP(flagnames.UseActiveDeployment, "", false, "Promote the active deployment") setContextSpecificPersistentFlags(createPromotePipelineJobCmd) } diff --git a/cmd/deleteApplication.go b/cmd/deleteApplication.go index e9872b2..4a78646 100644 --- a/cmd/deleteApplication.go +++ b/cmd/deleteApplication.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/application" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -27,7 +29,7 @@ var deleteApplicationCmd = &cobra.Command{ Short: "Delete application", Long: `Will delete an application from the cluster`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -53,6 +55,6 @@ var deleteApplicationCmd = &cobra.Command{ func init() { deleteCmd.AddCommand(deleteApplicationCmd) - deleteApplicationCmd.Flags().StringP("application", "a", "", "Name of the application to create") + deleteApplicationCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application to create") setContextSpecificPersistentFlags(deleteApplicationCmd) } diff --git a/cmd/deleteEnvironment.go b/cmd/deleteEnvironment.go index f882b06..7f2cd8e 100644 --- a/cmd/deleteEnvironment.go +++ b/cmd/deleteEnvironment.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/environment" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -27,12 +29,12 @@ var deleteEnvironmentCmd = &cobra.Command{ Short: "delete environment", Long: `deletes an orphaned Radix environment`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil || appName == nil || *appName == "" { return errors.New("environment name and application name are required fields") @@ -56,7 +58,7 @@ var deleteEnvironmentCmd = &cobra.Command{ func init() { deleteCmd.AddCommand(deleteEnvironmentCmd) - deleteEnvironmentCmd.Flags().StringP("application", "a", "", "Name of the application namespace") - deleteEnvironmentCmd.Flags().StringP("environment", "e", "", "Name of the environment to delete") + deleteEnvironmentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application") + deleteEnvironmentCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment to delete") setContextSpecificPersistentFlags(deleteEnvironmentCmd) } diff --git a/cmd/getApplication.go b/cmd/getApplication.go index d7194d5..ad3071b 100644 --- a/cmd/getApplication.go +++ b/cmd/getApplication.go @@ -21,6 +21,7 @@ import ( "github.com/equinor/radix-cli/generated-client/client/application" "github.com/equinor/radix-cli/generated-client/client/platform" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/equinor/radix-cli/pkg/utils/json" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -32,7 +33,7 @@ var getApplicationCmd = &cobra.Command{ Short: "Gets Radix application", Long: `Gets a list of Radix applications or a single application if provided`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -73,6 +74,6 @@ var getApplicationCmd = &cobra.Command{ func init() { getCmd.AddCommand(getApplicationCmd) - getApplicationCmd.Flags().StringP("application", "a", "", "Name of the application") + getApplicationCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application") setContextSpecificPersistentFlags(getApplicationCmd) } diff --git a/cmd/getBranchEnvironment.go b/cmd/getBranchEnvironment.go index bb85a06..2f1bc80 100644 --- a/cmd/getBranchEnvironment.go +++ b/cmd/getBranchEnvironment.go @@ -18,7 +18,7 @@ import ( "errors" "fmt" - "github.com/equinor/radix-cli/pkg/settings" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -28,7 +28,7 @@ var getBranchEnvironmentCmd = &cobra.Command{ Short: "Gets the environment for a given branch", Long: `Gets the environment for a given branch`, RunE: func(cmd *cobra.Command, args []string) error { - fromConfig, _ := cmd.Flags().GetBool(settings.FromConfigOption) + fromConfig, _ := cmd.Flags().GetBool(flagnames.FromConfig) if !fromConfig { return errors.New("config can only come from radixconfig file in current folder") } @@ -38,7 +38,7 @@ var getBranchEnvironmentCmd = &cobra.Command{ return err } - branch, _ := cmd.Flags().GetString("branch") + branch, _ := cmd.Flags().GetString(flagnames.Branch) if branch == "" { return errors.New("`branch` is required") @@ -56,6 +56,6 @@ var getBranchEnvironmentCmd = &cobra.Command{ func init() { getConfigCmd.AddCommand(getBranchEnvironmentCmd) - getBranchEnvironmentCmd.Flags().StringP("branch", "b", "", "Branch of the repository. Should be used together with --from-config to get the environment") + getBranchEnvironmentCmd.Flags().StringP(flagnames.Branch, "b", "", "Branch of the repository. Should be used together with --from-config to get the environment") setContextSpecificPersistentFlags(getBranchEnvironmentCmd) } diff --git a/cmd/getDeployment.go b/cmd/getDeployment.go index e71026a..7947ddb 100644 --- a/cmd/getDeployment.go +++ b/cmd/getDeployment.go @@ -17,9 +17,11 @@ package cmd import ( "errors" "fmt" + apiclient "github.com/equinor/radix-cli/generated-client/client" "github.com/equinor/radix-cli/generated-client/client/application" "github.com/equinor/radix-cli/generated-client/client/environment" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/equinor/radix-cli/pkg/utils/json" "github.com/equinor/radix-cli/generated-client/client/deployment" @@ -44,7 +46,7 @@ Examples: rx get deployment --application radix-test --environment test `, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -52,11 +54,11 @@ Examples: return errors.New("application name is required field") } - deploymentName, err := cmd.Flags().GetString("deployment") + deploymentName, err := cmd.Flags().GetString(flagnames.Deployment) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil { return err } @@ -132,8 +134,8 @@ func getDeploymentForEnvironment(apiClient *apiclient.Radixapi, appName, envName func init() { getCmd.AddCommand(getDeploymentCmd) - getDeploymentCmd.Flags().StringP("application", "a", "", "Name of the application") - getDeploymentCmd.Flags().StringP("deployment", "d", "", "Optional, name of a deployment. It cannot be used together with an option 'environment'.") - getDeploymentCmd.Flags().StringP("environment", "e", "", "Optional, name of the environment. It cannot be used together with an option 'deployment'.") + getDeploymentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application") + getDeploymentCmd.Flags().StringP(flagnames.Deployment, "d", "", "Optional, name of a deployment. It cannot be used together with an option 'environment'.") + getDeploymentCmd.Flags().StringP(flagnames.Environment, "e", "", "Optional, name of the environment. It cannot be used together with an option 'deployment'.") setContextSpecificPersistentFlags(getDeploymentCmd) } diff --git a/cmd/logsEnvironment.go b/cmd/logsEnvironment.go index 9ea5dc2..b704026 100644 --- a/cmd/logsEnvironment.go +++ b/cmd/logsEnvironment.go @@ -20,6 +20,7 @@ import ( apiclient "github.com/equinor/radix-cli/generated-client/client" "github.com/equinor/radix-cli/generated-client/client/environment" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/equinor/radix-cli/pkg/settings" "github.com/spf13/cobra" ) @@ -29,15 +30,13 @@ var logsEnvironmentCmd = &cobra.Command{ Use: "environment", Short: "Gets logs for all components in an environment", Long: `Gets and follows logs for all components in an environment. - + It may take few seconds to get the log. - -Example: - # Get logs for all components in an environment. Log lines from different components have different colors - rx get logs environment --application radix-test --environment dev -`, + `, + Example: `# Get logs for all components in an environment. Log lines from different components have different colors +rx get logs environment --application radix-test --environment dev`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -46,9 +45,9 @@ Example: return errors.New("application name is required") } - environmentName, _ := cmd.Flags().GetString("environment") - previousLog, _ := cmd.Flags().GetBool("previous") - since, _ := cmd.Flags().GetDuration("since") + environmentName, _ := cmd.Flags().GetString(flagnames.Environment) + previousLog, _ := cmd.Flags().GetBool(flagnames.Previous) + since, _ := cmd.Flags().GetDuration(flagnames.Since) if environmentName == "" { return errors.New("both `environment` and `component` are required") @@ -97,9 +96,9 @@ func getComponentReplicasForEnvironment(apiClient *apiclient.Radixapi, appName, func init() { logsCmd.AddCommand(logsEnvironmentCmd) - logsEnvironmentCmd.Flags().StringP("application", "a", "", "Name of the application owning the component") - logsEnvironmentCmd.Flags().StringP("environment", "e", "", "Environment the component runs in") - logsEnvironmentCmd.Flags().BoolP("previous", "p", false, "If set, print the logs for the previous instances of containers in environment component pods, if they exist") - logsEnvironmentCmd.Flags().DurationP("since", "s", settings.DeltaRefreshApplication, "If set, start get logs from the specified time, eg. 5m or 12h") + logsEnvironmentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application owning the component") + logsEnvironmentCmd.Flags().StringP(flagnames.Environment, "e", "", "Environment the component runs in") + logsEnvironmentCmd.Flags().BoolP(flagnames.Previous, "p", false, "If set, print the logs for the previous instances of containers in environment component pods, if they exist") + logsEnvironmentCmd.Flags().DurationP(flagnames.Since, "s", settings.DeltaRefreshApplication, "If set, start get logs from the specified time, eg. 5m or 12h") setContextSpecificPersistentFlags(logsEnvironmentCmd) } diff --git a/cmd/logsEnvironmentComponent.go b/cmd/logsEnvironmentComponent.go index 9dd94f9..051fc72 100644 --- a/cmd/logsEnvironmentComponent.go +++ b/cmd/logsEnvironmentComponent.go @@ -24,6 +24,7 @@ import ( "github.com/equinor/radix-cli/generated-client/client/component" "github.com/equinor/radix-cli/generated-client/client/environment" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/equinor/radix-cli/pkg/settings" "github.com/equinor/radix-cli/pkg/utils/log" "github.com/go-openapi/strfmt" @@ -49,7 +50,7 @@ Examples: rx get logs component -a radix-test -e dev --component web-app -p `, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -58,10 +59,10 @@ Examples: return errors.New("application name is required") } - environmentName, _ := cmd.Flags().GetString("environment") - componentName, _ := cmd.Flags().GetString("component") - previousLog, _ := cmd.Flags().GetBool("previous") - since, _ := cmd.Flags().GetDuration("since") + environmentName, _ := cmd.Flags().GetString(flagnames.Environment) + componentName, _ := cmd.Flags().GetString(flagnames.Component) + previousLog, _ := cmd.Flags().GetBool(flagnames.Previous) + since, _ := cmd.Flags().GetDuration(flagnames.Since) if environmentName == "" || componentName == "" { return errors.New("both `environment` and `component` are required") @@ -170,10 +171,10 @@ func getReplicasForComponent(apiClient *apiclient.Radixapi, appName, environment func init() { logsCmd.AddCommand(logsEnvironmentComponentCmd) - logsEnvironmentComponentCmd.Flags().StringP("application", "a", "", "Name of the application owning the component") - logsEnvironmentComponentCmd.Flags().StringP("environment", "e", "", "Environment the component runs in") - logsEnvironmentComponentCmd.Flags().String("component", "", "The component to follow") - logsEnvironmentComponentCmd.Flags().BoolP("previous", "p", false, "If set, print the logs for the previous instance of the container in a component pod, if it exists") - logsEnvironmentComponentCmd.Flags().DurationP("since", "s", settings.DeltaRefreshApplication, "If set, start get logs from the specified time, eg. 5m or 12h") + logsEnvironmentComponentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application owning the component") + logsEnvironmentComponentCmd.Flags().StringP(flagnames.Environment, "e", "", "Environment the component runs in") + logsEnvironmentComponentCmd.Flags().String(flagnames.Component, "", "The component to follow") + logsEnvironmentComponentCmd.Flags().BoolP(flagnames.Previous, "p", false, "If set, print the logs for the previous instance of the container in a component pod, if it exists") + logsEnvironmentComponentCmd.Flags().DurationP(flagnames.Since, "s", settings.DeltaRefreshApplication, "If set, start get logs from the specified time, eg. 5m or 12h") setContextSpecificPersistentFlags(logsEnvironmentComponentCmd) } diff --git a/cmd/logsPipelineJob.go b/cmd/logsPipelineJob.go index c355520..5d7e1ae 100644 --- a/cmd/logsPipelineJob.go +++ b/cmd/logsPipelineJob.go @@ -25,6 +25,7 @@ import ( apiclient "github.com/equinor/radix-cli/generated-client/client" "github.com/equinor/radix-cli/generated-client/client/pipeline_job" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/equinor/radix-cli/pkg/settings" "github.com/equinor/radix-cli/pkg/utils/log" "github.com/sirupsen/logrus" @@ -49,14 +50,12 @@ var logsJobCmd = &cobra.Command{ Short: "Gets logs for a pipeline job", Long: `Gets and follows logs for a pipeline job. -It may take few seconds to get the log. +It may take few seconds to get the log.`, + Example: `# Get logs for a pipeline job +rx get logs pipeline-job --application radix-test --job radix-pipeline-20230323185013-ehvnz`, -Example: - # Get logs for a pipeline job - rx get logs pipeline-job --application radix-test --job radix-pipeline-20230323185013-ehvnz -`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -65,7 +64,7 @@ Example: return errors.New("application name is required") } - jobName, _ := cmd.Flags().GetString("job") + jobName, _ := cmd.Flags().GetString(flagnames.Job) if jobName == "" { return errors.New("`job` is required") @@ -181,7 +180,7 @@ func errorAndLogJobStatus(status string, cmd *cobra.Command) error { func init() { logsCmd.AddCommand(logsJobCmd) - logsJobCmd.Flags().StringP("application", "a", "", "Name of the application for the job") - logsJobCmd.Flags().StringP("job", "j", "", "The job to get logs for") + logsJobCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application for the job") + logsJobCmd.Flags().StringP(flagnames.Job, "j", "", "The job to get logs for") setContextSpecificPersistentFlags(logsJobCmd) } diff --git a/cmd/restartApplication.go b/cmd/restartApplication.go index 8e1b6f7..73edc5d 100644 --- a/cmd/restartApplication.go +++ b/cmd/restartApplication.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/application" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -29,7 +31,7 @@ var restartApplicationCmd = &cobra.Command{ - Starts the application's containers, using up to date images - Stops the application's old containers`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -55,6 +57,6 @@ var restartApplicationCmd = &cobra.Command{ func init() { restartCmd.AddCommand(restartApplicationCmd) - restartApplicationCmd.Flags().StringP("application", "a", "", "Name of the application namespace") + restartApplicationCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") setContextSpecificPersistentFlags(restartApplicationCmd) } diff --git a/cmd/restartComponent.go b/cmd/restartComponent.go index 964b979..dd69108 100644 --- a/cmd/restartComponent.go +++ b/cmd/restartComponent.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/component" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -29,18 +31,18 @@ var restartComponentCmd = &cobra.Command{ - Starts the component's container, using up to date image - Stops the application component's old containers`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil || appName == nil || *appName == "" { return errors.New("environment name and application name are required fields") } - cmpName, err := cmd.Flags().GetString("component") + cmpName, err := cmd.Flags().GetString(flagnames.Component) if err != nil { return errors.New("component name is a required field") } @@ -64,8 +66,8 @@ var restartComponentCmd = &cobra.Command{ func init() { restartCmd.AddCommand(restartComponentCmd) - restartComponentCmd.Flags().StringP("application", "a", "", "Name of the application namespace") - restartComponentCmd.Flags().StringP("environment", "e", "", "Name of the environment of the application") - restartComponentCmd.Flags().StringP("component", "n", "", "Name of the component to restart") + restartComponentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") + restartComponentCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment of the application") + restartComponentCmd.Flags().StringP(flagnames.Component, "n", "", "Name of the component to restart") setContextSpecificPersistentFlags(restartComponentCmd) } diff --git a/cmd/restartEnvironment.go b/cmd/restartEnvironment.go index b3f0f73..808c11d 100644 --- a/cmd/restartEnvironment.go +++ b/cmd/restartEnvironment.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/environment" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -29,12 +31,12 @@ var restartEnvironmentCmd = &cobra.Command{ - Starts the environment's containers, using up to date images - Stops the application environment's old containers`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil || appName == nil || *appName == "" || envName == "" { return errors.New("environment name and application name are required fields") @@ -58,7 +60,7 @@ var restartEnvironmentCmd = &cobra.Command{ func init() { restartCmd.AddCommand(restartEnvironmentCmd) - restartEnvironmentCmd.Flags().StringP("application", "a", "", "Name of the application namespace") - restartEnvironmentCmd.Flags().StringP("environment", "e", "", "Name of the environment of the application") + restartEnvironmentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") + restartEnvironmentCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment of the application") setContextSpecificPersistentFlags(restartEnvironmentCmd) } diff --git a/cmd/restartPipelineJob.go b/cmd/restartPipelineJob.go index 08ec629..240f357 100644 --- a/cmd/restartPipelineJob.go +++ b/cmd/restartPipelineJob.go @@ -19,6 +19,7 @@ import ( "github.com/equinor/radix-cli/generated-client/client/pipeline_job" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -27,14 +28,11 @@ var restartPipelineJobCmd = &cobra.Command{ Use: "pipeline-job", Aliases: []string{"job"}, Short: "Restart Radix pipeline job", - Long: `Restart failed of stopped Radix pipeline job. - - Example: - rx restart pipeline-job --application radix-test --job radix-pipeline-20230323185013-ehvnz -`, + Long: "Restart failed of stopped Radix pipeline job.", + Example: `rx restart pipeline-job --application radix-test --job radix-pipeline-20230323185013-ehvnz`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -43,7 +41,7 @@ var restartPipelineJobCmd = &cobra.Command{ return errors.New("application name is required") } - jobName, _ := cmd.Flags().GetString("job") + jobName, _ := cmd.Flags().GetString(flagnames.Job) if jobName == "" { return errors.New("`job` is required") @@ -67,7 +65,7 @@ var restartPipelineJobCmd = &cobra.Command{ func init() { restartCmd.AddCommand(restartPipelineJobCmd) - restartPipelineJobCmd.Flags().StringP("application", "a", "", "Name of the application for the job") - restartPipelineJobCmd.Flags().StringP("job", "j", "", "The job to restart") + restartPipelineJobCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application for the job") + restartPipelineJobCmd.Flags().StringP(flagnames.Job, "j", "", "The job to restart") setContextSpecificPersistentFlags(restartPipelineJobCmd) } diff --git a/cmd/root.go b/cmd/root.go index a673680..48bd7d2 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,6 +10,7 @@ import ( "github.com/equinor/radix-cli/pkg/client" radixconfig "github.com/equinor/radix-cli/pkg/config" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/equinor/radix-cli/pkg/settings" v1 "github.com/equinor/radix-operator/pkg/apis/radix/v1" "github.com/equinor/radix-operator/pkg/apis/utils" @@ -38,21 +39,21 @@ func Execute() { } func setVerbosePersistentFlag(cmd *cobra.Command) *bool { - return cmd.PersistentFlags().Bool(settings.VerboseOption, false, "Verbose output") + return cmd.PersistentFlags().Bool(flagnames.Verbose, false, "Verbose output") } func setContextSpecificPersistentFlags(cmd *cobra.Command) { - cmd.PersistentFlags().Bool(settings.FromConfigOption, false, "Read and use radix config from file as context") - cmd.PersistentFlags().Bool(settings.TokenEnvironmentOption, false, fmt.Sprintf("Take the token from environment variable %s", client.TokenEnvironmentName)) - cmd.PersistentFlags().Bool(settings.TokenStdinOption, false, "Take the token from stdin") + cmd.PersistentFlags().Bool(flagnames.FromConfig, false, "Read and use radix config from file as context") + cmd.PersistentFlags().Bool(flagnames.TokenEnvironment, false, fmt.Sprintf("Take the token from environment variable %s", client.TokenEnvironmentName)) + cmd.PersistentFlags().Bool(flagnames.TokenStdin, false, "Take the token from stdin") setContextPersistentFlags(cmd) - cmd.PersistentFlags().String(settings.ClusterOption, "", "Set cluster to override context") - cmd.PersistentFlags().String(settings.ApiEnvironmentOption, "prod", "The API api-environment to run with (default prod)") + cmd.PersistentFlags().String(flagnames.Cluster, "", "Set cluster to override context") + cmd.PersistentFlags().String(flagnames.ApiEnvironment, "prod", "The API api-environment to run with (default prod)") setVerbosePersistentFlag(cmd) } func setContextPersistentFlags(cmd *cobra.Command) { - cmd.PersistentFlags().StringP(settings.ContextOption, "c", "", fmt.Sprintf("Use context %s|%s|%s|%s regardless of current context (default production) ", + cmd.PersistentFlags().StringP(flagnames.Context, "c", "", fmt.Sprintf("Use context %s|%s|%s|%s regardless of current context (default production) ", radixconfig.ContextPlatform, radixconfig.ContextPlatform2, radixconfig.ContextPlayground, radixconfig.ContextDevelopment)) } @@ -84,7 +85,7 @@ func getAppNameFromConfigOrFromParameter(cmd *cobra.Command, appNameField string var appName string var err error - fromConfig, _ := cmd.Flags().GetBool(settings.FromConfigOption) + fromConfig, _ := cmd.Flags().GetBool(flagnames.FromConfig) if fromConfig { radicConfig, err := getRadixApplicationFromFile() if err != nil { @@ -105,7 +106,7 @@ func getAppNameFromConfigOrFromParameter(cmd *cobra.Command, appNameField string func getEnvironmentFromConfig(cmd *cobra.Command, branchName string) (*string, error) { var err error - fromConfig, _ := cmd.Flags().GetBool(settings.FromConfigOption) + fromConfig, _ := cmd.Flags().GetBool(flagnames.FromConfig) if !fromConfig { return nil, errors.New("--from-config is required when getting environment from branch") } @@ -140,3 +141,16 @@ func loadConfigFromFile(appFileName string) (*v1.RadixApplication, error) { return radixApplication, nil } + +func getStringFromFlagValueOrFlagFile(cmd *cobra.Command, valueFlag, fileNameFlag string) (string, error) { + fileName, err := cmd.Flags().GetString(fileNameFlag) + if err != nil { + return "", err + } + if len(fileName) > 0 { + fileContent, err := os.ReadFile(fileName) + return string(fileContent), err + } + + return cmd.Flags().GetString(valueFlag) +} diff --git a/cmd/scale.go b/cmd/scale.go index d5283c6..02566cf 100644 --- a/cmd/scale.go +++ b/cmd/scale.go @@ -20,6 +20,7 @@ import ( "github.com/equinor/radix-cli/generated-client/client/component" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -38,19 +39,19 @@ rx scale --application radix-test --environment dev --component component-abc -- rx scale -a radix-test -e dev -n component-abc -r 2 `, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil { return err } - cmpName, err := cmd.Flags().GetString("component") + cmpName, err := cmd.Flags().GetString(flagnames.Component) if err != nil { return err } - replicas, err := cmd.Flags().GetInt("replicas") + replicas, err := cmd.Flags().GetInt(flagnames.Replicas) if err != nil { return err } @@ -80,9 +81,9 @@ rx scale -a radix-test -e dev -n component-abc -r 2 func init() { rootCmd.AddCommand(scaleCmd) - scaleCmd.Flags().StringP("application", "a", "", "Name of the application namespace") - scaleCmd.Flags().StringP("environment", "e", "", "Name of the environment of the application") - scaleCmd.Flags().StringP("component", "n", "", "Name of the component to scale") - scaleCmd.Flags().IntP("replicas", "r", 1, "The new desired number of replicas") + scaleCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") + scaleCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment of the application") + scaleCmd.Flags().StringP(flagnames.Component, "n", "", "Name of the component to scale") + scaleCmd.Flags().IntP(flagnames.Replicas, "r", 1, "The new desired number of replicas") setContextSpecificPersistentFlags(scaleCmd) } diff --git a/cmd/setContext.go b/cmd/setContext.go index 4acf538..48ef822 100644 --- a/cmd/setContext.go +++ b/cmd/setContext.go @@ -18,7 +18,7 @@ import ( "fmt" radixconfig "github.com/equinor/radix-cli/pkg/config" - "github.com/equinor/radix-cli/pkg/settings" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -30,7 +30,7 @@ var setContextCmd = &cobra.Command{ Long: fmt.Sprintf("Sets the context to be either %s, %s, %s or %s", radixconfig.ContextPlatform, radixconfig.ContextPlatform2, radixconfig.ContextPlayground, radixconfig.ContextDevelopment), RunE: func(cmd *cobra.Command, args []string) error { - context, _ := cmd.Flags().GetString(settings.ContextOption) + context, _ := cmd.Flags().GetString(flagnames.Context) if !radixconfig.IsValidContext(context) { return fmt.Errorf("context '%s' is not a valid context", context) diff --git a/cmd/setEnvironmentSecret.go b/cmd/setEnvironmentSecret.go index a9d543e..f04f142 100644 --- a/cmd/setEnvironmentSecret.go +++ b/cmd/setEnvironmentSecret.go @@ -23,6 +23,7 @@ import ( "github.com/equinor/radix-cli/generated-client/client/environment" "github.com/equinor/radix-cli/generated-client/models" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -32,7 +33,7 @@ var setEnvironmentSecretCmd = &cobra.Command{ Short: "Will set an environment secret", Long: `Will set an environment secret`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -41,8 +42,8 @@ var setEnvironmentSecretCmd = &cobra.Command{ return errors.New("application name is required") } - secretName, _ := cmd.Flags().GetString("secret") - secretValue, _ := cmd.Flags().GetString("value") + secretName, _ := cmd.Flags().GetString(flagnames.Secret) + secretValue, _ := cmd.Flags().GetString(flagnames.Value) if secretName == "" { return errors.New("secret is required") @@ -52,18 +53,18 @@ var setEnvironmentSecretCmd = &cobra.Command{ return errors.New("value is required") } - environmentName, _ := cmd.Flags().GetString("environment") + environmentName, _ := cmd.Flags().GetString(flagnames.Environment) if environmentName == "" { return errors.New("`environment` is required") } - component, _ := cmd.Flags().GetString("component") + component, _ := cmd.Flags().GetString(flagnames.Component) if component == "" { return errors.New("`component` is required") } - awaitReconcile, _ := cmd.Flags().GetBool("await-reconcile") + awaitReconcile, _ := cmd.Flags().GetBool(flagnames.AwaitReconcile) cmd.SilenceUsage = true @@ -129,11 +130,11 @@ func isComponentSecretReconciled(apiClient *apiclient.Radixapi, appName, environ func init() { setCmd.AddCommand(setEnvironmentSecretCmd) - setEnvironmentSecretCmd.Flags().StringP("application", "a", "", "Name of the application to set secret for") - setEnvironmentSecretCmd.Flags().StringP("environment", "e", "", "Environment to set secret in") - setEnvironmentSecretCmd.Flags().String("component", "", "Component to set the secret for") - setEnvironmentSecretCmd.Flags().StringP("secret", "s", "", "Name of the secret to set") - setEnvironmentSecretCmd.Flags().StringP("value", "v", "", "Value of the secret to set") - setEnvironmentSecretCmd.Flags().Bool("await-reconcile", true, "Await reconciliation in Radix. Default is true") + setEnvironmentSecretCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application to set secret for") + setEnvironmentSecretCmd.Flags().StringP(flagnames.Environment, "e", "", "Environment to set secret in") + setEnvironmentSecretCmd.Flags().String(flagnames.Component, "", "Component to set the secret for") + setEnvironmentSecretCmd.Flags().StringP(flagnames.Secret, "s", "", "Name of the secret to set") + setEnvironmentSecretCmd.Flags().StringP(flagnames.Value, "v", "", "Value of the secret to set") + setEnvironmentSecretCmd.Flags().Bool(flagnames.AwaitReconcile, true, "Await reconciliation in Radix. Default is true") setContextSpecificPersistentFlags(setEnvironmentSecretCmd) } diff --git a/cmd/setEnvironmentVariable.go b/cmd/setEnvironmentVariable.go index cf599d2..f164ac9 100644 --- a/cmd/setEnvironmentVariable.go +++ b/cmd/setEnvironmentVariable.go @@ -24,20 +24,18 @@ import ( "github.com/equinor/radix-cli/generated-client/client/environment" "github.com/equinor/radix-cli/generated-client/models" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) // setEnvironmentVariableCmd represents the setEnvironmentVariableCmd command var setEnvironmentVariableCmd = &cobra.Command{ - Use: "environment-variable", - Short: "Will set an environment variable", - Long: `Will set an environment variable - -Example: -rx set environment-variable --application your-application-name --environment test --component component-abc --variable LOG_LEVEL --value INFO -`, + Use: "environment-variable", + Short: "Will set an environment variable", + Long: "Will set an environment variable", + Example: `rx set environment-variable --application your-application-name --environment test --component component-abc --variable LOG_LEVEL --value INFO`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -46,8 +44,8 @@ rx set environment-variable --application your-application-name --environment te return errors.New("application name is required") } - variableName, _ := cmd.Flags().GetString("variable") - variableValue, _ := cmd.Flags().GetString("value") + variableName, _ := cmd.Flags().GetString(flagnames.Variable) + variableValue, _ := cmd.Flags().GetString(flagnames.Value) if variableName == "" { return errors.New("variable is required") @@ -57,18 +55,18 @@ rx set environment-variable --application your-application-name --environment te return errors.New("value is required") } - environmentName, _ := cmd.Flags().GetString("environment") + environmentName, _ := cmd.Flags().GetString(flagnames.Environment) if environmentName == "" { return errors.New("`environment` is required") } - componentName, _ := cmd.Flags().GetString("component") + componentName, _ := cmd.Flags().GetString(flagnames.Component) if componentName == "" { return errors.New("`component` is required") } - awaitReconcile, _ := cmd.Flags().GetBool("await-reconcile") + awaitReconcile, _ := cmd.Flags().GetBool(flagnames.AwaitReconcile) cmd.SilenceUsage = true @@ -134,11 +132,11 @@ func isComponentVariableReconciled(apiClient *apiclient.Radixapi, appName, envir func init() { setCmd.AddCommand(setEnvironmentVariableCmd) - setEnvironmentVariableCmd.Flags().StringP("application", "a", "", "Name of the application to set variable for") - setEnvironmentVariableCmd.Flags().StringP("environment", "e", "", "Environment to set variable in") - setEnvironmentVariableCmd.Flags().String("component", "", "Component to set the variable for") - setEnvironmentVariableCmd.Flags().StringP("variable", "", "", "Name of the variable to set") - setEnvironmentVariableCmd.Flags().StringP("value", "v", "", "Value of the variable to set") - setEnvironmentVariableCmd.Flags().Bool("await-reconcile", true, "Await reconciliation in Radix. Default is true") + setEnvironmentVariableCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application to set variable for") + setEnvironmentVariableCmd.Flags().StringP(flagnames.Environment, "e", "", "Environment to set variable in") + setEnvironmentVariableCmd.Flags().String(flagnames.Component, "", "Component to set the variable for") + setEnvironmentVariableCmd.Flags().StringP(flagnames.Variable, "", "", "Name of the variable to set") + setEnvironmentVariableCmd.Flags().StringP(flagnames.Value, "v", "", "Value of the variable to set") + setEnvironmentVariableCmd.Flags().Bool(flagnames.AwaitReconcile, true, "Await reconciliation in Radix. Default is true") setContextSpecificPersistentFlags(setEnvironmentVariableCmd) } diff --git a/cmd/setExternalDnsTls.go b/cmd/setExternalDnsTls.go new file mode 100644 index 0000000..eaa895e --- /dev/null +++ b/cmd/setExternalDnsTls.go @@ -0,0 +1,161 @@ +// Copyright © 2023 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "errors" + "fmt" + "os" + + apiclient "github.com/equinor/radix-cli/generated-client/client" + "github.com/equinor/radix-cli/generated-client/client/component" + "github.com/equinor/radix-cli/generated-client/client/environment" + "github.com/equinor/radix-cli/generated-client/models" + "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" + "github.com/spf13/cobra" +) + +// setExternalDnsTlsCmd represents the setExternalDnsTlsCmd command +var setExternalDnsTlsCmd = &cobra.Command{ + Use: "external-dns-tls", + Short: "Set TLS certificate and private key for a component's external DNS alias", + Long: "Set TLS certificate and private key for a component's external DNS alias", + Example: `# Read certificate and private key from file +rx set external-dns-tls --application myapp --environment prod --component web --alias myapp.example.com --certificate-from-file "cert.crt" --private-key-from-file "cert.key" `, + RunE: func(cmd *cobra.Command, args []string) error { + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) + if err != nil { + return err + } + if appName == nil || *appName == "" { + return errors.New("application name is required") + } + + environmentName, _ := cmd.Flags().GetString(flagnames.Environment) + if environmentName == "" { + return errors.New("`environment` is required") + } + + componentName, _ := cmd.Flags().GetString(flagnames.Component) + if componentName == "" { + return errors.New("`component` is required") + } + + fqdn, _ := cmd.Flags().GetString(flagnames.Alias) + if fqdn == "" { + return errors.New("`alias` is required") + } + + certificate, err := getStringFromFlagValueOrFlagFile(cmd, flagnames.Certificate, flagnames.CertificateFromFile) + if err != nil { + return err + } + if certificate == "" { + return errors.New("certificate value cannot be empty") + } + + privateKey, err := getStringFromFlagValueOrFlagFile(cmd, flagnames.PrivateKey, flagnames.PrivateKeyFromFile) + if err != nil { + return err + } + if privateKey == "" { + return errors.New("private key value cannot be empty") + } + + skipValidation, _ := cmd.Flags().GetBool(flagnames.SkipValidation) + awaitReconcile, _ := cmd.Flags().GetBool(flagnames.AwaitReconcile) + cmd.SilenceUsage = true + + apiClient, err := client.GetForCommand(cmd) + if err != nil { + return err + } + + if awaitReconcile { + reconciledOk := awaitReconciliation(func() bool { + return isComponentExternalDNSReconciled(apiClient, *appName, environmentName, componentName, fqdn) + }) + + if !reconciledOk { + return fmt.Errorf("component was not reconciled within time: either component %s does not exist in the environment %s or external DNS alias %s is not defined", + componentName, environmentName, fqdn) + } + } + updateExternalDNSTLS := component.NewUpdateComponentExternalDNSTLSParams(). + WithAppName(*appName). + WithEnvName(environmentName). + WithComponentName(componentName). + WithFqdn(fqdn). + WithTLSData(&models.UpdateExternalDNSTLSRequest{ + Certificate: &certificate, + PrivateKey: &privateKey, + SkipValidation: skipValidation, + }) + + _, err = apiClient.Component.UpdateComponentExternalDNSTLS(updateExternalDNSTLS, nil) + return err + }, +} + +func isComponentExternalDNSReconciled(apiClient *apiclient.Radixapi, appName, environmentName, componentName, fqdn string) bool { + getEnvironmentParameters := environment.NewGetEnvironmentParams(). + WithAppName(appName). + WithEnvName(environmentName) + + env, err := apiClient.Environment.GetEnvironment(getEnvironmentParameters, nil) + if err != nil { + fmt.Fprintln(os.Stderr, err) + return false + } + + if env.Payload != nil && + env.Payload.ActiveDeployment != nil && + env.Payload.ActiveDeployment.Components != nil { + for _, component := range env.Payload.ActiveDeployment.Components { + if *component.Name == componentName { + for _, externalDns := range component.ExternalDNS { + if *externalDns.FQDN == fqdn { + return true + } + } + } + } + } + + return false +} + +func init() { + setExternalDnsTlsCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application") + setExternalDnsTlsCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment") + setExternalDnsTlsCmd.Flags().String(flagnames.Component, "", "Name of the component") + setExternalDnsTlsCmd.Flags().String(flagnames.Alias, "", "External DNS alias to update") + setExternalDnsTlsCmd.Flags().String(flagnames.Certificate, "", "Certificate (PEM format)") + setExternalDnsTlsCmd.Flags().String(flagnames.CertificateFromFile, "", "Read certificate (PEM format) from file") + setExternalDnsTlsCmd.Flags().String(flagnames.PrivateKey, "", "Private key (PEM format)") + setExternalDnsTlsCmd.Flags().String(flagnames.PrivateKeyFromFile, "", "Read private key (PEM format) from file") + setExternalDnsTlsCmd.Flags().Bool(flagnames.SkipValidation, false, "Skip validation of certificate and private key") + setExternalDnsTlsCmd.Flags().Bool(flagnames.AwaitReconcile, true, "Await reconciliation in Radix. Default is true") + + setExternalDnsTlsCmd.MarkFlagsOneRequired(flagnames.Certificate, flagnames.CertificateFromFile) + setExternalDnsTlsCmd.MarkFlagsMutuallyExclusive(flagnames.Certificate, flagnames.CertificateFromFile) + setExternalDnsTlsCmd.MarkFlagsOneRequired(flagnames.PrivateKey, flagnames.PrivateKeyFromFile) + setExternalDnsTlsCmd.MarkFlagsMutuallyExclusive(flagnames.PrivateKey, flagnames.PrivateKeyFromFile) + + setContextSpecificPersistentFlags(setExternalDnsTlsCmd) + + setCmd.AddCommand(setExternalDnsTlsCmd) +} diff --git a/cmd/startApplication.go b/cmd/startApplication.go index 53a9f7e..92d7974 100644 --- a/cmd/startApplication.go +++ b/cmd/startApplication.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/application" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -29,7 +31,7 @@ var startApplicationCmd = &cobra.Command{ - Pulls new images from image hub in radix configuration - Starts the application containers using up to date images`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -55,6 +57,6 @@ var startApplicationCmd = &cobra.Command{ func init() { startCmd.AddCommand(startApplicationCmd) - startApplicationCmd.Flags().StringP("application", "a", "", "Name of the application namespace") + startApplicationCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") setContextSpecificPersistentFlags(startApplicationCmd) } diff --git a/cmd/startComponent.go b/cmd/startComponent.go index 0c6b3af..36b3632 100644 --- a/cmd/startComponent.go +++ b/cmd/startComponent.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/component" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -29,18 +31,18 @@ var startComponentCmd = &cobra.Command{ - Pulls new image from image hub in radix configuration - Starts the container using up to date image`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil || appName == nil || *appName == "" || envName == "" { return errors.New("environment name and application name are required fields") } - cmpName, err := cmd.Flags().GetString("component") + cmpName, err := cmd.Flags().GetString(flagnames.Component) if err != nil { return errors.New("component name is a required field") } @@ -64,8 +66,8 @@ var startComponentCmd = &cobra.Command{ func init() { startCmd.AddCommand(startComponentCmd) - startComponentCmd.Flags().StringP("application", "a", "", "Name of the application namespace") - startComponentCmd.Flags().StringP("environment", "e", "", "Name of the environment of the application") - startComponentCmd.Flags().StringP("component", "n", "", "Name of the component to start") + startComponentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") + startComponentCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment of the application") + startComponentCmd.Flags().StringP(flagnames.Component, "n", "", "Name of the component to start") setContextSpecificPersistentFlags(startComponentCmd) } diff --git a/cmd/startEnvironment.go b/cmd/startEnvironment.go index 8be4f36..925d8d9 100644 --- a/cmd/startEnvironment.go +++ b/cmd/startEnvironment.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/environment" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -29,12 +31,12 @@ var startEnvironmentCmd = &cobra.Command{ - Pulls new images from image hub in radix configuration - Starts the environment containers using up to date images`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil || appName == nil || *appName == "" || envName == "" { return errors.New("environment name and application name are required fields") @@ -58,7 +60,7 @@ var startEnvironmentCmd = &cobra.Command{ func init() { startCmd.AddCommand(startEnvironmentCmd) - startEnvironmentCmd.Flags().StringP("application", "a", "", "Name of the application namespace") - startEnvironmentCmd.Flags().StringP("environment", "e", "", "Name of the environment of the application") + startEnvironmentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") + startEnvironmentCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment of the application") setContextSpecificPersistentFlags(startEnvironmentCmd) } diff --git a/cmd/stopApplication.go b/cmd/stopApplication.go index 15f4e0e..0266417 100644 --- a/cmd/stopApplication.go +++ b/cmd/stopApplication.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/application" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -28,7 +30,7 @@ var stopApplicationCmd = &cobra.Command{ Long: `Stop an application - Stops the application components running containers`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } @@ -54,6 +56,6 @@ var stopApplicationCmd = &cobra.Command{ func init() { stopCmd.AddCommand(stopApplicationCmd) - stopApplicationCmd.Flags().StringP("application", "a", "", "Name of the application namespace") + stopApplicationCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") setContextSpecificPersistentFlags(stopApplicationCmd) } diff --git a/cmd/stopComponent.go b/cmd/stopComponent.go index 029ce72..f8b7fb6 100644 --- a/cmd/stopComponent.go +++ b/cmd/stopComponent.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/component" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -28,18 +30,18 @@ var stopComponentCmd = &cobra.Command{ Long: `Stop a component - Stops the component running container`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil || appName == nil || *appName == "" || envName == "" { return errors.New("environment name and application name are required fields") } - cmpName, err := cmd.Flags().GetString("component") + cmpName, err := cmd.Flags().GetString(flagnames.Component) if err != nil { return errors.New("component name is a required field") } @@ -63,8 +65,8 @@ var stopComponentCmd = &cobra.Command{ func init() { stopCmd.AddCommand(stopComponentCmd) - stopComponentCmd.Flags().StringP("application", "a", "", "Name of the application namespace") - stopComponentCmd.Flags().StringP("environment", "e", "", "Name of the environment of the application") - stopComponentCmd.Flags().StringP("component", "n", "", "Name of the component to stop") + stopComponentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") + stopComponentCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment of the application") + stopComponentCmd.Flags().StringP(flagnames.Component, "n", "", "Name of the component to stop") setContextSpecificPersistentFlags(stopComponentCmd) } diff --git a/cmd/stopEnvironment.go b/cmd/stopEnvironment.go index 857e6ad..e3030e6 100644 --- a/cmd/stopEnvironment.go +++ b/cmd/stopEnvironment.go @@ -16,8 +16,10 @@ package cmd import ( "errors" + "github.com/equinor/radix-cli/generated-client/client/environment" "github.com/equinor/radix-cli/pkg/client" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/spf13/cobra" ) @@ -28,12 +30,12 @@ var stopEnvironmentCmd = &cobra.Command{ Long: `Stop an environment - Stops the environment components running containers`, RunE: func(cmd *cobra.Command, args []string) error { - appName, err := getAppNameFromConfigOrFromParameter(cmd, "application") + appName, err := getAppNameFromConfigOrFromParameter(cmd, flagnames.Application) if err != nil { return err } - envName, err := cmd.Flags().GetString("environment") + envName, err := cmd.Flags().GetString(flagnames.Environment) if err != nil || appName == nil || *appName == "" || envName == "" { return errors.New("environment name and application name are required fields") @@ -57,7 +59,7 @@ var stopEnvironmentCmd = &cobra.Command{ func init() { stopCmd.AddCommand(stopEnvironmentCmd) - stopEnvironmentCmd.Flags().StringP("application", "a", "", "Name of the application namespace") - stopEnvironmentCmd.Flags().StringP("environment", "e", "", "Name of the environment of the application") + stopEnvironmentCmd.Flags().StringP(flagnames.Application, "a", "", "Name of the application namespace") + stopEnvironmentCmd.Flags().StringP(flagnames.Environment, "e", "", "Name of the environment of the application") setContextSpecificPersistentFlags(stopEnvironmentCmd) } diff --git a/cmd/validateRadixConfig.go b/cmd/validateRadixConfig.go index f23d1ca..a50c99f 100644 --- a/cmd/validateRadixConfig.go +++ b/cmd/validateRadixConfig.go @@ -19,7 +19,7 @@ import ( "os" "github.com/equinor/radix-cli/pkg/client" - "github.com/equinor/radix-cli/pkg/settings" + "github.com/equinor/radix-cli/pkg/flagnames" radixv1 "github.com/equinor/radix-operator/pkg/apis/radix/v1" "github.com/equinor/radix-operator/pkg/apis/radixvalidators" "github.com/equinor/radix-operator/pkg/apis/utils" @@ -37,12 +37,12 @@ var validateRadixConfigCmd = &cobra.Command{ cmd.SilenceUsage = true - radixconfig, err := cmd.Flags().GetString("config-file") + radixconfig, err := cmd.Flags().GetString(flagnames.ConfigFile) if err != nil { return err } - printfile, err := cmd.Flags().GetBool("print") + printfile, err := cmd.Flags().GetBool(flagnames.Print) if err != nil { return err } @@ -85,12 +85,12 @@ func printRA(ra *radixv1.RadixApplication) error { func init() { validateCmd.AddCommand(validateRadixConfigCmd) - validateRadixConfigCmd.Flags().StringP("config-file", "f", "radixconfig.yaml", "Name of the radixconfig file. Defaults to radixconfig.yaml in current directory") - validateRadixConfigCmd.Flags().BoolP("print", "p", false, "Print parsed config file") + validateRadixConfigCmd.Flags().StringP(flagnames.ConfigFile, "f", "radixconfig.yaml", "Name of the radixconfig file. Defaults to radixconfig.yaml in current directory") + validateRadixConfigCmd.Flags().BoolP(flagnames.Print, "p", false, "Print parsed config file") // Allow but hide token-env flag so radix-github-actions won't interfere - validateRadixConfigCmd.Flags().Bool(settings.TokenEnvironmentOption, false, fmt.Sprintf("Take the token from environment variable %s", client.TokenEnvironmentName)) - err := validateRadixConfigCmd.Flags().MarkHidden(settings.TokenEnvironmentOption) + validateRadixConfigCmd.Flags().Bool(flagnames.TokenEnvironment, false, fmt.Sprintf("Take the token from environment variable %s", client.TokenEnvironmentName)) + err := validateRadixConfigCmd.Flags().MarkHidden(flagnames.TokenEnvironment) if err != nil { panic(err) } diff --git a/generated-client/client/component/component_client.go b/generated-client/client/component/component_client.go index d98fa2f..1587575 100644 --- a/generated-client/client/component/component_client.go +++ b/generated-client/client/component/component_client.go @@ -52,6 +52,8 @@ type ClientService interface { StopComponent(params *StopComponentParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*StopComponentOK, error) + UpdateComponentExternalDNSTLS(params *UpdateComponentExternalDNSTLSParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateComponentExternalDNSTLSOK, error) + SetTransport(transport runtime.ClientTransport) } @@ -484,6 +486,45 @@ func (a *Client) StopComponent(params *StopComponentParams, authInfo runtime.Cli panic(msg) } +/* +UpdateComponentExternalDNSTLS sets external DNS TLS private key certificate for a component +*/ +func (a *Client) UpdateComponentExternalDNSTLS(params *UpdateComponentExternalDNSTLSParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UpdateComponentExternalDNSTLSOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdateComponentExternalDNSTLSParams() + } + op := &runtime.ClientOperation{ + ID: "updateComponentExternalDnsTls", + Method: "PUT", + PathPattern: "/applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http", "https"}, + Params: params, + Reader: &UpdateComponentExternalDNSTLSReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*UpdateComponentExternalDNSTLSOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for updateComponentExternalDnsTls: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + // SetTransport changes the transport on the client func (a *Client) SetTransport(transport runtime.ClientTransport) { a.transport = transport diff --git a/generated-client/client/component/update_component_external_dns_tls_parameters.go b/generated-client/client/component/update_component_external_dns_tls_parameters.go new file mode 100644 index 0000000..7413cba --- /dev/null +++ b/generated-client/client/component/update_component_external_dns_tls_parameters.go @@ -0,0 +1,291 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package component + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/equinor/radix-cli/generated-client/models" +) + +// NewUpdateComponentExternalDNSTLSParams creates a new UpdateComponentExternalDNSTLSParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewUpdateComponentExternalDNSTLSParams() *UpdateComponentExternalDNSTLSParams { + return &UpdateComponentExternalDNSTLSParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewUpdateComponentExternalDNSTLSParamsWithTimeout creates a new UpdateComponentExternalDNSTLSParams object +// with the ability to set a timeout on a request. +func NewUpdateComponentExternalDNSTLSParamsWithTimeout(timeout time.Duration) *UpdateComponentExternalDNSTLSParams { + return &UpdateComponentExternalDNSTLSParams{ + timeout: timeout, + } +} + +// NewUpdateComponentExternalDNSTLSParamsWithContext creates a new UpdateComponentExternalDNSTLSParams object +// with the ability to set a context for a request. +func NewUpdateComponentExternalDNSTLSParamsWithContext(ctx context.Context) *UpdateComponentExternalDNSTLSParams { + return &UpdateComponentExternalDNSTLSParams{ + Context: ctx, + } +} + +// NewUpdateComponentExternalDNSTLSParamsWithHTTPClient creates a new UpdateComponentExternalDNSTLSParams object +// with the ability to set a custom HTTPClient for a request. +func NewUpdateComponentExternalDNSTLSParamsWithHTTPClient(client *http.Client) *UpdateComponentExternalDNSTLSParams { + return &UpdateComponentExternalDNSTLSParams{ + HTTPClient: client, + } +} + +/* +UpdateComponentExternalDNSTLSParams contains all the parameters to send to the API endpoint + + for the update component external Dns Tls operation. + + Typically these are written to a http.Request. +*/ +type UpdateComponentExternalDNSTLSParams struct { + + /* ImpersonateGroup. + + Works only with custom setup of cluster. Allow impersonation of a comma-seperated list of test groups (Required if Impersonate-User is set) + */ + ImpersonateGroup *string + + /* ImpersonateUser. + + Works only with custom setup of cluster. Allow impersonation of test users (Required if Impersonate-Group is set) + */ + ImpersonateUser *string + + /* AppName. + + Name of application + */ + AppName string + + /* ComponentName. + + secret component of Radix application + */ + ComponentName string + + /* EnvName. + + secret of Radix application + */ + EnvName string + + /* Fqdn. + + FQDN to be updated + */ + Fqdn string + + /* TLSData. + + New TLS private key and certificate + */ + TLSData *models.UpdateExternalDNSTLSRequest + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the update component external Dns Tls params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateComponentExternalDNSTLSParams) WithDefaults() *UpdateComponentExternalDNSTLSParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the update component external Dns Tls params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *UpdateComponentExternalDNSTLSParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithTimeout(timeout time.Duration) *UpdateComponentExternalDNSTLSParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithContext(ctx context.Context) *UpdateComponentExternalDNSTLSParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithHTTPClient(client *http.Client) *UpdateComponentExternalDNSTLSParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithImpersonateGroup adds the impersonateGroup to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithImpersonateGroup(impersonateGroup *string) *UpdateComponentExternalDNSTLSParams { + o.SetImpersonateGroup(impersonateGroup) + return o +} + +// SetImpersonateGroup adds the impersonateGroup to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetImpersonateGroup(impersonateGroup *string) { + o.ImpersonateGroup = impersonateGroup +} + +// WithImpersonateUser adds the impersonateUser to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithImpersonateUser(impersonateUser *string) *UpdateComponentExternalDNSTLSParams { + o.SetImpersonateUser(impersonateUser) + return o +} + +// SetImpersonateUser adds the impersonateUser to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetImpersonateUser(impersonateUser *string) { + o.ImpersonateUser = impersonateUser +} + +// WithAppName adds the appName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithAppName(appName string) *UpdateComponentExternalDNSTLSParams { + o.SetAppName(appName) + return o +} + +// SetAppName adds the appName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetAppName(appName string) { + o.AppName = appName +} + +// WithComponentName adds the componentName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithComponentName(componentName string) *UpdateComponentExternalDNSTLSParams { + o.SetComponentName(componentName) + return o +} + +// SetComponentName adds the componentName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetComponentName(componentName string) { + o.ComponentName = componentName +} + +// WithEnvName adds the envName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithEnvName(envName string) *UpdateComponentExternalDNSTLSParams { + o.SetEnvName(envName) + return o +} + +// SetEnvName adds the envName to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetEnvName(envName string) { + o.EnvName = envName +} + +// WithFqdn adds the fqdn to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithFqdn(fqdn string) *UpdateComponentExternalDNSTLSParams { + o.SetFqdn(fqdn) + return o +} + +// SetFqdn adds the fqdn to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetFqdn(fqdn string) { + o.Fqdn = fqdn +} + +// WithTLSData adds the tLSData to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) WithTLSData(tLSData *models.UpdateExternalDNSTLSRequest) *UpdateComponentExternalDNSTLSParams { + o.SetTLSData(tLSData) + return o +} + +// SetTLSData adds the tlsData to the update component external Dns Tls params +func (o *UpdateComponentExternalDNSTLSParams) SetTLSData(tLSData *models.UpdateExternalDNSTLSRequest) { + o.TLSData = tLSData +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdateComponentExternalDNSTLSParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.ImpersonateGroup != nil { + + // header param Impersonate-Group + if err := r.SetHeaderParam("Impersonate-Group", *o.ImpersonateGroup); err != nil { + return err + } + } + + if o.ImpersonateUser != nil { + + // header param Impersonate-User + if err := r.SetHeaderParam("Impersonate-User", *o.ImpersonateUser); err != nil { + return err + } + } + + // path param appName + if err := r.SetPathParam("appName", o.AppName); err != nil { + return err + } + + // path param componentName + if err := r.SetPathParam("componentName", o.ComponentName); err != nil { + return err + } + + // path param envName + if err := r.SetPathParam("envName", o.EnvName); err != nil { + return err + } + + // path param fqdn + if err := r.SetPathParam("fqdn", o.Fqdn); err != nil { + return err + } + if o.TLSData != nil { + if err := r.SetBodyParam(o.TLSData); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/generated-client/client/component/update_component_external_dns_tls_responses.go b/generated-client/client/component/update_component_external_dns_tls_responses.go new file mode 100644 index 0000000..8b4ed00 --- /dev/null +++ b/generated-client/client/component/update_component_external_dns_tls_responses.go @@ -0,0 +1,460 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package component + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// UpdateComponentExternalDNSTLSReader is a Reader for the UpdateComponentExternalDNSTLS structure. +type UpdateComponentExternalDNSTLSReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdateComponentExternalDNSTLSReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUpdateComponentExternalDNSTLSOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewUpdateComponentExternalDNSTLSBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewUpdateComponentExternalDNSTLSUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewUpdateComponentExternalDNSTLSForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewUpdateComponentExternalDNSTLSNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 409: + result := NewUpdateComponentExternalDNSTLSConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewUpdateComponentExternalDNSTLSInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls] updateComponentExternalDnsTls", response, response.Code()) + } +} + +// NewUpdateComponentExternalDNSTLSOK creates a UpdateComponentExternalDNSTLSOK with default headers values +func NewUpdateComponentExternalDNSTLSOK() *UpdateComponentExternalDNSTLSOK { + return &UpdateComponentExternalDNSTLSOK{} +} + +/* +UpdateComponentExternalDNSTLSOK describes a response with status code 200, with default header values. + +success +*/ +type UpdateComponentExternalDNSTLSOK struct { +} + +// IsSuccess returns true when this update component external Dns Tls o k response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this update component external Dns Tls o k response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls o k response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this update component external Dns Tls o k response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSOK) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls o k response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the update component external Dns Tls o k response +func (o *UpdateComponentExternalDNSTLSOK) Code() int { + return 200 +} + +func (o *UpdateComponentExternalDNSTLSOK) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsOK ", 200) +} + +func (o *UpdateComponentExternalDNSTLSOK) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsOK ", 200) +} + +func (o *UpdateComponentExternalDNSTLSOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSBadRequest creates a UpdateComponentExternalDNSTLSBadRequest with default headers values +func NewUpdateComponentExternalDNSTLSBadRequest() *UpdateComponentExternalDNSTLSBadRequest { + return &UpdateComponentExternalDNSTLSBadRequest{} +} + +/* +UpdateComponentExternalDNSTLSBadRequest describes a response with status code 400, with default header values. + +Invalid application +*/ +type UpdateComponentExternalDNSTLSBadRequest struct { +} + +// IsSuccess returns true when this update component external Dns Tls bad request response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls bad request response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls bad request response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls bad request response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls bad request response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the update component external Dns Tls bad request response +func (o *UpdateComponentExternalDNSTLSBadRequest) Code() int { + return 400 +} + +func (o *UpdateComponentExternalDNSTLSBadRequest) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsBadRequest ", 400) +} + +func (o *UpdateComponentExternalDNSTLSBadRequest) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsBadRequest ", 400) +} + +func (o *UpdateComponentExternalDNSTLSBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSUnauthorized creates a UpdateComponentExternalDNSTLSUnauthorized with default headers values +func NewUpdateComponentExternalDNSTLSUnauthorized() *UpdateComponentExternalDNSTLSUnauthorized { + return &UpdateComponentExternalDNSTLSUnauthorized{} +} + +/* +UpdateComponentExternalDNSTLSUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type UpdateComponentExternalDNSTLSUnauthorized struct { +} + +// IsSuccess returns true when this update component external Dns Tls unauthorized response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls unauthorized response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls unauthorized response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls unauthorized response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls unauthorized response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the update component external Dns Tls unauthorized response +func (o *UpdateComponentExternalDNSTLSUnauthorized) Code() int { + return 401 +} + +func (o *UpdateComponentExternalDNSTLSUnauthorized) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsUnauthorized ", 401) +} + +func (o *UpdateComponentExternalDNSTLSUnauthorized) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsUnauthorized ", 401) +} + +func (o *UpdateComponentExternalDNSTLSUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSForbidden creates a UpdateComponentExternalDNSTLSForbidden with default headers values +func NewUpdateComponentExternalDNSTLSForbidden() *UpdateComponentExternalDNSTLSForbidden { + return &UpdateComponentExternalDNSTLSForbidden{} +} + +/* +UpdateComponentExternalDNSTLSForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type UpdateComponentExternalDNSTLSForbidden struct { +} + +// IsSuccess returns true when this update component external Dns Tls forbidden response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls forbidden response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls forbidden response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls forbidden response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls forbidden response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the update component external Dns Tls forbidden response +func (o *UpdateComponentExternalDNSTLSForbidden) Code() int { + return 403 +} + +func (o *UpdateComponentExternalDNSTLSForbidden) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsForbidden ", 403) +} + +func (o *UpdateComponentExternalDNSTLSForbidden) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsForbidden ", 403) +} + +func (o *UpdateComponentExternalDNSTLSForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSNotFound creates a UpdateComponentExternalDNSTLSNotFound with default headers values +func NewUpdateComponentExternalDNSTLSNotFound() *UpdateComponentExternalDNSTLSNotFound { + return &UpdateComponentExternalDNSTLSNotFound{} +} + +/* +UpdateComponentExternalDNSTLSNotFound describes a response with status code 404, with default header values. + +Not found +*/ +type UpdateComponentExternalDNSTLSNotFound struct { +} + +// IsSuccess returns true when this update component external Dns Tls not found response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls not found response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls not found response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls not found response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls not found response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the update component external Dns Tls not found response +func (o *UpdateComponentExternalDNSTLSNotFound) Code() int { + return 404 +} + +func (o *UpdateComponentExternalDNSTLSNotFound) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsNotFound ", 404) +} + +func (o *UpdateComponentExternalDNSTLSNotFound) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsNotFound ", 404) +} + +func (o *UpdateComponentExternalDNSTLSNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSConflict creates a UpdateComponentExternalDNSTLSConflict with default headers values +func NewUpdateComponentExternalDNSTLSConflict() *UpdateComponentExternalDNSTLSConflict { + return &UpdateComponentExternalDNSTLSConflict{} +} + +/* +UpdateComponentExternalDNSTLSConflict describes a response with status code 409, with default header values. + +Conflict +*/ +type UpdateComponentExternalDNSTLSConflict struct { +} + +// IsSuccess returns true when this update component external Dns Tls conflict response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSConflict) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls conflict response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSConflict) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls conflict response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSConflict) IsClientError() bool { + return true +} + +// IsServerError returns true when this update component external Dns Tls conflict response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSConflict) IsServerError() bool { + return false +} + +// IsCode returns true when this update component external Dns Tls conflict response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSConflict) IsCode(code int) bool { + return code == 409 +} + +// Code gets the status code for the update component external Dns Tls conflict response +func (o *UpdateComponentExternalDNSTLSConflict) Code() int { + return 409 +} + +func (o *UpdateComponentExternalDNSTLSConflict) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsConflict ", 409) +} + +func (o *UpdateComponentExternalDNSTLSConflict) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsConflict ", 409) +} + +func (o *UpdateComponentExternalDNSTLSConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewUpdateComponentExternalDNSTLSInternalServerError creates a UpdateComponentExternalDNSTLSInternalServerError with default headers values +func NewUpdateComponentExternalDNSTLSInternalServerError() *UpdateComponentExternalDNSTLSInternalServerError { + return &UpdateComponentExternalDNSTLSInternalServerError{} +} + +/* +UpdateComponentExternalDNSTLSInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type UpdateComponentExternalDNSTLSInternalServerError struct { +} + +// IsSuccess returns true when this update component external Dns Tls internal server error response has a 2xx status code +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this update component external Dns Tls internal server error response has a 3xx status code +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this update component external Dns Tls internal server error response has a 4xx status code +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this update component external Dns Tls internal server error response has a 5xx status code +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this update component external Dns Tls internal server error response a status code equal to that given +func (o *UpdateComponentExternalDNSTLSInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the update component external Dns Tls internal server error response +func (o *UpdateComponentExternalDNSTLSInternalServerError) Code() int { + return 500 +} + +func (o *UpdateComponentExternalDNSTLSInternalServerError) Error() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsInternalServerError ", 500) +} + +func (o *UpdateComponentExternalDNSTLSInternalServerError) String() string { + return fmt.Sprintf("[PUT /applications/{appName}/environments/{envName}/components/{componentName}/externaldns/{fqdn}/tls][%d] updateComponentExternalDnsTlsInternalServerError ", 500) +} + +func (o *UpdateComponentExternalDNSTLSInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/generated-client/models/component.go b/generated-client/models/component.go index df70340..d1d70e4 100644 --- a/generated-client/models/component.go +++ b/generated-client/models/component.go @@ -21,6 +21,9 @@ import ( // swagger:model Component type Component struct { + // Array of external DNS configurations + ExternalDNS []*ExternalDNS `json:"externalDNS"` + // Image name // Example: radixdev.azurecr.io/app-server:cdgkg // Required: true @@ -84,6 +87,10 @@ type Component struct { func (m *Component) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateExternalDNS(formats); err != nil { + res = append(res, err) + } + if err := m.validateImage(formats); err != nil { res = append(res, err) } @@ -130,6 +137,32 @@ func (m *Component) Validate(formats strfmt.Registry) error { return nil } +func (m *Component) validateExternalDNS(formats strfmt.Registry) error { + if swag.IsZero(m.ExternalDNS) { // not required + return nil + } + + for i := 0; i < len(m.ExternalDNS); i++ { + if swag.IsZero(m.ExternalDNS[i]) { // not required + continue + } + + if m.ExternalDNS[i] != nil { + if err := m.ExternalDNS[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("externalDNS" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("externalDNS" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Component) validateImage(formats strfmt.Registry) error { if err := validate.Required("image", "body", m.Image); err != nil { @@ -374,6 +407,10 @@ func (m *Component) validateOauth2(formats strfmt.Registry) error { func (m *Component) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error + if err := m.contextValidateExternalDNS(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidatePorts(ctx, formats); err != nil { res = append(res, err) } @@ -404,6 +441,31 @@ func (m *Component) ContextValidate(ctx context.Context, formats strfmt.Registry return nil } +func (m *Component) contextValidateExternalDNS(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.ExternalDNS); i++ { + + if m.ExternalDNS[i] != nil { + + if swag.IsZero(m.ExternalDNS[i]) { // not required + return nil + } + + if err := m.ExternalDNS[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("externalDNS" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("externalDNS" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Component) contextValidatePorts(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Ports); i++ { diff --git a/generated-client/models/external_dns.go b/generated-client/models/external_dns.go new file mode 100644 index 0000000..d5239d8 --- /dev/null +++ b/generated-client/models/external_dns.go @@ -0,0 +1,126 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ExternalDNS ExternalDNS describes an external DNS entry for a component +// +// swagger:model ExternalDNS +type ExternalDNS struct { + + // Fully Qualified Domain Name + // Example: site.example.com + // Required: true + FQDN *string `json:"fqdn"` + + // tls + // Required: true + TLS *TLS `json:"tls"` +} + +// Validate validates this external DNS +func (m *ExternalDNS) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateFQDN(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTLS(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExternalDNS) validateFQDN(formats strfmt.Registry) error { + + if err := validate.Required("fqdn", "body", m.FQDN); err != nil { + return err + } + + return nil +} + +func (m *ExternalDNS) validateTLS(formats strfmt.Registry) error { + + if err := validate.Required("tls", "body", m.TLS); err != nil { + return err + } + + if m.TLS != nil { + if err := m.TLS.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tls") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tls") + } + return err + } + } + + return nil +} + +// ContextValidate validate this external DNS based on the context it is used +func (m *ExternalDNS) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateTLS(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExternalDNS) contextValidateTLS(ctx context.Context, formats strfmt.Registry) error { + + if m.TLS != nil { + + if err := m.TLS.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tls") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tls") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ExternalDNS) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ExternalDNS) UnmarshalBinary(b []byte) error { + var res ExternalDNS + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/generated-client/models/secret.go b/generated-client/models/secret.go index a6016e9..e332d9d 100644 --- a/generated-client/models/secret.go +++ b/generated-client/models/secret.go @@ -8,7 +8,6 @@ package models import ( "context" "encoding/json" - "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" @@ -47,19 +46,11 @@ type Secret struct { // Consistent = Secret exists in Radix config and in cluster // NotAvailable = Secret is available in external secret configuration but not in cluster // Example: Consistent - // Enum: [Pending Consistent NotAvailable Invalid] + // Enum: [Pending Consistent NotAvailable] Status string `json:"status,omitempty"` - // StatusMessages contains a list of messages related to the Status - StatusMessages []string `json:"statusMessages"` - - // TLSCertificates holds the TLS certificate and certificate authorities (CA) - // The first certificate in the list should be the TLS certificate and the rest should be CA certificates - TLSCertificates []*TLSCertificate `json:"tlsCertificates"` - // Type of the secret // generic SecretTypeGeneric - // client-cert SecretTypeClientCert // azure-blob-fuse-volume SecretTypeAzureBlobFuseVolume // csi-azure-blob-volume SecretTypeCsiAzureBlobVolume // csi-azure-key-vault-creds SecretTypeCsiAzureKeyVaultCreds @@ -67,7 +58,7 @@ type Secret struct { // client-cert-auth SecretTypeClientCertificateAuth // oauth2-proxy SecretTypeOAuth2Proxy // Example: client-cert - // Enum: [generic client-cert azure-blob-fuse-volume csi-azure-blob-volume csi-azure-key-vault-creds csi-azure-key-vault-item client-cert-auth oauth2-proxy] + // Enum: [generic azure-blob-fuse-volume csi-azure-blob-volume csi-azure-key-vault-creds csi-azure-key-vault-item client-cert-auth oauth2-proxy] Type string `json:"type,omitempty"` } @@ -83,10 +74,6 @@ func (m *Secret) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateTLSCertificates(formats); err != nil { - res = append(res, err) - } - if err := m.validateType(formats); err != nil { res = append(res, err) } @@ -110,7 +97,7 @@ var secretTypeStatusPropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["Pending","Consistent","NotAvailable","Invalid"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["Pending","Consistent","NotAvailable"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -128,9 +115,6 @@ const ( // SecretStatusNotAvailable captures enum value "NotAvailable" SecretStatusNotAvailable string = "NotAvailable" - - // SecretStatusInvalid captures enum value "Invalid" - SecretStatusInvalid string = "Invalid" ) // prop value enum @@ -154,37 +138,11 @@ func (m *Secret) validateStatus(formats strfmt.Registry) error { return nil } -func (m *Secret) validateTLSCertificates(formats strfmt.Registry) error { - if swag.IsZero(m.TLSCertificates) { // not required - return nil - } - - for i := 0; i < len(m.TLSCertificates); i++ { - if swag.IsZero(m.TLSCertificates[i]) { // not required - continue - } - - if m.TLSCertificates[i] != nil { - if err := m.TLSCertificates[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("tlsCertificates" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("tlsCertificates" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - - return nil -} - var secretTypeTypePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["generic","client-cert","azure-blob-fuse-volume","csi-azure-blob-volume","csi-azure-key-vault-creds","csi-azure-key-vault-item","client-cert-auth","oauth2-proxy"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["generic","azure-blob-fuse-volume","csi-azure-blob-volume","csi-azure-key-vault-creds","csi-azure-key-vault-item","client-cert-auth","oauth2-proxy"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -197,9 +155,6 @@ const ( // SecretTypeGeneric captures enum value "generic" SecretTypeGeneric string = "generic" - // SecretTypeClientDashCert captures enum value "client-cert" - SecretTypeClientDashCert string = "client-cert" - // SecretTypeAzureDashBlobDashFuseDashVolume captures enum value "azure-blob-fuse-volume" SecretTypeAzureDashBlobDashFuseDashVolume string = "azure-blob-fuse-volume" @@ -240,42 +195,8 @@ func (m *Secret) validateType(formats strfmt.Registry) error { return nil } -// ContextValidate validate this secret based on the context it is used +// ContextValidate validates this secret based on context it is used func (m *Secret) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateTLSCertificates(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *Secret) contextValidateTLSCertificates(ctx context.Context, formats strfmt.Registry) error { - - for i := 0; i < len(m.TLSCertificates); i++ { - - if m.TLSCertificates[i] != nil { - - if swag.IsZero(m.TLSCertificates[i]) { // not required - return nil - } - - if err := m.TLSCertificates[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("tlsCertificates" + "." + strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName("tlsCertificates" + "." + strconv.Itoa(i)) - } - return err - } - } - - } - return nil } diff --git a/generated-client/models/secret_parameters.go b/generated-client/models/secret_parameters.go index b48776c..643f646 100644 --- a/generated-client/models/secret_parameters.go +++ b/generated-client/models/secret_parameters.go @@ -27,7 +27,6 @@ type SecretParameters struct { // Type of the secret // generic SecretTypeGeneric - // client-cert SecretTypeClientCert // azure-blob-fuse-volume SecretTypeAzureBlobFuseVolume // csi-azure-blob-volume SecretTypeCsiAzureBlobVolume // csi-azure-key-vault-creds SecretTypeCsiAzureKeyVaultCreds @@ -35,7 +34,7 @@ type SecretParameters struct { // client-cert-auth SecretTypeClientCertificateAuth // oauth2-proxy SecretTypeOAuth2Proxy // Example: azure-blob-fuse-volume - // Enum: [generic client-cert azure-blob-fuse-volume csi-azure-blob-volume csi-azure-key-vault-creds csi-azure-key-vault-item client-cert-auth oauth2-proxy] + // Enum: [generic azure-blob-fuse-volume csi-azure-blob-volume csi-azure-key-vault-creds csi-azure-key-vault-item client-cert-auth oauth2-proxy] Type string `json:"type,omitempty"` } @@ -70,7 +69,7 @@ var secretParametersTypeTypePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["generic","client-cert","azure-blob-fuse-volume","csi-azure-blob-volume","csi-azure-key-vault-creds","csi-azure-key-vault-item","client-cert-auth","oauth2-proxy"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["generic","azure-blob-fuse-volume","csi-azure-blob-volume","csi-azure-key-vault-creds","csi-azure-key-vault-item","client-cert-auth","oauth2-proxy"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -83,9 +82,6 @@ const ( // SecretParametersTypeGeneric captures enum value "generic" SecretParametersTypeGeneric string = "generic" - // SecretParametersTypeClientDashCert captures enum value "client-cert" - SecretParametersTypeClientDashCert string = "client-cert" - // SecretParametersTypeAzureDashBlobDashFuseDashVolume captures enum value "azure-blob-fuse-volume" SecretParametersTypeAzureDashBlobDashFuseDashVolume string = "azure-blob-fuse-volume" diff --git a/generated-client/models/step.go b/generated-client/models/step.go index f433f9c..b47e10f 100644 --- a/generated-client/models/step.go +++ b/generated-client/models/step.go @@ -24,16 +24,16 @@ type Step struct { Components []string `json:"components"` // Ended timestamp - // Example: 2006-01-02T15:04:05Z - Ended string `json:"ended,omitempty"` + // Format: date-time + Ended strfmt.DateTime `json:"ended,omitempty"` // Name of the step // Example: build Name string `json:"name,omitempty"` // Started timestamp - // Example: 2006-01-02T15:04:05Z - Started string `json:"started,omitempty"` + // Format: date-time + Started strfmt.DateTime `json:"started,omitempty"` // Status of the step // Example: Waiting @@ -45,6 +45,14 @@ type Step struct { func (m *Step) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateEnded(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStarted(formats); err != nil { + res = append(res, err) + } + if err := m.validateStatus(formats); err != nil { res = append(res, err) } @@ -55,6 +63,30 @@ func (m *Step) Validate(formats strfmt.Registry) error { return nil } +func (m *Step) validateEnded(formats strfmt.Registry) error { + if swag.IsZero(m.Ended) { // not required + return nil + } + + if err := validate.FormatOf("ended", "body", "date-time", m.Ended.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Step) validateStarted(formats strfmt.Registry) error { + if swag.IsZero(m.Started) { // not required + return nil + } + + if err := validate.FormatOf("started", "body", "date-time", m.Started.String(), formats); err != nil { + return err + } + + return nil +} + var stepTypeStatusPropEnum []interface{} func init() { diff --git a/generated-client/models/tls.go b/generated-client/models/tls.go new file mode 100644 index 0000000..31d3421 --- /dev/null +++ b/generated-client/models/tls.go @@ -0,0 +1,203 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TLS TLS configuration and status for external DNS +// +// swagger:model TLS +type TLS struct { + + // Certificates holds the X509 certificate chain + // The first certificate in the list should be the host certificate and the rest should be intermediate certificates + Certificates []*X509Certificate `json:"certificates"` + + // Status of TLS certificate and private key + // Pending TLSStatusPending TLS certificate and private key not set + // Consistent TLSStatusConsistent TLS certificate and private key is valid + // Invalid TLSStatusInvalid TLS certificate and private key is invalid + // Example: Consistent + // Required: true + // Enum: [Pending Consistent Invalid] + Status *string `json:"status"` + + // StatusMessages contains a list of messages related to Status + StatusMessages []string `json:"statusMessages"` + + // UseAutomation describes if TLS certificate is automatically issued using automation (ACME) + // Required: true + UseAutomation *bool `json:"useAutomation"` +} + +// Validate validates this TLS +func (m *TLS) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCertificates(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUseAutomation(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TLS) validateCertificates(formats strfmt.Registry) error { + if swag.IsZero(m.Certificates) { // not required + return nil + } + + for i := 0; i < len(m.Certificates); i++ { + if swag.IsZero(m.Certificates[i]) { // not required + continue + } + + if m.Certificates[i] != nil { + if err := m.Certificates[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("certificates" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("certificates" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +var tlsTypeStatusPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["Pending","Consistent","Invalid"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + tlsTypeStatusPropEnum = append(tlsTypeStatusPropEnum, v) + } +} + +const ( + + // TLSStatusPending captures enum value "Pending" + TLSStatusPending string = "Pending" + + // TLSStatusConsistent captures enum value "Consistent" + TLSStatusConsistent string = "Consistent" + + // TLSStatusInvalid captures enum value "Invalid" + TLSStatusInvalid string = "Invalid" +) + +// prop value enum +func (m *TLS) validateStatusEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, tlsTypeStatusPropEnum, true); err != nil { + return err + } + return nil +} + +func (m *TLS) validateStatus(formats strfmt.Registry) error { + + if err := validate.Required("status", "body", m.Status); err != nil { + return err + } + + // value enum + if err := m.validateStatusEnum("status", "body", *m.Status); err != nil { + return err + } + + return nil +} + +func (m *TLS) validateUseAutomation(formats strfmt.Registry) error { + + if err := validate.Required("useAutomation", "body", m.UseAutomation); err != nil { + return err + } + + return nil +} + +// ContextValidate validate this TLS based on the context it is used +func (m *TLS) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateCertificates(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TLS) contextValidateCertificates(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Certificates); i++ { + + if m.Certificates[i] != nil { + + if swag.IsZero(m.Certificates[i]) { // not required + return nil + } + + if err := m.Certificates[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("certificates" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("certificates" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TLS) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TLS) UnmarshalBinary(b []byte) error { + var res TLS + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/generated-client/models/update_external_dns_tls_request.go b/generated-client/models/update_external_dns_tls_request.go new file mode 100644 index 0000000..29120a3 --- /dev/null +++ b/generated-client/models/update_external_dns_tls_request.go @@ -0,0 +1,91 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// UpdateExternalDNSTLSRequest UpdateExternalDNSTLSRequest describes request body for setting private key and certificate for external DNS TLS +// +// swagger:model UpdateExternalDNSTLSRequest +type UpdateExternalDNSTLSRequest struct { + + // X509 certificate in PEM format + // Required: true + Certificate *string `json:"certificate"` + + // Private key in PEM format + // Required: true + PrivateKey *string `json:"privateKey"` + + // Skip validation of certificate and private key + SkipValidation bool `json:"skipValidation,omitempty"` +} + +// Validate validates this update external DNS TLS request +func (m *UpdateExternalDNSTLSRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCertificate(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePrivateKey(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateExternalDNSTLSRequest) validateCertificate(formats strfmt.Registry) error { + + if err := validate.Required("certificate", "body", m.Certificate); err != nil { + return err + } + + return nil +} + +func (m *UpdateExternalDNSTLSRequest) validatePrivateKey(formats strfmt.Registry) error { + + if err := validate.Required("privateKey", "body", m.PrivateKey); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this update external DNS TLS request based on context it is used +func (m *UpdateExternalDNSTLSRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UpdateExternalDNSTLSRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UpdateExternalDNSTLSRequest) UnmarshalBinary(b []byte) error { + var res UpdateExternalDNSTLSRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/generated-client/models/x509_certificate.go b/generated-client/models/x509_certificate.go new file mode 100644 index 0000000..f47f4d2 --- /dev/null +++ b/generated-client/models/x509_certificate.go @@ -0,0 +1,137 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// X509Certificate X509Certificate holds information about a X509 certificate +// +// swagger:model X509Certificate +type X509Certificate struct { + + // DNSNames defines list of Subject Alternate Names in the certificate + DNSNames []string `json:"dnsNames"` + + // Issuer contains the distinguished name for the certificate's issuer + // Example: CN=DigiCert TLS RSA SHA256 2020 CA1,O=DigiCert Inc,C=US + // Required: true + Issuer *string `json:"issuer"` + + // NotAfter defines the uppdater date/time validity boundary + // Required: true + // Format: date-time + NotAfter *strfmt.DateTime `json:"notAfter"` + + // NotBefore defines the lower date/time validity boundary + // Required: true + // Format: date-time + NotBefore *strfmt.DateTime `json:"notBefore"` + + // Subject contains the distinguished name for the certificate + // Example: CN=mysite.example.com,O=MyOrg,L=MyLocation,C=NO + // Required: true + Subject *string `json:"subject"` +} + +// Validate validates this x509 certificate +func (m *X509Certificate) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateIssuer(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNotAfter(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNotBefore(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSubject(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *X509Certificate) validateIssuer(formats strfmt.Registry) error { + + if err := validate.Required("issuer", "body", m.Issuer); err != nil { + return err + } + + return nil +} + +func (m *X509Certificate) validateNotAfter(formats strfmt.Registry) error { + + if err := validate.Required("notAfter", "body", m.NotAfter); err != nil { + return err + } + + if err := validate.FormatOf("notAfter", "body", "date-time", m.NotAfter.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *X509Certificate) validateNotBefore(formats strfmt.Registry) error { + + if err := validate.Required("notBefore", "body", m.NotBefore); err != nil { + return err + } + + if err := validate.FormatOf("notBefore", "body", "date-time", m.NotBefore.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *X509Certificate) validateSubject(formats strfmt.Registry) error { + + if err := validate.Required("subject", "body", m.Subject); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this x509 certificate based on context it is used +func (m *X509Certificate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *X509Certificate) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *X509Certificate) UnmarshalBinary(b []byte) error { + var res X509Certificate + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/go.mod b/go.mod index caed062..a8bcac6 100644 --- a/go.mod +++ b/go.mod @@ -5,14 +5,14 @@ go 1.21 toolchain go1.21.0 require ( - github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0 - github.com/equinor/radix-operator v1.47.2 + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 + github.com/equinor/radix-operator v1.49.0 github.com/fatih/color v1.15.0 github.com/go-openapi/errors v0.20.4 - github.com/go-openapi/runtime v0.26.0 - github.com/go-openapi/strfmt v0.21.7 + github.com/go-openapi/runtime v0.26.2 + github.com/go-openapi/strfmt v0.21.8 github.com/go-openapi/swag v0.22.4 - github.com/go-openapi/validate v0.22.1 + github.com/go-openapi/validate v0.22.3 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.0 @@ -34,7 +34,7 @@ require ( github.com/go-openapi/jsonpointer v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/loads v0.21.2 // indirect - github.com/go-openapi/spec v0.20.8 // indirect + github.com/go-openapi/spec v0.20.11 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v5 v5.0.0 // indirect github.com/golang/mock v1.6.0 // indirect @@ -66,7 +66,7 @@ require ( github.com/prometheus/common v0.45.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.mongodb.org/mongo-driver v1.11.3 // indirect + go.mongodb.org/mongo-driver v1.13.1 // indirect go.opentelemetry.io/otel v1.19.0 // indirect go.opentelemetry.io/otel/metric v1.19.0 // indirect go.opentelemetry.io/otel/trace v1.19.0 // indirect diff --git a/go.sum b/go.sum index f226ec4..75436d5 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,7 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0 h1:HCc0+LpPfpCKs6LGGLAhwBARt9632unrVcI6i8s/8os= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= @@ -22,8 +19,8 @@ github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxER github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/equinor/radix-common v1.7.1 h1:kl7Tuo2VEo2WHGm/vkvktrZ9t9S3Nht7Mob3CSIzcJI= github.com/equinor/radix-common v1.7.1/go.mod h1:M6mhgHtFQ3rnjJnyOuECXiZOh7XQ5xVeHMyCAU+YPzQ= -github.com/equinor/radix-operator v1.47.2 h1:QYOIDhx0zfjrHcipl/AuO+O8cMOqQ6ELESoIsj0BWZo= -github.com/equinor/radix-operator v1.47.2/go.mod h1:kwwnvyW1WKCKiXVSKNhkG7zAe1sFC2XW9IbNZsCCgRw= +github.com/equinor/radix-operator v1.49.0 h1:yNdb0zocBw7GdWybAGUm2lWmk6I+xeeCjvrN8xjVTyA= +github.com/equinor/radix-operator v1.49.0/go.mod h1:i8A6V/g1OM+Zk2lAASZaoX+lHdJIZYYZHA586SHB2p8= github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= @@ -33,11 +30,8 @@ github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY= github.com/go-openapi/analysis v0.21.4 h1:ZDFLvSNxpDaomuCueM0BlSXxpANBlFYiBvr+GXrvIHc= github.com/go-openapi/analysis v0.21.4/go.mod h1:4zQ35W4neeZTqh3ol0rv/O8JBbka9QyAgQRPp9y3pfo= -github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= -github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= github.com/go-openapi/errors v0.20.4 h1:unTcVm6PispJsMECE3zWgvG4xTiKda1LIR5rCRWLG6M= github.com/go-openapi/errors v0.20.4/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= @@ -46,59 +40,29 @@ github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34 github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3KYD14BXdQ= github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA= -github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/loads v0.21.1/go.mod h1:/DtAMXXneXFjbQMGEtbamCZb+4x7eGwkvZCvBmwUG+g= github.com/go-openapi/loads v0.21.2 h1:r2a/xFIYeZ4Qd2TnGpWDIQNcP80dIaZgf704za8enro= github.com/go-openapi/loads v0.21.2/go.mod h1:Jq58Os6SSGz0rzh62ptiu8Z31I+OTHqmULx5e/gJbNw= -github.com/go-openapi/runtime v0.26.0 h1:HYOFtG00FM1UvqrcxbEJg/SwvDRvYLQKGhw2zaQjTcc= -github.com/go-openapi/runtime v0.26.0/go.mod h1:QgRGeZwrUcSHdeh4Ka9Glvo0ug1LC5WyE+EV88plZrQ= -github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/runtime v0.26.2 h1:elWyB9MacRzvIVgAZCBJmqTi7hBzU0hlKD4IvfX0Zl0= +github.com/go-openapi/runtime v0.26.2/go.mod h1:O034jyRZ557uJKzngbMDJXkcKJVzXJiymdSfgejrcRw= github.com/go-openapi/spec v0.20.6/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= -github.com/go-openapi/spec v0.20.8 h1:ubHmXNY3FCIOinT8RNrrPfGc9t7I1qhPtdOGoG2AxRU= -github.com/go-openapi/spec v0.20.8/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= -github.com/go-openapi/strfmt v0.21.0/go.mod h1:ZRQ409bWMj+SOgXofQAGTIo2Ebu72Gs+WaRADcS5iNg= -github.com/go-openapi/strfmt v0.21.1/go.mod h1:I/XVKeLc5+MM5oPNN7P6urMOpuLXEcNrCX/rPGuWb0k= +github.com/go-openapi/spec v0.20.11 h1:J/TzFDLTt4Rcl/l1PmyErvkqlJDncGvPTMnCI39I4gY= +github.com/go-openapi/spec v0.20.11/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= github.com/go-openapi/strfmt v0.21.3/go.mod h1:k+RzNO0Da+k3FrrynSNN8F7n/peCmQQqbbXjtDfvmGg= -github.com/go-openapi/strfmt v0.21.7 h1:rspiXgNWgeUzhjo1YU01do6qsahtJNByjLVbPLNHb8k= -github.com/go-openapi/strfmt v0.21.7/go.mod h1:adeGTkxE44sPyLk0JV235VQAO/ZXUr8KAzYjclFs3ew= +github.com/go-openapi/strfmt v0.21.8 h1:VYBUoKYRLAlgKDrIxR/I0lKrztDQ0tuTDrbhLVP8Erg= +github.com/go-openapi/strfmt v0.21.8/go.mod h1:adeGTkxE44sPyLk0JV235VQAO/ZXUr8KAzYjclFs3ew= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-openapi/validate v0.22.1 h1:G+c2ub6q47kfX1sOBLwIQwzBVt8qmOAARyo/9Fqs9NU= -github.com/go-openapi/validate v0.22.1/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUriMu5/zuPSQ1hg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-openapi/validate v0.22.3 h1:KxG9mu5HBRYbecRb37KRCihvGGtND2aXziBAv0NNfyI= +github.com/go-openapi/validate v0.22.3/go.mod h1:kVxh31KbfsxU8ZyoHaDbLBWU5CnMdqBUEtadQ2G4d5M= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= -github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= -github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= -github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= -github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= -github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= -github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= -github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= -github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= -github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= -github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= -github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= -github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= -github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= -github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= -github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= @@ -127,21 +91,15 @@ github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= -github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -157,8 +115,6 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= -github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -188,11 +144,8 @@ github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -210,28 +163,19 @@ github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lne github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -240,23 +184,20 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= -github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= -go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= -go.mongodb.org/mongo-driver v1.11.3 h1:Ql6K6qYHEzB6xvu4+AU0BoRoqf9vFPcc4o7MUIdPW8Y= -go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= +go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk= +go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo= go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs= go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY= go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE= @@ -265,11 +206,8 @@ go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJ go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg= go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -279,38 +217,28 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -328,19 +256,15 @@ golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -363,7 +287,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -373,7 +296,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/client/client.go b/pkg/client/client.go index 19957a3..a546b9f 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -11,7 +11,7 @@ import ( apiclient "github.com/equinor/radix-cli/generated-client/client" "github.com/equinor/radix-cli/pkg/client/auth" radixconfig "github.com/equinor/radix-cli/pkg/config" - "github.com/equinor/radix-cli/pkg/settings" + "github.com/equinor/radix-cli/pkg/flagnames" "github.com/go-openapi/runtime" httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" @@ -44,7 +44,7 @@ func GetForCommand(cmd *cobra.Command) (*apiclient.Radixapi, error) { if err != nil { return nil, err } - verboseOutput, _ := cmd.Flags().GetBool(settings.VerboseOption) + verboseOutput, _ := cmd.Flags().GetBool(flagnames.Verbose) transport := getTransport(endpoint, authWriter, verboseOutput) return apiclient.New(transport, strfmt.Default), nil } @@ -63,7 +63,7 @@ func getAPIEndpoint(cmd *cobra.Command, config *radixconfig.RadixConfig) (string } if cluster != "" { - apiEnvironment, _ := cmd.Flags().GetString(settings.ApiEnvironmentOption) + apiEnvironment, _ := cmd.Flags().GetString(flagnames.ApiEnvironment) return getAPIEndpointForCluster(cluster, apiEnvironment), nil } @@ -103,7 +103,7 @@ func LogoutCommand() error { func getContextAndCluster(cmd *cobra.Command) (string, string, error) { context, _ := cmd.Flags().GetString("context") - cluster, _ := cmd.Flags().GetString(settings.ClusterOption) + cluster, _ := cmd.Flags().GetString(flagnames.Cluster) if context != "" && cluster != "" { return "", "", errors.New("cannot use both context and cluster as arguments at the same time") @@ -158,8 +158,8 @@ func getPatternForContext(context string) string { func getTokenFromFlagSet(cmd *cobra.Command) (*string, error) { var token string - tokenFromStdIn, _ := cmd.Flags().GetBool(settings.TokenStdinOption) - tokenFromEnvironment, _ := cmd.Flags().GetBool(settings.TokenEnvironmentOption) + tokenFromStdIn, _ := cmd.Flags().GetBool(flagnames.TokenStdin) + tokenFromEnvironment, _ := cmd.Flags().GetBool(flagnames.TokenEnvironment) if tokenFromStdIn && tokenFromEnvironment { return nil, errors.New("`token-stdin` and `token-environment` cannot both be set") diff --git a/pkg/flagnames/names.go b/pkg/flagnames/names.go new file mode 100644 index 0000000..65db67b --- /dev/null +++ b/pkg/flagnames/names.go @@ -0,0 +1,46 @@ +package flagnames + +const ( + AcknowledgeWarnings = "acknowledge-warnings" + AdminADGroups = "ad-groups" + Alias = "alias" + ApiEnvironment = "api-environment" + Application = "application" + AwaitReconcile = "await-reconcile" + Branch = "branch" + Certificate = "certificate" + CertificateFromFile = "certificate-from-file" + Cluster = "cluster" + CommitID = "commitID" + Component = "component" + ConfigurationItem = "configuration-item" + ConfigBranch = "config-branch" + ConfigFile = "config-file" + Context = "context" + Deployment = "deployment" + Environment = "environment" + Follow = "follow" + FromConfig = "from-config" + FromEnvironment = "from-environment" + ImageTagName = "image-tag-name" + Job = "job" + Previous = "previous" + Print = "print" + PrivateKey = "private-key" + PrivateKeyFromFile = "private-key-from-file" + ReaderADGroups = "reader-ad-groups" + Replicas = "replicas" + Repository = "repository" + Secret = "secret" + SharedSecret = "shared-secret" + Since = "since" + SkipValidation = "skip-validation" + ToEnvironment = "to-environment" + TokenEnvironment = "token-environment" + TokenStdin = "token-stdin" + UseActiveDeployment = "use-active-deployment" + User = "user" + Variable = "variable" + Verbose = "verbose" + Value = "value" +) diff --git a/pkg/settings/settings.go b/pkg/settings/settings.go index f8982a7..8683f4e 100644 --- a/pkg/settings/settings.go +++ b/pkg/settings/settings.go @@ -5,12 +5,4 @@ import "time" const ( DeltaRefreshApplication = 3 * time.Second DeltaTimeout = 30 * time.Second - - FromConfigOption = "from-config" - TokenEnvironmentOption = "token-environment" - TokenStdinOption = "token-stdin" - ContextOption = "context" - ClusterOption = "cluster" - ApiEnvironmentOption = "api-environment" - VerboseOption = "verbose" )