Skip to content

Commit 3d8c136

Browse files
author
OpenShift Bot
authoredNov 11, 2016
Merge pull request #863 from spadgett/pod-env-config-map
Merged by openshift-bot
2 parents 44484b3 + 099a065 commit 3d8c136

File tree

6 files changed

+50
-23
lines changed

6 files changed

+50
-23
lines changed
 

Diff for: ‎app/scripts/controllers/pod.js

+13
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,24 @@ angular.module('openshiftConsole')
206206
});
207207
};
208208

209+
var altTextForValueFrom = $filter('altTextForValueFrom');
210+
var updateEnv = function() {
211+
// Copy the containers so we aren't modifying the original pod spec.
212+
var containers = angular.copy(_.get($scope, 'pod.spec.containers', []));
213+
_.each(containers, function(container) {
214+
container.env = container.env || [];
215+
_.each(container.env, altTextForValueFrom);
216+
});
217+
218+
$scope.containersEnv = containers;
219+
};
220+
209221
var podResolved = function(pod, action) {
210222
$scope.loaded = true;
211223
$scope.pod = pod;
212224
setLogVars(pod);
213225
setContainerVars();
226+
updateEnv();
214227
if (action === "DELETED") {
215228
$scope.alerts["deleted"] = {
216229
type: "warning",

Diff for: ‎app/scripts/controllers/replicaSet.js

+2
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ angular.module('openshiftConsole')
8080
$scope.logCanRun = !(_.includes(['New', 'Pending'], $filter('deploymentStatus')(replicaSet)));
8181
};
8282

83+
var altTextForValueFrom = $filter('altTextForValueFrom');
8384
var copyDeploymentAndEnsureEnv = function(replicaSet) {
8485
$scope.updatedDeployment = angular.copy(replicaSet);
8586
_.each($scope.updatedDeployment.spec.template.spec.containers, function(container) {
8687
container.env = container.env || [];
88+
_.each(container.env, altTextForValueFrom);
8789
});
8890
};
8991

Diff for: ‎app/views/browse/pod.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ <h1>
5959
</uib-tab>
6060
<uib-tab heading="Environment" active="selectedTab.environment">
6161
<uib-tab-heading>Environment</uib-tab-heading>
62-
<div ng-repeat="container in pod.spec.containers">
62+
<div ng-repeat="container in containersEnv">
6363
<h3>Container {{container.name}} Environment Variables</h3>
6464
<key-value-editor
6565
entries="container.env"

Diff for: ‎app/views/browse/replica-set.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ <h1>
5050
</uib-tab>
5151
<uib-tab heading="Environment" active="selectedTab.environment">
5252
<uib-tab-heading>Environment</uib-tab-heading>
53-
<div ng-if="deployment || (replicaSet | hasDeploymentConfig)">
53+
<!--
54+
Use the `hasDeployment` filter rather than checking for the `deployment` scope
55+
var. This prevents the editor from displaying briefly before the deployment has
56+
loaded, which adds an empty env var name/value to the array. The empty
57+
value breaks `container.env.length` check for the no env vars message.
58+
-->
59+
<div ng-if="(replicaSet | hasDeployment) || (replicaSet | hasDeploymentConfig)">
5460
<p ng-if="deployment && ({ group: 'extensions', resource: 'deployments' } | canI : 'update')">
5561
<span class="pficon pficon-info" aria-hidden="true"></span>
5662
Environment variables can be edited on the <a ng-href="{{deployment | navigateResourceURL}}?tab=environment">deployment</a>.
@@ -59,7 +65,7 @@ <h1>
5965
<span class="pficon pficon-info" aria-hidden="true"></span>
6066
Environment variables can be edited on the <a ng-href="{{replicaSet | configURLForResource}}?tab=environment">deployment configuration</a>.
6167
</p>
62-
<div ng-repeat="container in replicaSet.spec.template.spec.containers">
68+
<div ng-repeat="container in updatedDeployment.spec.template.spec.containers">
6369
<h3>Container {{container.name}} Environment Variables</h3>
6470
<key-value-editor
6571
ng-if="container.env.length"
@@ -74,7 +80,7 @@ <h3>Container {{container.name}} Environment Variables</h3>
7480
<em ng-if="!container.env.length">The container specification has no environment variables set.</em>
7581
</div>
7682
</div>
77-
<ng-form ng-show="!deployment && !(replicaSet | hasDeploymentConfig)" name="forms.envForm">
83+
<ng-form ng-if="!(replicaSet | hasDeployment) && !(replicaSet | hasDeploymentConfig)" name="forms.envForm">
7884
<div ng-repeat="container in updatedDeployment.spec.template.spec.containers">
7985
<div ng-if="resource | canI : 'update'">
8086
<key-value-editor

Diff for: ‎dist/scripts/scripts.js

+20-15
Original file line numberDiff line numberDiff line change
@@ -4004,18 +4004,23 @@ name:b.containerName
40044004
}), d = t(c);
40054005
b.containerState = d;
40064006
});
4007-
}, x = function(b, c) {
4008-
a.loaded = !0, a.pod = b, n(b), o(), "DELETED" === c && (a.alerts.deleted = {
4007+
}, x = b("altTextForValueFrom"), y = function() {
4008+
var b = angular.copy(_.get(a, "pod.spec.containers", []));
4009+
_.each(b, function(a) {
4010+
a.env = a.env || [], _.each(a.env, x);
4011+
}), a.containersEnv = b;
4012+
}, z = function(b, c) {
4013+
a.loaded = !0, a.pod = b, n(b), o(), y(), "DELETED" === c && (a.alerts.deleted = {
40094014
type:"warning",
40104015
message:"This pod has been deleted."
40114016
});
40124017
};
40134018
k.get(c.project).then(_.spread(function(d, i) {
40144019
m = i, a.project = d, a.projectContext = i, g.get("pods", c.pod, i).then(function(b) {
4015-
x(b);
4020+
z(b);
40164021
var d = {};
40174022
d[b.metadata.name] = b, a.containerTerminals = u(), v(b), h.fetchReferencedImageStreamImages(d, a.imagesByDockerReference, a.imageStreamImageRefByDockerReference, m), l.push(g.watchObject("pods", c.pod, i, function(b, c) {
4018-
x(b, c), w(a.containerTerminals), v(b);
4023+
z(b, c), w(a.containerTerminals), v(b);
40194024
}));
40204025
}, function(c) {
40214026
a.loaded = !0, a.alerts.load = {
@@ -5750,9 +5755,9 @@ a.metricsAvailable = b;
57505755
});
57515756
var u = function(c) {
57525757
a.logCanRun = !_.includes([ "New", "Pending" ], b("deploymentStatus")(c));
5753-
}, v = function(b) {
5758+
}, v = b("altTextForValueFrom"), w = function(b) {
57545759
a.updatedDeployment = angular.copy(b), _.each(a.updatedDeployment.spec.template.spec.containers, function(a) {
5755-
a.env = a.env || [];
5760+
a.env = a.env || [], _.each(a.env, v);
57565761
});
57575762
};
57585763
a.saveEnvVars = function() {
@@ -5771,17 +5776,17 @@ details:"Reason: " + b("getErrorDetails")(c)
57715776
};
57725777
});
57735778
}, a.clearEnvVarUpdates = function() {
5774-
v(a.replicaSet), a.forms.envForm.$setPristine();
5779+
w(a.replicaSet), a.forms.envForm.$setPristine();
57755780
};
5776-
var w = b("isIE")() || b("isEdge")();
5781+
var x = b("isIE")() || b("isEdge")();
57775782
i.get(c.project).then(_.spread(function(d, h) {
57785783
a.project = d, a.projectContext = h;
5779-
var i, n, x = {}, y = {}, z = function() {
5780-
if (a.hpaForRS = g.filterHPA(x, o, c.replicaSet), a.deploymentConfigName && a.isActive) {
5781-
var b = g.filterHPA(x, "DeploymentConfig", a.deploymentConfigName);
5784+
var i, n, v = {}, y = {}, z = function() {
5785+
if (a.hpaForRS = g.filterHPA(v, o, c.replicaSet), a.deploymentConfigName && a.isActive) {
5786+
var b = g.filterHPA(v, "DeploymentConfig", a.deploymentConfigName);
57825787
a.autoscalers = a.hpaForRS.concat(b);
57835788
} else if (a.deployment && a.isActive) {
5784-
var d = g.filterHPA(x, "Deployment", a.deployment.metadata.name);
5789+
var d = g.filterHPA(v, "Deployment", a.deployment.metadata.name);
57855790
a.autoscalers = a.hpaForRS.concat(d);
57865791
} else a.autoscalers = a.hpaForRS;
57875792
}, A = function() {
@@ -5877,7 +5882,7 @@ object:b
58775882
"DELETED" === c && (a.alerts.deleted = {
58785883
type:"warning",
58795884
message:"This " + r + " has been deleted."
5880-
}), a.replicaSet = b, !a.forms.envForm || a.forms.envForm.$pristine ? v(b) :a.alerts.background_update = {
5885+
}), a.replicaSet = b, !a.forms.envForm || a.forms.envForm.$pristine ? w(b) :a.alerts.background_update = {
58815886
type:"warning",
58825887
message:"This " + r + " has been updated in the background. Saving your changes may create a conflict or cause loss of data.",
58835888
links:[ {
@@ -5923,9 +5928,9 @@ a.builds = b.by("metadata.name"), m.log("builds (subscribe)", a.builds);
59235928
group:"extensions",
59245929
resource:"horizontalpodautoscalers"
59255930
}, h, function(a) {
5926-
x = a.by("metadata.name"), z(), C();
5931+
v = a.by("metadata.name"), z(), C();
59275932
}, {
5928-
poll:w,
5933+
poll:x,
59295934
pollInterval:6e4
59305935
})), f.list("limitranges", h, function(a) {
59315936
y = a.by("metadata.name"), C();

Diff for: ‎dist/scripts/templates.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
27752775
"</uib-tab>\n" +
27762776
"<uib-tab heading=\"Environment\" active=\"selectedTab.environment\">\n" +
27772777
"<uib-tab-heading>Environment</uib-tab-heading>\n" +
2778-
"<div ng-repeat=\"container in pod.spec.containers\">\n" +
2778+
"<div ng-repeat=\"container in containersEnv\">\n" +
27792779
"<h3>Container {{container.name}} Environment Variables</h3>\n" +
27802780
"<key-value-editor entries=\"container.env\" is-readonly cannot-add cannot-sort cannot-delete ng-if=\"container.env.length\"></key-value-editor>\n" +
27812781
"<em ng-if=\"!container.env.length\">The container specification has no environment variables set.</em>\n" +
@@ -2915,7 +2915,8 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
29152915
"</uib-tab>\n" +
29162916
"<uib-tab heading=\"Environment\" active=\"selectedTab.environment\">\n" +
29172917
"<uib-tab-heading>Environment</uib-tab-heading>\n" +
2918-
"<div ng-if=\"deployment || (replicaSet | hasDeploymentConfig)\">\n" +
2918+
"\n" +
2919+
"<div ng-if=\"(replicaSet | hasDeployment) || (replicaSet | hasDeploymentConfig)\">\n" +
29192920
"<p ng-if=\"deployment && ({ group: 'extensions', resource: 'deployments' } | canI : 'update')\">\n" +
29202921
"<span class=\"pficon pficon-info\" aria-hidden=\"true\"></span>\n" +
29212922
"Environment variables can be edited on the <a ng-href=\"{{deployment | navigateResourceURL}}?tab=environment\">deployment</a>.\n" +
@@ -2924,13 +2925,13 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
29242925
"<span class=\"pficon pficon-info\" aria-hidden=\"true\"></span>\n" +
29252926
"Environment variables can be edited on the <a ng-href=\"{{replicaSet | configURLForResource}}?tab=environment\">deployment configuration</a>.\n" +
29262927
"</p>\n" +
2927-
"<div ng-repeat=\"container in replicaSet.spec.template.spec.containers\">\n" +
2928+
"<div ng-repeat=\"container in updatedDeployment.spec.template.spec.containers\">\n" +
29282929
"<h3>Container {{container.name}} Environment Variables</h3>\n" +
29292930
"<key-value-editor ng-if=\"container.env.length\" entries=\"container.env\" key-placeholder=\"Name\" value-placeholder=\"Value\" cannot-add cannot-delete cannot-sort is-readonly show-header></key-value-editor>\n" +
29302931
"<em ng-if=\"!container.env.length\">The container specification has no environment variables set.</em>\n" +
29312932
"</div>\n" +
29322933
"</div>\n" +
2933-
"<ng-form ng-show=\"!deployment && !(replicaSet | hasDeploymentConfig)\" name=\"forms.envForm\">\n" +
2934+
"<ng-form ng-if=\"!(replicaSet | hasDeployment) && !(replicaSet | hasDeploymentConfig)\" name=\"forms.envForm\">\n" +
29342935
"<div ng-repeat=\"container in updatedDeployment.spec.template.spec.containers\">\n" +
29352936
"<div ng-if=\"resource | canI : 'update'\">\n" +
29362937
"<key-value-editor entries=\"container.env\" key-placeholder=\"Name\" value-placeholder=\"Value\" key-validator=\"[A-Za-z_][A-Za-z0-9_]*\" key-validator-error=\"Please enter a valid key\" key-validator-error-tooltip=\"A valid environment variable name is an alphanumeric (a-z and 0-9) string beginning with a letter that may contain underscores.\" add-row-link=\"Add environment variable\" show-header></key-value-editor>\n" +

0 commit comments

Comments
 (0)
Please sign in to comment.