-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from wild-devops/develop
Adjust template concept to initial state
- Loading branch information
Showing
28 changed files
with
339 additions
and
194 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
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,87 @@ | ||
## `templates:` **element** | ||
Contains definitions of `step:` elements structure for reusing and syntax shortenings in the whole `pwshake.yaml` config. | ||
|
||
This tells to **PWSHAKE** engine how to substitute any structured `yaml` input in step definitions into an executable **Powershell** command. | ||
|
||
* ## `templates:` example | ||
``` | ||
PS>cat python.yaml | ||
templates: | ||
python: | ||
file: | ||
inline: | ||
powershell: | | ||
if ($step.python) { | ||
"python $($step.python)" | Cmd-Shell | ||
} elseif ($step.file) { | ||
"python $($step.file)" | Cmd-Shell | ||
} elseif ($step.inline) { | ||
python -c $step.inline | ||
} else { | ||
python --version | ||
} | ||
``` | ||
The given example can be used with regular `pwshake.yaml` config by including the template file `python.yaml` and using a new `python:` element as a regular step in tasks definition. | ||
``` | ||
PS>cat hello.py | ||
import sys | ||
print("Hello " + sys.argv[1] + "!", file=sys.stdout, flush=True) | ||
PS>cat python_pwshake.yaml | ||
includes: | ||
- python.yaml | ||
tasks: | ||
test_python_template: | ||
- python: | ||
- python: --version | ||
- python: | ||
inline: print('Hello pwshake!'); | ||
- python: | ||
file: | | ||
{{pwshake_path}}/hello.py again | ||
- python: '{{pwshake_path}}/hello.py twice' | ||
invoke_tasks: | ||
- test_python_template | ||
``` | ||
Output should look like the following: | ||
``` | ||
PS>Invoke-pwshake ./python_pwshake.yaml | ||
... | ||
Invoke task: test_python_template | ||
Execute step: step_25540982 | ||
Python 3.6.8 | ||
Execute step: step_8493528 | ||
bash: python --version | ||
Python 3.6.8 | ||
Execute step: step_46664441 | ||
Hello pwshake! | ||
Execute step: step_6213368 | ||
bash: python /workdir/examples/templates/hello.py again | ||
Hello again! | ||
Execute step: step_32712664 | ||
bash: python /workdir/examples/templates/hello.py twice | ||
Hello twice! | ||
``` | ||
* ## Implicit built-in `templates:` | ||
Some built-in `[step:]` template definitions are already included into the **PWSHAKE** module and loaded during the **PWSHAKE** engine initialization. | ||
So, they can be used in regular `pwshake.yaml` config without including either as external files or `templates:` element items. | ||
Examples: | ||
``` | ||
PS>cat some_pwshake.yaml | ||
... | ||
tasks: | ||
- cmd: | ||
- shell: | ||
- msbuild: | ||
- script: | ||
- invoke_tasks: | ||
``` | ||
All these steps above are actually substituted templates which are loaded from [this location](/pwshake/templates). | ||
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,2 @@ | ||
import sys | ||
print("Hello " + sys.argv[1] + "!", file=sys.stdout, flush=True) |
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,14 @@ | ||
templates: | ||
python: | ||
file: | ||
inline: | ||
powershell: | | ||
if ($step.python) { | ||
"python $($step.python)" | Cmd-Shell | ||
} elseif ($step.file) { | ||
"python $($step.file)" | Cmd-Shell | ||
} elseif ($step.inline) { | ||
python -c $step.inline | ||
} else { | ||
python --version | ||
} |
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,16 @@ | ||
includes: | ||
- python.yaml | ||
|
||
tasks: | ||
test_python_template: | ||
- python: | ||
- python: --version | ||
- python: | ||
inline: print('Hello pwshake!'); | ||
- python: | ||
file: | | ||
{{pwshake_path}}/hello.py again | ||
- python: '{{pwshake_path}}/hello.py twice' | ||
|
||
invoke_tasks: | ||
- test_python_template |
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.