Skip to content

Commit

Permalink
fix(cli): option to run release trains on environment groups when dex…
Browse files Browse the repository at this point in the history
… is enabled (#2059)

Ref: SRX-880CZF
  • Loading branch information
AminSlk authored Oct 23, 2024
1 parent c17dc8f commit 41b04df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/pkg/releasetrain/releasetrain.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type ReleaseTrainParameters struct {
TargetEnvironment string
Team *string
CiLink *string
UseEnvGroupTarget bool
UseDexAuthentication bool
}

Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions cli/pkg/releasetrain/releasetrain_parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type ReleaseTrainCommandLineArguments struct {
targetEnvironment cli_utils.RepeatedString
team cli_utils.RepeatedString
ciLink cli_utils.RepeatedString
useEnvGroupTarget bool
useDexAuthentication bool
}

Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit 41b04df

Please sign in to comment.