-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add PreserveCounts
to Job.Register
#8168
Changes from all commits
57d685c
8590ae3
65bdd84
92fb931
4a6ec2c
0284698
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,7 +162,11 @@ func (c *JobInspectCommand) Run(args []string) int { | |
} | ||
|
||
// Print the contents of the job | ||
req := api.RegisterJobRequest{Job: job} | ||
req := struct { | ||
Job *api.Job | ||
}{ | ||
Job: job, | ||
} | ||
Comment on lines
+165
to
+169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need a class for deserializing a |
||
f, err := DataFormat("json", "") | ||
if err != nil { | ||
c.Ui.Error(fmt.Sprintf("Error getting formatter: %s", err)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,9 @@ Run Options: | |
-policy-override | ||
Sets the flag to force override any soft mandatory Sentinel policies. | ||
|
||
-preserve-counts | ||
If set, the existing task group counts will be preserved when updating a job. | ||
|
||
-consul-token | ||
If set, the passed Consul token is stored in the job before sending to the | ||
Nomad servers. This allows passing the Consul token without storing it in | ||
|
@@ -118,6 +121,7 @@ func (c *JobRunCommand) AutocompleteFlags() complete.Flags { | |
"-vault-token": complete.PredictAnything, | ||
"-output": complete.PredictNothing, | ||
"-policy-override": complete.PredictNothing, | ||
"-preserve-counts": complete.PredictNothing, | ||
}) | ||
} | ||
|
||
|
@@ -128,7 +132,7 @@ func (c *JobRunCommand) AutocompleteArgs() complete.Predictor { | |
func (c *JobRunCommand) Name() string { return "job run" } | ||
|
||
func (c *JobRunCommand) Run(args []string) int { | ||
var detach, verbose, output, override bool | ||
var detach, verbose, output, override, preserveCounts bool | ||
var checkIndexStr, consulToken, vaultToken string | ||
|
||
flags := c.Meta.FlagSet(c.Name(), FlagSetClient) | ||
|
@@ -137,6 +141,7 @@ func (c *JobRunCommand) Run(args []string) int { | |
flags.BoolVar(&verbose, "verbose", false, "") | ||
flags.BoolVar(&output, "output", false, "") | ||
flags.BoolVar(&override, "policy-override", false, "") | ||
flags.BoolVar(&preserveCounts, "preserve-counts", false, "") | ||
flags.StringVar(&checkIndexStr, "check-index", "", "") | ||
flags.StringVar(&consulToken, "consul-token", "", "") | ||
flags.StringVar(&vaultToken, "vault-token", "", "") | ||
|
@@ -208,7 +213,11 @@ func (c *JobRunCommand) Run(args []string) int { | |
} | ||
|
||
if output { | ||
req := api.RegisterJobRequest{Job: job} | ||
req := struct { | ||
Job *api.Job | ||
}{ | ||
Job: job, | ||
} | ||
Comment on lines
+216
to
+220
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need a class for deserializing a |
||
buf, err := json.MarshalIndent(req, "", " ") | ||
if err != nil { | ||
c.Ui.Error(fmt.Sprintf("Error converting job: %s", err)) | ||
|
@@ -232,9 +241,8 @@ func (c *JobRunCommand) Run(args []string) int { | |
opts.EnforceIndex = true | ||
opts.ModifyIndex = checkIndex | ||
} | ||
if override { | ||
opts.PolicyOverride = true | ||
} | ||
opts.PolicyOverride = override | ||
opts.PreserveCounts = preserveCounts | ||
|
||
// Submit the job | ||
resp, _, err := client.Jobs().RegisterOpts(job, opts, nil) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JobRegisterRequest
hasWriteRequest
, but we don't use it. Otherwise, has the same shape asRegisterJobRequest