Browse code

deploy: stop defaulting to ImageStreamTag unconditionally

Michail Kargakis authored on 2016/07/20 22:04:03
Showing 3 changed files
... ...
@@ -100,8 +100,9 @@ func SetDefaults_RollingDeploymentStrategyParams(obj *RollingDeploymentStrategyP
100 100
 func SetDefaults_DeploymentConfig(obj *DeploymentConfig) {
101 101
 	for _, t := range obj.Spec.Triggers {
102 102
 		if t.ImageChangeParams != nil {
103
-			// Default unconditionally for transforming old data.
104
-			t.ImageChangeParams.From.Kind = "ImageStreamTag"
103
+			if len(t.ImageChangeParams.From.Kind) == 0 {
104
+				t.ImageChangeParams.From.Kind = "ImageStreamTag"
105
+			}
105 106
 			if len(t.ImageChangeParams.From.Namespace) == 0 {
106 107
 				t.ImageChangeParams.From.Namespace = obj.Namespace
107 108
 			}
... ...
@@ -93,6 +93,8 @@ os::cmd::expect_success_and_text "oc get dc --show-labels" "app=dockerbuild,temp
93 93
 os::cmd::expect_success_and_text "oc get dc frontend --show-labels" "app=dockerbuild,template=application-template-dockerbuild"
94 94
 os::cmd::expect_success_and_not_text "oc get dc" "app=dockerbuild,template=application-template-dockerbuild"
95 95
 os::cmd::expect_success_and_not_text "oc get dc frontend" "app=dockerbuild,template=application-template-dockerbuild"
96
+os::cmd::expect_success "oc process -f test/testdata/old-template.json | oc create -f -"
97
+os::cmd::expect_success_and_text "oc get dc/eap-app -o yaml" ":latest"
96 98
 echo "get: ok"
97 99
 os::test::junit::declare_suite_end
98 100
 
99 101
new file mode 100644
... ...
@@ -0,0 +1,340 @@
0
+{
1
+    "kind": "Template",
2
+    "apiVersion": "v1",
3
+    "metadata": {
4
+        "annotations": {
5
+            "iconClass": "icon-jboss",
6
+            "description": "Application template for EAP 6 applications built using S2I.",
7
+            "tags": "eap,javaee,java,jboss,xpaas",
8
+            "version": "1.3.2"
9
+        },
10
+        "name": "eap64-basic-s2i"
11
+    },
12
+    "labels": {
13
+        "template": "eap64-basic-s2i",
14
+        "xpaas": "1.3.2"
15
+    },
16
+    "parameters": [
17
+        {
18
+            "description": "The name for the application.",
19
+            "name": "APPLICATION_NAME",
20
+            "value": "eap-app",
21
+            "required": true
22
+        },
23
+        {
24
+            "description": "Custom hostname for http service route.  Leave blank for default hostname, e.g.: <application-name>-<project>.<default-domain-suffix>",
25
+            "name": "HOSTNAME_HTTP",
26
+            "value": "",
27
+            "required": false
28
+        },
29
+        {
30
+            "description": "Git source URI for application",
31
+            "name": "SOURCE_REPOSITORY_URL",
32
+            "value": "https://github.com/jboss-developer/jboss-eap-quickstarts",
33
+            "required": true
34
+        },
35
+        {
36
+            "description": "Git branch/tag reference",
37
+            "name": "SOURCE_REPOSITORY_REF",
38
+            "value": "6.4.x",
39
+            "required": false
40
+        },
41
+        {
42
+            "description": "Path within Git project to build; empty for root project directory.",
43
+            "name": "CONTEXT_DIR",
44
+            "value": "kitchensink",
45
+            "required": false
46
+        },
47
+        {
48
+            "description": "Queue names",
49
+            "name": "HORNETQ_QUEUES",
50
+            "value": "",
51
+            "required": false
52
+        },
53
+        {
54
+            "description": "Topic names",
55
+            "name": "HORNETQ_TOPICS",
56
+            "value": "",
57
+            "required": false
58
+        },
59
+        {
60
+            "description": "HornetQ cluster admin password",
61
+            "name": "HORNETQ_CLUSTER_PASSWORD",
62
+            "from": "[a-zA-Z0-9]{8}",
63
+            "generate": "expression",
64
+            "required": true
65
+        },
66
+        {
67
+            "description": "GitHub trigger secret",
68
+            "name": "GITHUB_WEBHOOK_SECRET",
69
+            "from": "[a-zA-Z0-9]{8}",
70
+            "generate": "expression",
71
+            "required": true
72
+        },
73
+        {
74
+            "description": "Generic build trigger secret",
75
+            "name": "GENERIC_WEBHOOK_SECRET",
76
+            "from": "[a-zA-Z0-9]{8}",
77
+            "generate": "expression",
78
+            "required": true
79
+        },
80
+        {
81
+            "description": "Namespace in which the ImageStreams for Red Hat Middleware images are installed. These ImageStreams are normally installed in the openshift namespace. You should only need to modify this if you've installed the ImageStreams in a different namespace/project.",
82
+            "name": "IMAGE_STREAM_NAMESPACE",
83
+            "value": "openshift",
84
+            "required": true
85
+        },
86
+        {
87
+            "description": "JGroups cluster password",
88
+            "name": "JGROUPS_CLUSTER_PASSWORD",
89
+            "from": "[a-zA-Z0-9]{8}",
90
+            "generate": "expression",
91
+            "required": true
92
+        },
93
+        {
94
+            "description": "Controls whether exploded deployment content should be automatically deployed",
95
+            "name": "AUTO_DEPLOY_EXPLODED",
96
+            "value": "false",
97
+            "required": false
98
+        }
99
+    ],
100
+    "objects": [
101
+        {
102
+            "kind": "Service",
103
+            "apiVersion": "v1",
104
+            "spec": {
105
+                "ports": [
106
+                    {
107
+                        "port": 8080,
108
+                        "targetPort": 8080
109
+                    }
110
+                ],
111
+                "selector": {
112
+                    "deploymentConfig": "${APPLICATION_NAME}"
113
+                }
114
+            },
115
+            "metadata": {
116
+                "name": "${APPLICATION_NAME}",
117
+                "labels": {
118
+                    "application": "${APPLICATION_NAME}"
119
+                },
120
+                "annotations": {
121
+                    "description": "The web server's http port."
122
+                }
123
+            }
124
+        },
125
+        {
126
+            "kind": "Route",
127
+            "apiVersion": "v1",
128
+            "id": "${APPLICATION_NAME}-http",
129
+            "metadata": {
130
+                "name": "${APPLICATION_NAME}",
131
+                "labels": {
132
+                    "application": "${APPLICATION_NAME}"
133
+                },
134
+                "annotations": {
135
+                    "description": "Route for application's http service."
136
+                }
137
+            },
138
+            "spec": {
139
+                "host": "${HOSTNAME_HTTP}",
140
+                "to": {
141
+                    "name": "${APPLICATION_NAME}"
142
+                }
143
+            }
144
+        },
145
+        {
146
+            "kind": "ImageStream",
147
+            "apiVersion": "v1",
148
+            "metadata": {
149
+                "name": "${APPLICATION_NAME}",
150
+                "labels": {
151
+                    "application": "${APPLICATION_NAME}"
152
+                }
153
+            }
154
+        },
155
+        {
156
+            "kind": "BuildConfig",
157
+            "apiVersion": "v1",
158
+            "metadata": {
159
+                "name": "${APPLICATION_NAME}",
160
+                "labels": {
161
+                    "application": "${APPLICATION_NAME}"
162
+                }
163
+            },
164
+            "spec": {
165
+                "source": {
166
+                    "type": "Git",
167
+                    "git": {
168
+                        "uri": "${SOURCE_REPOSITORY_URL}",
169
+                        "ref": "${SOURCE_REPOSITORY_REF}"
170
+                    },
171
+                    "contextDir": "${CONTEXT_DIR}"
172
+                },
173
+                "strategy": {
174
+                    "type": "Source",
175
+                    "sourceStrategy": {
176
+                        "forcePull": true,
177
+                        "from": {
178
+                            "kind": "ImageStreamTag",
179
+                            "namespace": "${IMAGE_STREAM_NAMESPACE}",
180
+                            "name": "jboss-eap64-openshift:1.4"
181
+                        }
182
+                    }
183
+                },
184
+                "output": {
185
+                    "to": {
186
+                        "kind": "ImageStreamTag",
187
+                        "name": "${APPLICATION_NAME}:latest"
188
+                    }
189
+                },
190
+                "triggers": [
191
+                    {
192
+                        "type": "GitHub",
193
+                        "github": {
194
+                            "secret": "${GITHUB_WEBHOOK_SECRET}"
195
+                        }
196
+                    },
197
+                    {
198
+                        "type": "Generic",
199
+                        "generic": {
200
+                            "secret": "${GENERIC_WEBHOOK_SECRET}"
201
+                        }
202
+                    },
203
+                    {
204
+                        "type": "ImageChange",
205
+                        "imageChange": {}
206
+                    },
207
+                    {
208
+                        "type": "ConfigChange"
209
+                    }
210
+                ]
211
+            }
212
+        },
213
+        {
214
+            "kind": "DeploymentConfig",
215
+            "apiVersion": "v1",
216
+            "metadata": {
217
+                "name": "${APPLICATION_NAME}",
218
+                "labels": {
219
+                    "application": "${APPLICATION_NAME}"
220
+                }
221
+            },
222
+            "spec": {
223
+                "strategy": {
224
+                    "type": "Recreate"
225
+                },
226
+                "triggers": [
227
+                    {
228
+                        "type": "ImageChange",
229
+                        "imageChangeParams": {
230
+                            "automatic": true,
231
+                            "containerNames": [
232
+                                "${APPLICATION_NAME}"
233
+                            ],
234
+                            "from": {
235
+                                "kind": "ImageStream",
236
+                                "name": "${APPLICATION_NAME}"
237
+                            }
238
+                        }
239
+                    },
240
+                    {
241
+                        "type": "ConfigChange"
242
+                    }
243
+                ],
244
+                "replicas": 1,
245
+                "selector": {
246
+                    "deploymentConfig": "${APPLICATION_NAME}"
247
+                },
248
+                "template": {
249
+                    "metadata": {
250
+                        "name": "${APPLICATION_NAME}",
251
+                        "labels": {
252
+                            "deploymentConfig": "${APPLICATION_NAME}",
253
+                            "application": "${APPLICATION_NAME}"
254
+                        }
255
+                    },
256
+                    "spec": {
257
+                        "terminationGracePeriodSeconds": 60,
258
+                        "containers": [
259
+                            {
260
+                                "name": "${APPLICATION_NAME}",
261
+                                "image": "${APPLICATION_NAME}",
262
+                                "imagePullPolicy": "Always",
263
+                                "livenessProbe": {
264
+                                    "exec": {
265
+                                        "command": [
266
+                                            "/bin/bash",
267
+                                            "-c",
268
+                                            "/opt/eap/bin/livenessProbe.sh"
269
+                                        ]
270
+                                    }
271
+                                },
272
+                                "readinessProbe": {
273
+                                    "exec": {
274
+                                        "command": [
275
+                                            "/bin/bash",
276
+                                            "-c",
277
+                                            "/opt/eap/bin/readinessProbe.sh"
278
+                                        ]
279
+                                    }
280
+                                },
281
+                                "ports": [
282
+                                    {
283
+                                        "name": "jolokia",
284
+                                        "containerPort": 8778,
285
+                                        "protocol": "TCP"
286
+                                    },
287
+                                    {
288
+                                        "name": "http",
289
+                                        "containerPort": 8080,
290
+                                        "protocol": "TCP"
291
+                                    },
292
+                                    {
293
+                                        "name": "ping",
294
+                                        "containerPort": 8888,
295
+                                        "protocol": "TCP"
296
+                                    }
297
+                                ],
298
+                                "env": [
299
+                                    {
300
+                                        "name": "OPENSHIFT_KUBE_PING_LABELS",
301
+                                        "value": "application=${APPLICATION_NAME}"
302
+                                    },
303
+                                    {
304
+                                        "name": "OPENSHIFT_KUBE_PING_NAMESPACE",
305
+                                        "valueFrom": {
306
+                                            "fieldRef": {
307
+                                                "fieldPath": "metadata.namespace"
308
+                                            }
309
+                                        }
310
+                                    },
311
+                                    {
312
+                                        "name": "HORNETQ_CLUSTER_PASSWORD",
313
+                                        "value": "${HORNETQ_CLUSTER_PASSWORD}"
314
+                                    },
315
+                                    {
316
+                                        "name": "HORNETQ_QUEUES",
317
+                                        "value": "${HORNETQ_QUEUES}"
318
+                                    },
319
+                                    {
320
+                                        "name": "HORNETQ_TOPICS",
321
+                                        "value": "${HORNETQ_TOPICS}"
322
+                                    },
323
+                                    {
324
+                                        "name": "JGROUPS_CLUSTER_PASSWORD",
325
+                                        "value": "${JGROUPS_CLUSTER_PASSWORD}"
326
+                                    },
327
+                                    {
328
+                                        "name": "AUTO_DEPLOY_EXPLODED",
329
+                                        "value": "${AUTO_DEPLOY_EXPLODED}"
330
+                                    }
331
+                                ]
332
+                            }
333
+                        ]
334
+                    }
335
+                }
336
+            }
337
+        }
338
+    ]
339
+}