Merge "feat(pipeline): enables images value override"
This commit is contained in:
commit
f0be23a0f8
@ -54,13 +54,18 @@ data:
|
||||
},
|
||||
"namespace": "development-pipeline",
|
||||
"release_name": "mongodb-bitnami",
|
||||
"images": {
|
||||
"applications": {
|
||||
"mongodb-sharded": {
|
||||
"tag": "1.0",
|
||||
"name": "mongodb",
|
||||
"repo": "mongodb"
|
||||
"sources": {
|
||||
"image_map": {
|
||||
"tag": ["releases", "image", "tag"],
|
||||
"tmp_name": ["releases", "image", "repository"],
|
||||
"tmp_repo": ["releases", "image", "registry"]
|
||||
}
|
||||
},
|
||||
"releases": {
|
||||
"image": {
|
||||
"registry": "docker.io",
|
||||
"repository": "bitnami/mongodb-sharded",
|
||||
"tag": "4.4.3-debian-10-r44"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -78,6 +83,14 @@ data:
|
||||
},
|
||||
"namespace": "development-pipeline",
|
||||
"release_name": "mongodb",
|
||||
"sources": {
|
||||
"image_map": {
|
||||
"tag": ["releases", "images", "applications", "mongodb", "tag"],
|
||||
"tmp_name": ["releases", "images", "applications", "mongodb", "name"],
|
||||
"tmp_repo": ["releases", "images", "applications", "mongodb", "repo"]
|
||||
}
|
||||
},
|
||||
"releases": {
|
||||
"images": {
|
||||
"applications": {
|
||||
"mongodb": {
|
||||
@ -88,6 +101,7 @@ data:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
default.json: |
|
||||
{
|
||||
|
@ -23,13 +23,22 @@ spec:
|
||||
script: |
|
||||
#!/bin/sh
|
||||
update-ca-certificates
|
||||
ansible-playbook -vvv {{ $.Values.tasks.functional.functionalPlaybook }} -i hosts -e '{"stage":"deploy"}' -e @"$(workspaces.development_pipeline_data.path)/default.json" -e @"$(workspaces.development_pipeline_data.path)/cluster.json" -e 'loop_source="$(workspaces.development_pipeline_data.path)/chart.json"'
|
||||
ansible-playbook -vvv {{ $.Values.tasks.functional.functionalPlaybook }} -i hosts \
|
||||
-e '{"stage":"deploy"}' \
|
||||
-e @"$(workspaces.development_pipeline_data.path)/default.json" \
|
||||
-e @"$(workspaces.development_pipeline_data.path)/cluster.json" \
|
||||
-e 'loop_source="$(workspaces.development_pipeline_data.path)/chart.json"' \
|
||||
-e 'datapath="$(workspaces.development_pipeline_data.path)"'
|
||||
|
||||
- name: run-helm-tests
|
||||
image: {{ $.Values.tasks.functional.functionalTestImage }}
|
||||
script: |
|
||||
#!/bin/sh
|
||||
ansible-playbook -vvv {{ $.Values.tasks.functional.functionalPlaybook }} -i hosts -e '{"stage":"test"}' -e @"$(workspaces.development_pipeline_data.path)/default.json" -e @"$(workspaces.development_pipeline_data.path)/cluster.json" -e 'loop_source="$(workspaces.development_pipeline_data.path)/chart.json"'
|
||||
ansible-playbook -vvv {{ $.Values.tasks.functional.functionalPlaybook }} -i hosts \
|
||||
-e '{"stage":"test"}' \
|
||||
-e @"$(workspaces.development_pipeline_data.path)/default.json" \
|
||||
-e @"$(workspaces.development_pipeline_data.path)/cluster.json" \
|
||||
-e 'loop_source="$(workspaces.development_pipeline_data.path)/chart.json"'
|
||||
volumes:
|
||||
- name: helm-publish-creds
|
||||
secret:
|
||||
|
@ -21,6 +21,7 @@ RUN apt-get update ;\
|
||||
ca-certificates \
|
||||
gnupg-agent \
|
||||
software-properties-common \
|
||||
moreutils \
|
||||
gettext-base ;\
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - ;\
|
||||
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" ;\
|
||||
|
@ -6,9 +6,36 @@
|
||||
when: ("{{ stage }}" == "deploy")
|
||||
block:
|
||||
#Deploy CNF
|
||||
|
||||
- name: Deploy charts
|
||||
shell: helm upgrade --install --kubeconfig="{{ cluster_kubeconfig_path }}/kubeconfig" "{{ chart.release_name }}" "{{ chart.project }}-staging/{{ chart.chart_name }}" --version="{{ chart.version }}" --namespace="{{ chart.namespace }}"
|
||||
shell: |
|
||||
set -xe ;
|
||||
CHARTNAME={{ chart.chart_name }} ;
|
||||
REPO={{ docker_registry }} ;
|
||||
NAME={{ chart.project }}-staging/{{ chart.chart_name }} ;
|
||||
|
||||
jq -c --arg c $CHARTNAME --arg v $REPO 'map(if .repo == $c then .["tmp_repo"] = $v else . end)' {{ datapath }}/image.json | sponge {{ datapath }}/image.json ;
|
||||
jq -c --arg c $CHARTNAME --arg v $NAME 'map(if .repo == $c then .["tmp_name"] = $v else . end)' {{ datapath }}/image.json | sponge {{ datapath }}/image.json ;
|
||||
|
||||
M=$(jq -c --arg c $CHARTNAME 'map(select(.chart_name == $c)) | first | .sources.image_map' {{ datapath }}/chart.json) ;
|
||||
if [ "$M" != "null" ] && [ -n "$M" ] ; then \
|
||||
echo $M | jq -r 'keys[]' | while IFS= read -r k; do \
|
||||
v=$(echo $M | jq -c --arg k $k '.[$k]') ;\
|
||||
filter=".$k" ;\
|
||||
value=$(jq -c --arg c $CHARTNAME 'map(select(.image_name == $c)) | first' {{ datapath}}/image.json | jq -r $filter) ;\
|
||||
jq -r --arg c $CHARTNAME --argjson k $v --arg v $value 'map(if .chart_name == $c then getpath($k) = $v else . end)' {{ datapath }}/chart.json | sponge {{ datapath }}/chart.json ;\
|
||||
done ; \
|
||||
fi ;
|
||||
jq -c --arg c $CHARTNAME 'map(select(.chart_name == $c)) | first | .releases' \
|
||||
{{ datapath }}/chart.json > {{ datapath }}/{{ chart.chart_name }}-overrides.json ;
|
||||
cat {{ datapath }}/{{ chart.chart_name }}-overrides.json ;
|
||||
helm upgrade --install \
|
||||
--kubeconfig="{{ cluster_kubeconfig_path }}/kubeconfig" \
|
||||
"{{ chart.release_name }}" "{{ chart.project }}-staging/{{ chart.chart_name }}" \
|
||||
--version="{{ chart.version }}" \
|
||||
--values="{{ datapath }}/{{ chart.chart_name }}-overrides.json" \
|
||||
--namespace="{{ chart.namespace }}"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
loop: "{{ charts }}"
|
||||
loop_control:
|
||||
loop_var: "chart"
|
||||
|
Loading…
Reference in New Issue
Block a user