Skip to content

Commit 37956e6

Browse files
chore: add concurrency option to cli
1 parent d63d483 commit 37956e6

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

cmd/ctrlc/root/api/upsert/policy/policy.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func NewUpsertPolicyCmd() *cobra.Command {
2020
var environmentTargetSelector string
2121
var resourceTargetSelector string
2222
var deploymentVersionSelector string
23+
var concurrency int
2324

2425
cmd := &cobra.Command{
2526
Use: "policy [flags]",
@@ -98,6 +99,12 @@ func NewUpsertPolicyCmd() *cobra.Command {
9899
}
99100
}
100101

102+
var parsedConcurrency *api.PolicyConcurrency
103+
if concurrency != 0 {
104+
floatConcurrency := api.PolicyConcurrency(concurrency)
105+
parsedConcurrency = &floatConcurrency
106+
}
107+
101108
// Create policy request
102109
body := api.UpsertPolicyJSONRequestBody{
103110
Name: name,
@@ -113,6 +120,7 @@ func NewUpsertPolicyCmd() *cobra.Command {
113120
},
114121
},
115122
DeploymentVersionSelector: parsedDeploymentVersionSelector,
123+
Concurrency: parsedConcurrency,
116124
}
117125

118126
resp, err := client.UpsertPolicy(cmd.Context(), body)
@@ -132,7 +140,7 @@ func NewUpsertPolicyCmd() *cobra.Command {
132140
cmd.Flags().StringVar(&deploymentTargetSelector, "deployment-selector", "", "JSON string for deployment target selector")
133141
cmd.Flags().StringVar(&environmentTargetSelector, "environment-selector", "", "JSON string for environment target selector")
134142
cmd.Flags().StringVar(&resourceTargetSelector, "resource-selector", "", "JSON string for resource target selector")
135-
143+
cmd.Flags().IntVarP(&concurrency, "concurrency", "c", 0, "Concurrency of the policy")
136144
cmd.Flags().StringVar(&deploymentVersionSelector, "version-selector", "", "JSON string for version selector")
137145

138146
// Mark required flags

cmd/ctrlc/root/apply/policy.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ func createPolicyRequestBody(policy Policy) api.UpsertPolicyJSONRequestBody {
113113
}
114114
}
115115

116+
var concurrency *api.PolicyConcurrency
117+
if policy.Concurrency != nil {
118+
floatConcurrency := api.PolicyConcurrency(*policy.Concurrency)
119+
concurrency = &floatConcurrency
120+
}
121+
116122
return api.UpsertPolicyJSONRequestBody{
117123
Name: policy.Name,
118124
Description: policy.Description,
@@ -125,6 +131,7 @@ func createPolicyRequestBody(policy Policy) api.UpsertPolicyJSONRequestBody {
125131
VersionAnyApprovals: versionAnyApprovals,
126132
VersionUserApprovals: &versionUserApprovals,
127133
VersionRoleApprovals: &versionRoleApprovals,
134+
Concurrency: concurrency,
128135
}
129136
}
130137

cmd/ctrlc/root/apply/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ type Policy struct {
122122
VersionAnyApprovals *VersionAnyApproval `yaml:"versionAnyApprovals,omitempty"`
123123
VersionUserApprovals []VersionUserApproval `yaml:"versionUserApprovals,omitempty"`
124124
VersionRoleApprovals []VersionRoleApproval `yaml:"versionRoleApprovals,omitempty"`
125+
Concurrency *int `yaml:"concurrency,omitempty"`
125126
}
126127

127128
type PolicyTarget struct {

internal/api/client.gen.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)