-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.yaml
90 lines (83 loc) · 2.56 KB
/
image.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Copyright 2022 VMware
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
apiVersion: carto.run/v1alpha1
kind: ClusterImageTemplate
metadata:
name: image
spec:
params:
- name: service_account
default: default
- name: cluster_builder
default: default
- name: registry
default: {}
imagePath: .status.latestImage
ytt: |
#@ load("@ytt:data", "data")
#@ def merge_labels(fixed_values):
#@ labels = {}
#@ if hasattr(data.values.workload.metadata, "labels"):
#@ labels.update(data.values.workload.metadata.labels)
#@ end
#@ labels.update(fixed_values)
#@ return labels
#@ end
#@ def param(key):
#@ if not key in data.values.params:
#@ return None
#@ end
#@ return data.values.params[key]
#@ end
#@ def image():
#@ return "/".join([
#@ data.values.params.registry.server,
#@ data.values.params.registry.repository,
#@ "-".join([
#@ data.values.workload.metadata.name,
#@ data.values.workload.metadata.namespace,
#@ ])
#@ ])
#@ end
---
apiVersion: kpack.io/v1alpha2
kind: Image
metadata:
name: #@ data.values.workload.metadata.name
labels: #@ merge_labels({ "app.kubernetes.io/component": "build" })
spec:
tag: #@ image()
serviceAccountName: #@ data.values.params.service_account
builder:
kind: ClusterBuilder
name: #@ data.values.params.cluster_builder
source:
blob:
url: #@ data.values.source.url
#@ if/end hasattr(data.values.workload.spec.source, "subPath"):
subPath: #@ data.values.workload.spec.source.subPath
build:
env:
- name: BP_OCI_SOURCE
value: #@ data.values.source.revision
#@ if/end param("live-update"):
- name: BP_LIVE_RELOAD_ENABLED
value: 'true'
#@ if hasattr(data.values.workload.spec.build, "env"):
#@ for var in data.values.workload.spec.build.env:
- name: #@ var.name
value: #@ var.value
#@ end
#@ end