11#!/usr/bin/env variant
22# vim:set ft=yaml
3+
4+ parameters:
5+ - name: config
6+ default: .color
7+ description: "Config file that keeps track of the current color"
8+
9+ options:
10+ - name: debug
11+ default: boolean
12+ default: false
13+ description: "Enable debug mode"
14+
315tasks:
16+
417 deps:
518 description: "Install alpine dependencies"
619 script: |
7- apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse
20+ ! which apk >/dev/null || apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse
821
922 color:
1023 description: "Lookup the current color"
11-
12- parameters:
13- - name: config
14- default: ".color"
15- description: "Config file that keeps track of the current color"
16-
1724 script: |
1825 config=${CF_VOLUME_PATH:-.}/{{ get "config" }}
1926 if [ -f ${config} ]; then
2027 cat ${config}
2128 else
2229 echo "blue" | tee ${config}
2330 fi
31+
2432 blue-green:
2533 description: "Trigger a blue-green deployment"
2634
2735 parameters:
2836 - name: namespace
2937 default: "default"
3038 description: "Kubernetes namespace"
31-
32- - name: config
33- default: ".color"
34- description: "Config file that keeps track of the current color"
3539
3640 - name: color
3741 type: string
@@ -46,12 +50,15 @@ tasks:
4650 type: string
4751 default: blue
4852 description: "Flip green color to this color"
49-
50- script: |
51- config=${CF_VOLUME_PATH:-.}/{{ get "config" }}
52- cur_color={{ get "color" }}
53- new_color={{ get "color" | get }}
54- echo "Updating {{ get "namespace" }}: $cur_color => $new_color"
55- echo "$new_color" > ${config}
56- export COLOR=$new_color
57- helmfile --namespace {{ get "namespace" }} sync
53+
54+ steps:
55+ - task: deps
56+ - script: |
57+ config=${CF_VOLUME_PATH:-.}/{{ get "config" }}
58+ cur_color={{ get "color" }}
59+ new_color={{ get "color" | get }}
60+ echo "Config file is ${config}"
61+ echo "Updating {{ get "namespace" }}: $cur_color => $new_color"
62+ echo "$new_color" > ${config}
63+ export COLOR=$new_color
64+ helmfile --namespace {{ get "namespace" }} sync
0 commit comments