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}}" }' | \
34+ curl -X POST $ADMIN_API_URL/api/v1/build -H "Content-Type: application/json" -H "Authorization: {{.AUTH}}" -d @-
35+ - sleep 5
36+ - task : logs
37+ deps :
38+ - cleanjobs
39+ # - updatetoml
40+ silent : true
41+
42+ logs :
43+ desc : Show logs of the last build job
44+ cmds :
45+ - kubectl -n nuvolaris logs $(kubectl get jobs.batch -o name | grep "build-") -c buildkit --follow
46+ silent : false
47+
48+ cleanjobs :
49+ desc : Clean up old jobs
50+ cmds :
51+ - for I in $(kubectl get jobs -n nuvolaris | grep build | awk '{ print $1 }' | tr "\n" " "); do kubectl delete job $I; done
52+ - for I in $(kubectl get cm -n nuvolaris | grep "cm-" | awk '{ print $1 }' | tr "\n" " "); do kubectl delete cm $I; done
53+ silent : true
54+
55+ updatetoml :
56+ desc : Update the buildkitd.toml file config map
57+ cmds :
58+ - |
59+ if test $(kubectl -n nuvolaris get cm -o name | grep nuvolaris-buildkitd-conf | wc -l) -gt 0;
60+ then kubectl -n nuvolaris delete configmap nuvolaris-buildkitd-conf
61+ fi
62+ - kubectl -n nuvolaris create configmap nuvolaris-buildkitd-conf --from-file=deploy/buildkit/buildkitd.toml
63+ silent : true
64+
65+ list-catalogs :
66+ desc : List catalogs in the registry
67+ cmds :
68+ - curl -u $REGISTRY_USER:$REGISTRY_PASS $REGISTRY_HOST/v2/_catalog
69+ silent : false
70+
71+ list-images :
72+ desc : List images in a specific catalog
73+ vars :
74+ CATALOG : ' {{.CATALOG}}'
75+ cmds :
76+ - if test -z "{{.CATALOG}}"; then echo "CATALOG IS NOT SET" && exit 1; fi
77+ - curl -u $REGISTRY_USER:$REGISTRY_PASS $REGISTRY_HOST/v2/{{.CATALOG}}/tags/list
78+ silent : false
79+
80+ get-image :
81+ desc : Get an image from the registry
82+ vars :
83+ IMAGE : ' {{.IMAGE}}'
84+ IMAGE_NAME :
85+ sh : echo '{{.IMAGE}}' | cut -d':' -f1
86+ HASH :
87+ sh : echo '{{.IMAGE}}' | cut -d':' -f2
88+ cmds :
89+ - echo "Getting image {{.IMAGE_NAME}} with hash {{.HASH}}"
90+ - curl -u $REGISTRY_USER:$REGISTRY_PASS $REGISTRY_HOST/v2/{{.IMAGE_NAME}}/manifests/{{.HASH}}
91+ silent : false
92+
93+ delete-image :
94+ desc : Delete an image from the registry
95+ vars :
96+ IMAGE : ' {{.IMAGE}}'
97+ IMAGE_NAME :
98+ sh : echo '{{.IMAGE}}' | cut -d':' -f1
99+ HASH :
100+ sh : echo '{{.IMAGE}}' | cut -d':' -f2
101+ MANIFEST_DIGEST :
102+ sh : curl --silent -u $REGISTRY_USER:$REGISTRY_PASS $REGISTRY_HOST/v2/{{.IMAGE_NAME}}/manifests/{{.HASH}} | grep -i 'Docker-Content-Digest:' | awk '{print $2}' | tr -d '\r'
103+ cmds :
104+ - echo 'Deleting image {{.IMAGE}}'
105+ - echo "Deleting manifest {{.MANIFEST_DIGEST}} for image {{.IMAGE_NAME}}"
106+ - curl -u $REGISTRY_USER:$REGISTRY_PASS -X DELETE $REGISTRY_HOST/v2/{{.IMAGE_NAME}}/manifests/{{.MANIFEST_DIGEST}}
107+ silent : false
0 commit comments