Skip to content

Commit 7561b3a

Browse files
committed
Fix problems with env valueFrom for DC hooks
* Avoid adding an `undefined` element to value from array depending on the order that config maps and secrets load * Fix typo passing config maps to edit-lifecycle hooks * Show valueFrom values for hooks when viewing the deployment config Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1509842 Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1509819
1 parent bb79695 commit 7561b3a

File tree

6 files changed

+91
-31
lines changed

6 files changed

+91
-31
lines changed

app/scripts/controllers/edit/deploymentConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ angular.module('openshiftConsole')
165165
DataService.list("secrets", context, null, { errorNotification: false }).then(function(secretData) {
166166
secretDataOrdered = orderByDisplayName(secretData.by("metadata.name"));
167167
$scope.availableSecrets = secretDataOrdered;
168-
$scope.valueFromObjects = secretDataOrdered.concat(configMapDataOrdered);
168+
$scope.valueFromObjects = configMapDataOrdered.concat(secretDataOrdered);
169169
var secretsByType = SecretsService.groupSecretsByType(secretData);
170170
var secretNamesByType =_.mapValues(secretsByType, function(secretData) {return _.map(secretData, 'metadata.name');});
171171
// Add empty option to the image/source secrets

app/scripts/directives/lifecycleHook.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ angular.module("openshiftConsole")
123123

124124
$scope.valueFromObjects = [];
125125
$scope.$watchGroup(['availableSecrets', 'availableConfigMaps'], function() {
126-
$scope.valueFromObjects = ($scope.availableSecrets || []).concat($scope.availableConfigMaps);
126+
var configMaps = $scope.availableConfigMaps || [];
127+
var secrets = $scope.availableSecrets || [];
128+
$scope.valueFromObjects = configMaps.concat(secrets);
127129
});
128130

129131
$scope.$watch("istagHook.tagObject.tag", function() {

app/views/directives/lifecycle-hook.html

+32-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,37 @@ <h5 class="container-name">Container {{strategyParams[type].execNewPod.container
3333
<dt ng-if-start="strategyParams[type].execNewPod.env">Environment Variables:</dt>
3434
<dd ng-if-end>
3535
<div ng-repeat="env in strategyParams[type].execNewPod.env">
36-
<div class="truncate" ng-attr-title="{{env.value}}">{{env.name}}={{env.value}}</div>
36+
<div ng-if="env.valueFrom.configMapKeyRef || env.valueFrom.secretKeyRef">
37+
{{env.name}} set to key
38+
<span ng-if="env.valueFrom.configMapKeyRef">
39+
{{env.valueFrom.configMapKeyRef.key}} in config map
40+
<span
41+
ng-if="!('configmaps' | canI : 'get')">
42+
{{env.valueFrom.configMapKeyRef.name}}
43+
</span>
44+
<a
45+
ng-if="'configmaps' | canI : 'get'"
46+
ng-href="{{env.valueFrom.configMapKeyRef.name | navigateResourceURL : 'ConfigMap' : deploymentConfig.metadata.namespace}}">
47+
{{env.valueFrom.configMapKeyRef.name}}
48+
</a>
49+
</span>
50+
<span ng-if="env.valueFrom.secretKeyRef">
51+
{{env.valueFrom.secretKeyRef.key}} in secret
52+
<span
53+
ng-if="!('secrets' | canI : 'get')">
54+
{{env.valueFrom.secretKeyRef.name}}
55+
</span>
56+
<a
57+
ng-if="'secrets' | canI : 'get'"
58+
ng-href="{{env.valueFrom.secretKeyRef.name | navigateResourceURL : 'Secret' : deploymentConfig.metadata.namespace}}">
59+
{{env.valueFrom.secretKeyRef.name}}
60+
</a>
61+
<a ng-href="{{volume.secret.secretName | navigateResourceURL : 'Secret' : namespace}}">{{volume.secret.secretName}}</a>
62+
</span>
63+
</div>
64+
<div ng-if="!env.valueFrom" class="truncate" ng-attr-title="{{env.value}}">
65+
{{env.name}}={{env.value}}
66+
</div>
3767
</div>
3868
</dd>
3969
<dt ng-if-start="strategyParams[type].execNewPod.volumes">Volumes:</dt>
@@ -53,4 +83,4 @@ <h5 class="container-name">Container {{tagImage.containerName}}</h5>
5383
</dl>
5484
</div>
5585
</div>
56-
</dl>
86+
</dl>

app/views/edit/deployment-config.html

+24-21
Original file line numberDiff line numberDiff line change
@@ -229,37 +229,40 @@ <h3>Deployment Strategy</h3>
229229
<div class="lifecycle-hook" id="pre-lifecycle-hook">
230230

231231
<h3>Pre Lifecycle Hook</h3>
232-
<edit-lifecycle-hook model='strategyData[strategyParamsPropertyName].pre'
233-
type='pre'
234-
available-volumes='volumeNames'
235-
available-containers='containerNames'
236-
available-secrets='availableSecrets'
237-
available-configmaps='availableConfigMaps'
238-
namespace="projectName">
232+
<edit-lifecycle-hook
233+
model="strategyData[strategyParamsPropertyName].pre"
234+
type="pre"
235+
available-volumes="volumeNames"
236+
available-containers="containerNames"
237+
available-secrets="availableSecrets"
238+
available-config-maps="availableConfigMaps"
239+
namespace="projectName">
239240
</edit-lifecycle-hook>
240241
</div>
241242

242243
<div ng-if="strategyData.type !== 'Rolling'" class="lifecycle-hook" id="mid-lifecycle-hook" >
243244
<h3>Mid Lifecycle Hook</h3>
244-
<edit-lifecycle-hook model='strategyData[strategyParamsPropertyName].mid'
245-
type='mid'
246-
available-volumes='volumeNames'
247-
available-containers='containerNames'
248-
available-secrets='availableSecrets'
249-
available-configmaps='availableConfigMaps'
250-
namespace="projectName">
245+
<edit-lifecycle-hook
246+
model="strategyData[strategyParamsPropertyName].mid"
247+
type="mid"
248+
available-volumes="volumeNames"
249+
available-containers="containerNames"
250+
available-secrets="availableSecrets"
251+
available-config-maps="availableConfigMaps"
252+
namespace="projectName">
251253
</edit-lifecycle-hook>
252254
</div>
253255

254256
<div class="lifecycle-hook" id="post-lifecycle-hook" >
255257
<h3>Post Lifecycle Hook</h3>
256-
<edit-lifecycle-hook model='strategyData[strategyParamsPropertyName].post'
257-
type='post'
258-
available-volumes='volumeNames'
259-
available-containers='containerNames'
260-
available-secrets='availableSecrets'
261-
available-configmaps='availableConfigMaps'
262-
namespace="projectName">
258+
<edit-lifecycle-hook
259+
model="strategyData[strategyParamsPropertyName].post"
260+
type="post"
261+
available-volumes="volumeNames"
262+
available-containers="containerNames"
263+
available-secrets="availableSecrets"
264+
available-config-maps="availableConfigMaps"
265+
namespace="projectName">
263266
</edit-lifecycle-hook>
264267
</div>
265268
</div>

dist/scripts/scripts.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7395,7 +7395,7 @@ b = g(t.by("metadata.name")), e.availableConfigMaps = b, e.valueFromObjects = b.
73957395
}), c.list("secrets", r, null, {
73967396
errorNotification: !1
73977397
}).then(function(t) {
7398-
C = g(t.by("metadata.name")), e.availableSecrets = C, e.valueFromObjects = C.concat(b);
7398+
C = g(t.by("metadata.name")), e.availableSecrets = C, e.valueFromObjects = b.concat(C);
73997399
var n = p.groupSecretsByType(t), a = _.mapValues(n, function(e) {
74007400
return _.map(e, "metadata.name");
74017401
});
@@ -11040,7 +11040,8 @@ e.removedHookParams = e.hookParams, delete e.hookParams, e.editForm.$setDirty();
1104011040
e.$watchGroup([ "hookParams", "action.type" ], function() {
1104111041
e.hookParams && ("execNewPod" === e.action.type ? (e.hookParams.tagImages && (e.removedHookParams.tagImages = e.hookParams.tagImages, delete e.hookParams.tagImages), r()) : "tagImages" === e.action.type && (e.hookParams.execNewPod && (e.removedHookParams.execNewPod = e.hookParams.execNewPod, delete e.hookParams.execNewPod), r()));
1104211042
}), e.valueFromObjects = [], e.$watchGroup([ "availableSecrets", "availableConfigMaps" ], function() {
11043-
e.valueFromObjects = (e.availableSecrets || []).concat(e.availableConfigMaps);
11043+
var t = e.availableConfigMaps || [], n = e.availableSecrets || [];
11044+
e.valueFromObjects = t.concat(n);
1104411045
}), e.$watch("istagHook.tagObject.tag", function() {
1104511046
_.has(e.istagHook, [ "tagObject", "tag" ]) && (_.set(e.hookParams, "tagImages[0].to.kind", "ImageStreamTag"), _.set(e.hookParams, "tagImages[0].to.namespace", e.istagHook.namespace), _.set(e.hookParams, "tagImages[0].to.name", e.istagHook.imageStream + ":" + e.istagHook.tagObject.tag));
1104611047
});

dist/scripts/templates.js

+28-4
Original file line numberDiff line numberDiff line change
@@ -7622,7 +7622,31 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
76227622
"<dt ng-if-start=\"strategyParams[type].execNewPod.env\">Environment Variables:</dt>\n" +
76237623
"<dd ng-if-end>\n" +
76247624
"<div ng-repeat=\"env in strategyParams[type].execNewPod.env\">\n" +
7625-
"<div class=\"truncate\" ng-attr-title=\"{{env.value}}\">{{env.name}}={{env.value}}</div>\n" +
7625+
"<div ng-if=\"env.valueFrom.configMapKeyRef || env.valueFrom.secretKeyRef\">\n" +
7626+
"{{env.name}} set to key\n" +
7627+
"<span ng-if=\"env.valueFrom.configMapKeyRef\">\n" +
7628+
"{{env.valueFrom.configMapKeyRef.key}} in config map\n" +
7629+
"<span ng-if=\"!('configmaps' | canI : 'get')\">\n" +
7630+
"{{env.valueFrom.configMapKeyRef.name}}\n" +
7631+
"</span>\n" +
7632+
"<a ng-if=\"'configmaps' | canI : 'get'\" ng-href=\"{{env.valueFrom.configMapKeyRef.name | navigateResourceURL : 'ConfigMap' : deploymentConfig.metadata.namespace}}\">\n" +
7633+
"{{env.valueFrom.configMapKeyRef.name}}\n" +
7634+
"</a>\n" +
7635+
"</span>\n" +
7636+
"<span ng-if=\"env.valueFrom.secretKeyRef\">\n" +
7637+
"{{env.valueFrom.secretKeyRef.key}} in secret\n" +
7638+
"<span ng-if=\"!('secrets' | canI : 'get')\">\n" +
7639+
"{{env.valueFrom.secretKeyRef.name}}\n" +
7640+
"</span>\n" +
7641+
"<a ng-if=\"'secrets' | canI : 'get'\" ng-href=\"{{env.valueFrom.secretKeyRef.name | navigateResourceURL : 'Secret' : deploymentConfig.metadata.namespace}}\">\n" +
7642+
"{{env.valueFrom.secretKeyRef.name}}\n" +
7643+
"</a>\n" +
7644+
"<a ng-href=\"{{volume.secret.secretName | navigateResourceURL : 'Secret' : namespace}}\">{{volume.secret.secretName}}</a>\n" +
7645+
"</span>\n" +
7646+
"</div>\n" +
7647+
"<div ng-if=\"!env.valueFrom\" class=\"truncate\" ng-attr-title=\"{{env.value}}\">\n" +
7648+
"{{env.name}}={{env.value}}\n" +
7649+
"</div>\n" +
76267650
"</div>\n" +
76277651
"</dd>\n" +
76287652
"<dt ng-if-start=\"strategyParams[type].execNewPod.volumes\">Volumes:</dt>\n" +
@@ -10127,17 +10151,17 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
1012710151
"<div class=\"lifecycle-hooks\">\n" +
1012810152
"<div class=\"lifecycle-hook\" id=\"pre-lifecycle-hook\">\n" +
1012910153
"<h3>Pre Lifecycle Hook</h3>\n" +
10130-
"<edit-lifecycle-hook model=\"strategyData[strategyParamsPropertyName].pre\" type=\"pre\" available-volumes=\"volumeNames\" available-containers=\"containerNames\" available-secrets=\"availableSecrets\" available-configmaps=\"availableConfigMaps\" namespace=\"projectName\">\n" +
10154+
"<edit-lifecycle-hook model=\"strategyData[strategyParamsPropertyName].pre\" type=\"pre\" available-volumes=\"volumeNames\" available-containers=\"containerNames\" available-secrets=\"availableSecrets\" available-config-maps=\"availableConfigMaps\" namespace=\"projectName\">\n" +
1013110155
"</edit-lifecycle-hook>\n" +
1013210156
"</div>\n" +
1013310157
"<div ng-if=\"strategyData.type !== 'Rolling'\" class=\"lifecycle-hook\" id=\"mid-lifecycle-hook\">\n" +
1013410158
"<h3>Mid Lifecycle Hook</h3>\n" +
10135-
"<edit-lifecycle-hook model=\"strategyData[strategyParamsPropertyName].mid\" type=\"mid\" available-volumes=\"volumeNames\" available-containers=\"containerNames\" available-secrets=\"availableSecrets\" available-configmaps=\"availableConfigMaps\" namespace=\"projectName\">\n" +
10159+
"<edit-lifecycle-hook model=\"strategyData[strategyParamsPropertyName].mid\" type=\"mid\" available-volumes=\"volumeNames\" available-containers=\"containerNames\" available-secrets=\"availableSecrets\" available-config-maps=\"availableConfigMaps\" namespace=\"projectName\">\n" +
1013610160
"</edit-lifecycle-hook>\n" +
1013710161
"</div>\n" +
1013810162
"<div class=\"lifecycle-hook\" id=\"post-lifecycle-hook\">\n" +
1013910163
"<h3>Post Lifecycle Hook</h3>\n" +
10140-
"<edit-lifecycle-hook model=\"strategyData[strategyParamsPropertyName].post\" type=\"post\" available-volumes=\"volumeNames\" available-containers=\"containerNames\" available-secrets=\"availableSecrets\" available-configmaps=\"availableConfigMaps\" namespace=\"projectName\">\n" +
10164+
"<edit-lifecycle-hook model=\"strategyData[strategyParamsPropertyName].post\" type=\"post\" available-volumes=\"volumeNames\" available-containers=\"containerNames\" available-secrets=\"availableSecrets\" available-config-maps=\"availableConfigMaps\" namespace=\"projectName\">\n" +
1014110165
"</edit-lifecycle-hook>\n" +
1014210166
"</div>\n" +
1014310167
"</div>\n" +

0 commit comments

Comments
 (0)