Skip to content

Commit f3fcba9

Browse files
author
OpenShift Bot
authoredSep 13, 2017
Merge pull request #2058 from jeff-phillips-18/containers
Merged by openshift-bot
2 parents b947915 + 8a4bef2 commit f3fcba9

File tree

7 files changed

+76
-15
lines changed

7 files changed

+76
-15
lines changed
 

Diff for: ‎app/scripts/directives/addSecretToApplication.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,18 @@
9393
});
9494
};
9595

96+
var isContainerSelected = function(container) {
97+
return ctrl.attachAllContainers || ctrl.attachContainers[container.name];
98+
};
99+
96100
ctrl.$postLink = function() {
97101
$scope.$watch(function() {
98102
return ctrl.application;
99103
}, function() {
100104
// Look at the existing mount paths so that we can warn if the new value is not unique.
101105
var podTemplate = _.get(ctrl.application, 'spec.template');
102106
ctrl.existingMountPaths = StorageService.getMountPaths(podTemplate);
107+
ctrl.attachAllContainers = true;
103108
});
104109
};
105110

@@ -119,8 +124,10 @@
119124

120125
// For each container, add the new volume mount.
121126
_.each(podTemplate.spec.containers, function(container) {
122-
container.envFrom = container.envFrom || [];
123-
container.envFrom.push(newEnvFrom);
127+
if (isContainerSelected(container)) {
128+
container.envFrom = container.envFrom || [];
129+
container.envFrom.push(newEnvFrom);
130+
}
124131
});
125132
} else {
126133
var generateName = $filter('generateName');
@@ -133,8 +140,10 @@
133140

134141
// For each selected container, add the new volume mount.
135142
_.each(podTemplate.spec.containers, function(container) {
136-
container.volumeMounts = container.volumeMounts || [];
137-
container.volumeMounts.push(newVolumeMount);
143+
if (isContainerSelected(container)) {
144+
container.volumeMounts = container.volumeMounts || [];
145+
container.volumeMounts.push(newVolumeMount);
146+
}
138147
});
139148

140149
var newVolume = {

Diff for: ‎app/styles/_secrets.less

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
max-width: 600px;
44
}
55

6+
.container-options {
7+
margin-left: 20px;
8+
.select-container {
9+
max-height: 200px;
10+
overflow-y: auto;
11+
.checkbox:first-of-type {
12+
margin-top: 0;
13+
}
14+
}
15+
}
16+
617
.dialog-title {
718
border-bottom: 1px solid @color-pf-black-300;
819

Diff for: ‎app/views/directives/add-secret-to-application.html

+17
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,23 @@ <h3>Add to Application</h3>
7070
</div>
7171
</div>
7272
</div>
73+
<legend ng-if-start="ctrl.application.spec.template.spec.containers.length > 1">Containers:</legend>
74+
<div ng-if-end class="form-group container-options">
75+
<div ng-if="ctrl.attachAllContainers">
76+
The secret will be added to all containers. You can
77+
<a href="" ng-click="ctrl.attachAllContainers = false">select specific containers</a>
78+
instead.
79+
</div>
80+
<div ng-if="!ctrl.attachAllContainers" class="form-group">
81+
<label class="sr-only required">Containers</label>
82+
<select-containers
83+
ng-model="ctrl.attachContainers"
84+
pod-template="ctrl.application.spec.template"
85+
ng-required="true"
86+
help-text="Add the secret to the selected containers.">
87+
</select-containers>
88+
</div>
89+
</div>
7390
<div class="button-group pull-right">
7491
<button
7592
class="btn btn-default"

Diff for: ‎app/views/directives/select-containers.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<ng-form name="forms.containerSelect">
2-
<div class="checkbox" ng-repeat="container in template.spec.containers">
3-
<label class="truncate">
4-
<input
2+
<div class="select-container">
3+
<div class="checkbox" ng-repeat="container in template.spec.containers">
4+
<label class="truncate">
5+
<input
56
type="checkbox"
67
ng-model="containers[container.name]"
78
ng-required="required && !containerSelected">
8-
<b>{{container.name}}</b>
9+
<b>{{container.name}}</b>
910
<span class="hidden-xs">
1011
from image
1112
<i ng-attr-title="{{container.image}}">{{container.image}}</i>
1213
</span>
13-
</label>
14+
</label>
15+
</div>
1416
</div>
1517
<div ng-if="helpText" class="help-block">
1618
{{helpText}}

Diff for: ‎dist/scripts/scripts.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -10639,12 +10639,16 @@ var e = new RegExp("^[A-Za-z_]{1}[A-Za-z0-9_]*$");
1063910639
m.hasInvalidEnvVars = _.some(m.secret.data, function(t, n) {
1064010640
return !e.test(n);
1064110641
});
10642-
}, m.$postLink = function() {
10642+
};
10643+
var g = function(e) {
10644+
return m.attachAllContainers || m.attachContainers[e.name];
10645+
};
10646+
m.$postLink = function() {
1064310647
t.$watch(function() {
1064410648
return m.application;
1064510649
}, function() {
1064610650
var e = _.get(m.application, "spec.template");
10647-
m.existingMountPaths = i.getMountPaths(e);
10651+
m.existingMountPaths = i.getMountPaths(e), m.attachAllContainers = !0;
1064810652
});
1064910653
}, m.addToApplication = function() {
1065010654
var t = angular.copy(m.application), i = _.get(t, "spec.template");
@@ -10655,7 +10659,7 @@ name: m.secret.metadata.name
1065510659
}
1065610660
};
1065710661
_.each(i.spec.containers, function(e) {
10658-
e.envFrom = e.envFrom || [], e.envFrom.push(s);
10662+
g(e) && (e.envFrom = e.envFrom || [], e.envFrom.push(s));
1065910663
});
1066010664
} else {
1066110665
var c = e("generateName")(m.secret.metadata.name + "-"), l = {
@@ -10664,7 +10668,7 @@ mountPath: m.mountVolume,
1066410668
readOnly: !0
1066510669
};
1066610670
_.each(i.spec.containers, function(e) {
10667-
e.volumeMounts = e.volumeMounts || [], e.volumeMounts.push(l);
10671+
g(e) && (e.volumeMounts = e.volumeMounts || [], e.volumeMounts.push(l));
1066810672
});
1066910673
var u = {
1067010674
name: c,
@@ -10674,10 +10678,10 @@ secretName: m.secret.metadata.name
1067410678
};
1067510679
i.spec.volumes = i.spec.volumes || [], i.spec.volumes.push(u);
1067610680
}
10677-
var d = e("humanizeKind"), p = d(m.secret.kind), f = d(t.kind), g = {
10681+
var d = e("humanizeKind"), p = d(m.secret.kind), f = d(t.kind), h = {
1067810682
namespace: m.project.metadata.name
1067910683
};
10680-
a.update(n.kindToResource(t.kind), t.metadata.name, t, g).then(function() {
10684+
a.update(n.kindToResource(t.kind), t.metadata.name, t, h).then(function() {
1068110685
o.addNotification({
1068210686
type: "success",
1068310687
message: "Successfully added " + p + " " + m.secret.metadata.name + " to " + f + " " + t.metadata.name + ".",

Diff for: ‎dist/scripts/templates.js

+15
Original file line numberDiff line numberDiff line change
@@ -5610,6 +5610,19 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
56105610
"</div>\n" +
56115611
"</div>\n" +
56125612
"</div>\n" +
5613+
"<legend ng-if-start=\"ctrl.application.spec.template.spec.containers.length > 1\">Containers:</legend>\n" +
5614+
"<div ng-if-end class=\"form-group container-options\">\n" +
5615+
"<div ng-if=\"ctrl.attachAllContainers\">\n" +
5616+
"The secret will be added to all containers. You can\n" +
5617+
"<a href=\"\" ng-click=\"ctrl.attachAllContainers = false\">select specific containers</a>\n" +
5618+
"instead.\n" +
5619+
"</div>\n" +
5620+
"<div ng-if=\"!ctrl.attachAllContainers\" class=\"form-group\">\n" +
5621+
"<label class=\"sr-only required\">Containers</label>\n" +
5622+
"<select-containers ng-model=\"ctrl.attachContainers\" pod-template=\"ctrl.application.spec.template\" ng-required=\"true\" help-text=\"Add the secret to the selected containers.\">\n" +
5623+
"</select-containers>\n" +
5624+
"</div>\n" +
5625+
"</div>\n" +
56135626
"<div class=\"button-group pull-right\">\n" +
56145627
"<button class=\"btn btn-default\" ng-class=\"{'dialog-btn': isDialog}\" ng-click=\"ctrl.onCancel()\">\n" +
56155628
"Cancel\n" +
@@ -8811,6 +8824,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
88118824

88128825
$templateCache.put('views/directives/select-containers.html',
88138826
"<ng-form name=\"forms.containerSelect\">\n" +
8827+
"<div class=\"select-container\">\n" +
88148828
"<div class=\"checkbox\" ng-repeat=\"container in template.spec.containers\">\n" +
88158829
"<label class=\"truncate\">\n" +
88168830
"<input type=\"checkbox\" ng-model=\"containers[container.name]\" ng-required=\"required && !containerSelected\">\n" +
@@ -8821,6 +8835,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
88218835
"</span>\n" +
88228836
"</label>\n" +
88238837
"</div>\n" +
8838+
"</div>\n" +
88248839
"<div ng-if=\"helpText\" class=\"help-block\">\n" +
88258840
"{{helpText}}\n" +
88268841
"</div>\n" +

Diff for: ‎dist/styles/main.css

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.