1+ # Licensed to the Apache Software Foundation (ASF) under one
2+ # or more contributor license agreements. See the NOTICE file
3+ # distributed with this work for additional information
4+ # regarding copyright ownership. The ASF licenses this file
5+ # to you under the Apache License, Version 2.0 (the
6+ # "License"); you may not use this file except in compliance
7+ # with the License. You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing,
12+ # software distributed under the License is distributed on an
13+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+ # KIND, either express or implied. See the License for the
15+ # specific language governing permissions and limitations
16+ # under the License.
17+ #
18+
19+ version : ' 3'
20+
21+ tasks :
22+
23+ send :
24+ desc : Send the build to the server
25+ vars :
26+ AUTH :
27+ sh : cat ~/.wskprops | grep "AUTH" | cut -d'=' -f2 | xargs -I {}
28+ cmds :
29+ - if test -z "{{.SOURCE}}"; then echo "SOURCE IS NOT SET" && exit 1; fi
30+ - if test -z "{{.TARGET}}"; then echo "TARGET IS NOT SET" && exit 1; fi
31+ - if test -z "{{.KIND}}"; then echo "KIND IS NOT SET" && exit 1; fi
32+ - |
33+ echo '{"source": "{{.SOURCE}}", "target": "{{.TARGET}}", "kind": "{{.KIND}}", "file": "{{.REQUIREMENTS}}" }' | http POST $ADMIN_API_URL/system/build Content-Type:application/json Authorization:"{{.AUTH}}"
34+ - sleep 5
35+ - task : logs
36+ deps :
37+ - cleanjobs
38+ # - updatetoml
39+ silent : true
40+
41+ logs :
42+ desc : Show logs of the last build job
43+ cmds :
44+ - kubectl -n nuvolaris logs $(kubectl get jobs.batch -o name | grep "build-") -c buildkit --follow
45+ silent : false
46+
47+ cleanjobs :
48+ desc : Clean up old jobs
49+ cmds :
50+ - for I in $(kubectl get jobs -n nuvolaris | grep build | awk '{ print $1 }' | tr "\n" " "); do kubectl delete job $I; done
51+ - for I in $(kubectl get cm -n nuvolaris | grep "cm-" | awk '{ print $1 }' | tr "\n" " "); do kubectl delete cm $I; done
52+ silent : true
53+
54+ updatetoml :
55+ desc : Update the buildkitd.toml file config map
56+ cmds :
57+ - |
58+ if test $(kubectl -n nuvolaris get cm -o name | grep nuvolaris-buildkitd-conf | wc -l) -gt 0;
59+ then kubectl -n nuvolaris delete configmap nuvolaris-buildkitd-conf
60+ fi
61+ - kubectl -n nuvolaris create configmap nuvolaris-buildkitd-conf --from-file=deploy/buildkit/buildkitd.toml
62+ silent : true
63+
64+ list-catalogs :
65+ desc : List catalogs in the registry
66+ cmds :
67+ - http -a $REGISTRY_USER:$REGISTRY_PASS GET "${REGISTRY_HOST}/v2/_catalog"
68+ silent : false
69+
70+ list-images :
71+ desc : List images in a specific catalog
72+ vars :
73+ CATALOG : ' {{.CATALOG}}'
74+ cmds :
75+ - if test -z "{{.CATALOG}}"; then echo "CATALOG IS NOT SET" && exit 1; fi
76+ - http -a $REGISTRY_USER:$REGISTRY_PASS GET "${REGISTRY_HOST}/v2/{{.CATALOG}}/tags/list"
77+ silent : false
78+
79+ get-image :
80+ desc : Get an image from the registry
81+ vars :
82+ IMAGE : ' {{.IMAGE}}'
83+ IMAGE_NAME :
84+ sh : echo '{{.IMAGE}}' | cut -d':' -f1
85+ HASH :
86+ sh : echo '{{.IMAGE}}' | cut -d':' -f2
87+ cmds :
88+ - echo "Getting image {{.IMAGE_NAME}} with hash {{.HASH}}"
89+ - http -a $REGISTRY_USER:$REGISTRY_PASS GET "${REGISTRY_HOST}/v2/{{.IMAGE_NAME}}/manifests/{{.HASH}}"
90+ silent : false
91+
92+ delete-image :
93+ desc : Delete an image from the registry
94+ vars :
95+ IMAGE : ' {{.IMAGE}}'
96+ IMAGE_NAME :
97+ sh : echo '{{.IMAGE}}' | cut -d':' -f1
98+ HASH :
99+ sh : echo '{{.IMAGE}}' | cut -d':' -f2
100+ MANIFEST_DIGEST :
101+ sh : http --headers -a $REGISTRY_USER:$REGISTRY_PASS GET "${REGISTRY_HOST}/v2/{{.IMAGE_NAME}}/manifests/{{.HASH}}" | grep -i 'Docker-Content-Digest:' | awk '{print $2}' | tr -d '\r'
102+ cmds :
103+ - echo 'Deleting image {{.IMAGE}}'
104+ - echo "Deleting manifest {{.MANIFEST_DIGEST}} for image {{.IMAGE_NAME}}"
105+ - http -a $REGISTRY_USER:$REGISTRY_PASS DELETE "${REGISTRY_HOST}/v2/{{.IMAGE_NAME}}/manifests/{{.MANIFEST_DIGEST}}"
106+ silent : false
0 commit comments