-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implicit run args from globa parameters and options
Formely when you call an another job with `run "JOB" { args }`, you had to explicitly set args even for global parameters/options that the JOB requires. This fixes that. See examples/globals to see how it works.
- Loading branch information
Showing
12 changed files
with
597 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
parameter "global_param" { | ||
type = string | ||
default = "A" | ||
} | ||
|
||
option "global_opt" { | ||
type = string | ||
default = "B" | ||
} | ||
|
||
job "example" { | ||
parameter "local_param" { | ||
type = string | ||
default = "C" | ||
} | ||
|
||
option "local_opt" { | ||
type = string | ||
default = "D" | ||
} | ||
|
||
step "call sub" { | ||
run "sub" { | ||
param1 = "E" | ||
} | ||
} | ||
|
||
step "call echo" { | ||
run "echo" { | ||
text = <<EOS | ||
example:global_param=${param.global_param} | ||
example:global_opt=${opt.global_opt} | ||
example:local_param=${param.local_param} | ||
example:local_opt=${opt.local_opt} | ||
EOS | ||
} | ||
} | ||
} | ||
|
||
job "sub" { | ||
parameter "param1" { | ||
type = string | ||
} | ||
|
||
run { | ||
job = "echo" | ||
with = { | ||
text = <<EOS | ||
sub:global_param=${param.global_param} | ||
sub:global_opt=${opt.global_opt} | ||
sub:param1=${param.param1} | ||
EOS | ||
} | ||
} | ||
} | ||
|
||
job "echo" { | ||
option "text" { | ||
type = string | ||
} | ||
|
||
exec { | ||
command = "bash" | ||
args = [ | ||
"-c", <<EOS | ||
cat <<EOF | ||
${opt.text} | ||
EOF | ||
EOS | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
test "example" { | ||
case "ok" { | ||
out = <<EOS | ||
sub:global_param=A | ||
sub:global_opt=B | ||
sub:param1=E | ||
|
||
example:global_param=A | ||
example:global_opt=B | ||
example:local_param=C | ||
example:local_opt=D | ||
EOS | ||
exitstatus = 0 | ||
} | ||
|
||
run "example" { | ||
} | ||
|
||
assert "out" { | ||
condition = run.res.stdout == case.out | ||
} | ||
|
||
assert "exitstatus" { | ||
condition = run.res.exitstatus == case.exitstatus | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.