clarify variable references
This commit is contained in:
parent
725e715c2e
commit
a155423ba3
|
@ -6,13 +6,13 @@ import (
|
|||
"github.com/hashicorp/nomad/api"
|
||||
)
|
||||
|
||||
func normalizeJob(jw *jobConfig) {
|
||||
j := jw.Job
|
||||
func normalizeJob(jc *jobConfig) {
|
||||
j := jc.Job
|
||||
if j.Name == nil {
|
||||
j.Name = &jw.JobID
|
||||
j.Name = &jc.JobID
|
||||
}
|
||||
if j.ID == nil {
|
||||
j.ID = &jw.JobID
|
||||
j.ID = &jc.JobID
|
||||
}
|
||||
|
||||
if j.Periodic != nil && j.Periodic.Spec != nil {
|
||||
|
@ -20,11 +20,11 @@ func normalizeJob(jw *jobConfig) {
|
|||
j.Periodic.SpecType = &v
|
||||
}
|
||||
|
||||
normalizeVault(jw.Vault)
|
||||
normalizeVault(jc.Vault)
|
||||
|
||||
if len(jw.Tasks) != 0 {
|
||||
alone := make([]*api.TaskGroup, 0, len(jw.Tasks))
|
||||
for _, t := range jw.Tasks {
|
||||
if len(jc.Tasks) != 0 {
|
||||
alone := make([]*api.TaskGroup, 0, len(jc.Tasks))
|
||||
for _, t := range jc.Tasks {
|
||||
alone = append(alone, &api.TaskGroup{
|
||||
Name: &t.Name,
|
||||
Tasks: []*api.Task{t},
|
||||
|
@ -47,7 +47,7 @@ func normalizeJob(jw *jobConfig) {
|
|||
normalizeVault(t.Vault)
|
||||
|
||||
if t.Vault == nil {
|
||||
t.Vault = jw.Vault
|
||||
t.Vault = jc.Vault
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,19 +69,19 @@ func (c *jobConfig) decodeBody(body hcl.Body) hcl.Diagnostics {
|
|||
// decodeInputVariables looks in the found blocks for 'variables' and
|
||||
// 'variable' blocks. It should be called firsthand so that other blocks can
|
||||
// use the variables.
|
||||
func (j *jobConfig) decodeInputVariables(content *hcl.BodyContent) hcl.Diagnostics {
|
||||
func (c *jobConfig) decodeInputVariables(content *hcl.BodyContent) hcl.Diagnostics {
|
||||
var diags hcl.Diagnostics
|
||||
|
||||
for _, block := range content.Blocks {
|
||||
switch block.Type {
|
||||
case variableLabel:
|
||||
moreDiags := j.InputVariables.decodeVariableBlock(block, nil)
|
||||
moreDiags := c.InputVariables.decodeVariableBlock(block, nil)
|
||||
diags = append(diags, moreDiags...)
|
||||
case variablesLabel:
|
||||
attrs, moreDiags := block.Body.JustAttributes()
|
||||
diags = append(diags, moreDiags...)
|
||||
for key, attr := range attrs {
|
||||
moreDiags = j.InputVariables.decodeVariable(key, attr, nil)
|
||||
moreDiags = c.InputVariables.decodeVariable(key, attr, nil)
|
||||
diags = append(diags, moreDiags...)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue