Skip to content

Commit

Permalink
flag for user append agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Cerebrovinny committed Oct 24, 2024
1 parent b0b3a9c commit a98ee34
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/exec/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var (
cfg.DeployRunInitFlag,
cfg.InitRunReconfigure,
cfg.AutoGenerateBackendFileFlag,
cfg.AppendUserAgentFlag,
cfg.FromPlanFlag,
cfg.PlanFileFlag,
cfg.HelpFlag1,
Expand Down Expand Up @@ -668,6 +669,21 @@ func processArgsAndFlags(componentType string, inputArgsAndFlags []string) (sche
info.TerraformDir = terraformDirFlagParts[1]
}

if arg == cfg.AppendUserAgentFlag {
if len(inputArgsAndFlags) <= (i + 1) {
return info, fmt.Errorf("invalid flag: %s requires a value", arg)
}
info.AppendUserAgent = inputArgsAndFlags[i+1]
indexesToRemove = append(indexesToRemove, i, i+1)
} else if strings.HasPrefix(arg+"=", cfg.AppendUserAgentFlag) {
parts := strings.SplitN(arg, "=", 2)
if len(parts) != 2 {
return info, fmt.Errorf("invalid flag: %s", arg)
}
info.AppendUserAgent = parts[1]
indexesToRemove = append(indexesToRemove, i)
}

if arg == cfg.HelmfileCommandFlag {
if len(inputArgsAndFlags) <= (i + 1) {
return info, fmt.Errorf("invalid flag: %s", arg)
Expand Down
1 change: 1 addition & 0 deletions pkg/config/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (

DeployRunInitFlag = "--deploy-run-init"
AutoGenerateBackendFileFlag = "--auto-generate-backend-file"
AppendUserAgentFlag = "--append-user-agent"
InitRunReconfigure = "--init-run-reconfigure"

FromPlanFlag = "--from-plan"
Expand Down
1 change: 1 addition & 0 deletions pkg/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ type ArgsAndFlagsInfo struct {
DeployRunInit string
InitRunReconfigure string
AutoGenerateBackendFile string
AppendUserAgent string
UseTerraformPlan bool
PlanFile string
DryRun bool
Expand Down

0 comments on commit a98ee34

Please sign in to comment.