mirror of
https://github.com/outbackdingo/debos.git
synced 2026-01-28 02:18:45 +00:00
Add some yaml anchors in the templating test to ensure those are correctly handled. This is in preperation for switching the yaml package. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
57 lines
1.8 KiB
YAML
57 lines
1.8 KiB
YAML
# expected to be run with -t escaped:\$bad\'ge\$rs or similar to verify passing
|
|
# variables onwards
|
|
{{ $escaped := or .escaped "$mu'room$" }}
|
|
architecture: amd64
|
|
|
|
# Test YAML anchors - define reusable command settings
|
|
.common-run-settings: &common-run-settings
|
|
chroot: false
|
|
|
|
actions:
|
|
- action: run
|
|
description: test escaping in command
|
|
<<: *common-run-settings
|
|
command: echo {{ escape $escaped }} > test.a
|
|
- action: run
|
|
description: escaping via heredoc
|
|
<<: *common-run-settings
|
|
command: |-
|
|
cat << 'EOF' > test.b
|
|
{{ $escaped }}
|
|
EOF
|
|
- action: run
|
|
description: validate escaping
|
|
<<: *common-run-settings
|
|
command: diff -u test.a test.b
|
|
- action: run
|
|
description: sector custom function
|
|
<<: *common-run-settings
|
|
command: test "8s" = {{ sector 8 }}
|
|
- action: run
|
|
description: sprig string functions
|
|
<<: *common-run-settings
|
|
command: test "HELLOHELLO" = {{ "hello" | upper | repeat 2 }}
|
|
- action: run
|
|
description: sprig integer math functions
|
|
<<: *common-run-settings
|
|
command: test 42 -eq {{ mul 4 10 | add 2 }}
|
|
- action: run
|
|
description: sprig conversion function
|
|
<<: *common-run-settings
|
|
command: test 42 -eq {{ 0x2a | int }}
|
|
|
|
# expected.uuid5 contains value generated with $namespace and $text1
|
|
{{ $namespace := or .namespace "6c9d1418-8fa9-11ee-b4ca-325096b39f47" }}
|
|
{{ $text1 := or .text1 "ver1.0" }}
|
|
{{ $text2 := or .text2 "ver2.0" }}
|
|
{{ $expected := or .expected "3deb2a0e-692c-5a37-93c0-1123948bf5ae" }}
|
|
|
|
- action: run
|
|
description: test uuid5 generate same value when input is same
|
|
<<: *common-run-settings
|
|
command: test {{ uuid5 $namespace $text1 }} = {{ $expected }}
|
|
- action: run
|
|
description: test uuid5 generate different value when input is different
|
|
<<: *common-run-settings
|
|
command: test {{ uuid5 $namespace $text2 }} != {{ $expected }}
|