From 41b04df340d901f95bfd5eaafc217ce5e28875ff Mon Sep 17 00:00:00 2001 From: Amin Salarkia Date: Wed, 23 Oct 2024 14:34:44 +0200 Subject: [PATCH] fix(cli): option to run release trains on environment groups when dex is enabled (#2059) Ref: SRX-880CZF --- cli/pkg/releasetrain/releasetrain.go | 4 ++++ cli/pkg/releasetrain/releasetrain_parsing.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/cli/pkg/releasetrain/releasetrain.go b/cli/pkg/releasetrain/releasetrain.go index 11a163e2c..d56ddd20f 100644 --- a/cli/pkg/releasetrain/releasetrain.go +++ b/cli/pkg/releasetrain/releasetrain.go @@ -36,6 +36,7 @@ type ReleaseTrainParameters struct { TargetEnvironment string Team *string CiLink *string + UseEnvGroupTarget bool UseDexAuthentication bool } @@ -60,6 +61,9 @@ func createHttpRequest(url string, authParams kutil.AuthenticationParameters, pa if parameters.UseDexAuthentication { prefix = "api/environments" + if parameters.UseEnvGroupTarget { + prefix = "api/environment-groups" + } } path := fmt.Sprintf("%s/%s/releasetrain", prefix, parameters.TargetEnvironment) diff --git a/cli/pkg/releasetrain/releasetrain_parsing.go b/cli/pkg/releasetrain/releasetrain_parsing.go index 1965b9344..78132612a 100644 --- a/cli/pkg/releasetrain/releasetrain_parsing.go +++ b/cli/pkg/releasetrain/releasetrain_parsing.go @@ -29,6 +29,7 @@ type ReleaseTrainCommandLineArguments struct { targetEnvironment cli_utils.RepeatedString team cli_utils.RepeatedString ciLink cli_utils.RepeatedString + useEnvGroupTarget bool useDexAuthentication bool } @@ -62,6 +63,7 @@ func readArgs(args []string) (*ReleaseTrainCommandLineArguments, error) { fs.Var(&cmdArgs.team, "team", "the target team. Only specified teams services will be taken into account when conducting the release train") fs.BoolVar(&cmdArgs.useDexAuthentication, "use_dex_auth", false, "if set to true, the /api/* endpoint will be used. Dex must be enabled on the server side and a dex token must be provided, otherwise the request will be denied") fs.Var(&cmdArgs.ciLink, "ci_link", "the link to the CI run that created this release train") + fs.BoolVar(&cmdArgs.useEnvGroupTarget, "use_env_group_target", false, "if set to true, sets target type to environment-group") if err := fs.Parse(args); err != nil { return nil, fmt.Errorf("error while parsing command line arguments, error: %w", err) @@ -88,6 +90,7 @@ func convertToParams(cmdArgs ReleaseTrainCommandLineArguments) (*ReleaseTrainPar CiLink: nil, TargetEnvironment: cmdArgs.targetEnvironment.Values[0], UseDexAuthentication: cmdArgs.useDexAuthentication, + UseEnvGroupTarget: cmdArgs.useEnvGroupTarget, } if len(cmdArgs.team.Values) == 1 {