blob: d033eda6634d26fe59734ff36290d96c22b405da (
plain)
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
91
92
93
94
95
96
97
|
#jinja2: trim_blocks: "true", lstrip_blocks: "false"
---
{% set app = app | default('{}') %}
{% set have_triggers = 0 %}
apiVersion: v1
kind: Template
metadata:
name: {{ appname | default(kaas_project) }}-builders
annotations:
descriptions: {{ kaas_project_config.description | default(appname | default(kaas_project) ~ " auto-generated image-builder template") }}
{% set applabels = ( app.labels | default({}) | combine( { 'app': appname }) ) if appname is defined else (app.labels | default({})) %}
{% if applabels | length > 0 %}
labels: {{ applabels | to_json }}
{% endif %}
objects:
{% for name, builder in builders.iteritems() %}
{% set isname = builder.name | default(name) | regex_replace('_','-') %}
{% set istag = builder.version | default("latest") %}
{% set type = builder.type | default("Docker") %}
{% set src_type = builder.src_type | default("git") %}
{% set image_type = builder.image_type | default("ImageStreamTag") %}
- kind: ImageStream
apiVersion: v1
metadata:
name: {{ isname }}
- kind: "BuildConfig"
apiVersion: v1
metadata:
name: {{ isname }}
spec:
successfulBuildsHistoryLimit: "{{ kaas_pod_history_limit }}"
failedBuildsHistoryLimit: "{{ kaas_pod_history_limit }}"
triggers:
- type: "ConfigChange"
source:
type: {{ src_type }}
{{ src_type }}:
uri: "{{ builder.src }}"
{% if builder.src_path is defined %}
contextDir: "{{ builder.src_path }}"
{% endif %}
strategy:
{% if type == 'Docker' %}
type: {{ type }}
{{ type | lower }}Strategy:
dockerfilePath: "{{ builder.dockerfile | default('Dockerfile') }}"
{% if builder.args is defined %}
buildArgs:
{% for arg_name, arg_val in builder.args.iteritems() %}
- name: "{{ arg_name }}"
value: "{{ arg_val }}"
{% endfor %}
{% endif %}
{% else %}
type: {{ type }}
{{ type | lower }}Strategy:
{% if builder.image is defined %}
from:
kind: {{ image_type }}
name: "{{ builder.image }}"
{% if image_type == 'ImageStreamTag' %}
namespace: "{{ builder.image_namespace | default('openshift') }}"
{% endif %}
{% endif %}
{% endif %}
{% if builder.env is defined %}
env: {{ builder.env | to_json }}
{% endif %}
output:
to:
kind: "ImageStreamTag"
name: "{{ isname }}:{{ istag }}"
imageLabels:
- name: "vendor"
value: "{{ builder.vendor | default(ands_info.vendor) }}"
- name: "author"
value: "{{ builder.author | default(ands_info.admin) }}"
- name: "authoritative-source-url"
value: "{{ builder.url | default(ands_info.git_url) }}"
triggers:
- type: ConfigChange
- type: ImageChange
{% if builder.trigger is defined %}
{% set have_triggers = 1 %}
{% set trigger_type = "Generic" if 'github.com' in builder.src else "Generic" %}
- type: {{ trigger_type }}
{{ trigger_type | lower }}:
secret: ${TRIGGER_SECRET}
{% endif %}
{% endfor %}
parameters:
{% if have_triggers %}
- description: Trigger secret
from: '[a-zA-Z0-9]{8}'
generate: expression
name: TRIGGER_SECRET
{% endif %}
|