Run and plan automatically sets the region
This commit is contained in:
parent
86e368cdb8
commit
a0557e766e
|
@ -126,6 +126,11 @@ func NewClient(config *Config) (*Client, error) {
|
|||
return client, nil
|
||||
}
|
||||
|
||||
// SetRegion sets the region to forward API requests to.
|
||||
func (c *Client) SetRegion(region string) {
|
||||
c.config.Region = region
|
||||
}
|
||||
|
||||
// request is used to help build up a request
|
||||
type request struct {
|
||||
config *Config
|
||||
|
|
|
@ -44,6 +44,9 @@ Usage: nomad plan [options] <file>
|
|||
A structured diff between the local and remote job is displayed to
|
||||
give insight into what the scheduler will attempt to do and why.
|
||||
|
||||
If the job has specified the region, the -region flag and NOMAD_REGION
|
||||
environment variable are overridden to the job's region.
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
|
@ -116,6 +119,11 @@ func (c *PlanCommand) Run(args []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
// Force the region to be that of the job.
|
||||
if r := job.Region; r != "" {
|
||||
client.SetRegion(r)
|
||||
}
|
||||
|
||||
// Submit the job
|
||||
resp, _, err := client.Jobs().Plan(apiJob, diff, nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -37,6 +37,9 @@ Usage: nomad run [options] <file>
|
|||
exit code will be 2. Any other errors, including client connection
|
||||
issues or internal errors, are indicated by exit code 1.
|
||||
|
||||
If the job has specified the region, the -region flag and NOMAD_REGION
|
||||
environment variable are overridden to the job's region.
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
|
@ -134,6 +137,11 @@ func (c *RunCommand) Run(args []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
// Force the region to be that of the job.
|
||||
if r := job.Region; r != "" {
|
||||
client.SetRegion(r)
|
||||
}
|
||||
|
||||
// Submit the job
|
||||
evalID, _, err := client.Jobs().Register(apiJob, nil)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue