Skip to content

Commit

Permalink
Modify go CLI to accept a concurrency flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rcrichton committed Apr 19, 2024
1 parent 987f8a9 commit 289e1cf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/src/cmd/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ func setCommonActionFlags(cmd *cobra.Command) {
flags.StringSliceVar(&state.EnvFiles, "env-file", nil, "env file")
flags.StringVar(&state.ConfigFile, "config", "", "config file (default is $WORKING_DIR/config.yaml)")
flags.StringSliceP("env-var", "e", nil, "Env var(s) to set or overwrite")
flags.StringP("concurrency", "", "", "The concurrency level to use for executing actions on packages (default 5)")
}
4 changes: 4 additions & 0 deletions cli/src/core/parse/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func GetInstantCommand(packageSpec core.PackageSpec) []string {
instantCommand = append(instantCommand, "--only")
}

if packageSpec.Concurrency != "" {
instantCommand = append(instantCommand, "--concurrency", packageSpec.Concurrency)
}

instantCommand = append(instantCommand, packageSpec.Packages...)

for _, customPackage := range packageSpec.CustomPackages {
Expand Down
5 changes: 5 additions & 0 deletions cli/src/core/parse/packageSpec.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func getPackageSpecFromParams(cmd *cobra.Command, config *core.Config) (*core.Pa
if err != nil {
return nil, errors.Wrap(err, "")
}
concurrency, err := cmd.Flags().GetString("concurrency")
if err != nil {
return nil, errors.Wrap(err, "")
}

var envVariables []string
if cmd.Flags().Changed("env-file") {
Expand All @@ -77,6 +81,7 @@ func getPackageSpecFromParams(cmd *cobra.Command, config *core.Config) (*core.Pa
IsDev: isDev,
IsOnly: isOnly,
DeployCommand: cmd.Use,
Concurrency: concurrency,
}

return &packageSpec, nil
Expand Down
1 change: 1 addition & 0 deletions cli/src/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type PackageSpec struct {
CustomPackages []CustomPackage
ImageVersion string
TargetLauncher string
Concurrency string
}

type GeneratePackageSpec struct {
Expand Down

0 comments on commit 289e1cf

Please sign in to comment.