Skip to content

Commit

Permalink
DEV Warning Help Text & Styling
Browse files Browse the repository at this point in the history
Include warning help text and styling of select per @sg00dwin
Separated configmap and secret duplicate check since name overlap can
happen.
  • Loading branch information
cdcabrera committed Oct 20, 2017
1 parent e9b63d8 commit b5f4b72
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
35 changes: 21 additions & 14 deletions app/scripts/directives/editEnvironmentFrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@
};

var updateEnvFromEntries = function() {
var optionsByConfigMap = {};
var optionsBySecret = {};
var entriesMap = {};
var configMapsByName = {};
var secretsByName = {};
var uniqueConfigMaps = {};
var uniqueSecrets = {};

ctrl.envFromEntries = ctrl.entries || [];

Expand All @@ -129,10 +130,10 @@
_.each(ctrl.envFromSelectorOptions, function(option) {
switch(option.kind) {
case 'ConfigMap':
optionsByConfigMap[option.metadata.name] = option;
configMapsByName[option.metadata.name] = option;
break;
case 'Secret':
optionsBySecret[option.metadata.name] = option;
secretsByName[option.metadata.name] = option;
break;
}
});
Expand All @@ -154,18 +155,24 @@
if (refType && entryType) {
var refTypeName = entry[refType].name;

if (refTypeName in optionsByConfigMap) {
entry.selectedEnvFrom = optionsByConfigMap[refTypeName];
}
if (entry.configMapRef && (refTypeName in configMapsByName)) {
entry.selectedEnvFrom = configMapsByName[refTypeName];

if (refTypeName in optionsBySecret) {
entry.selectedEnvFrom = optionsBySecret[refTypeName];
if (refTypeName in uniqueConfigMaps) {
entry.duplicateEnvFrom = true;
} else {
uniqueConfigMaps[refTypeName] = true;
}
}

if (refTypeName in entriesMap) {
entry.duplicateEnvFrom = true;
} else {
entriesMap[refTypeName] = true;
if (entry.secretRef && (refTypeName in secretsByName)) {
entry.selectedEnvFrom = secretsByName[refTypeName];

if (refTypeName in uniqueSecrets) {
entry.duplicateEnvFrom = true;
} else {
uniqueSecrets[refTypeName] = true;
}
}

if(!canI(entryType, 'get')) {
Expand Down
10 changes: 5 additions & 5 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9245,7 +9245,7 @@ return e.secretRef || e.configMapRef;
});
};
var c = function() {
var e = {}, t = {}, n = {};
var e = {}, t = {}, n = {}, o = {};
a.envFromEntries = a.entries || [], a.envFromEntries.length || s(a.envFromEntries), _.each(a.envFromSelectorOptions, function(n) {
switch (n.kind) {
case "ConfigMap":
Expand All @@ -9256,10 +9256,10 @@ case "Secret":
t[n.metadata.name] = n;
}
}), _.each(a.envFromEntries, function(a) {
var o, i;
if (a.configMapRef && (o = "configMapRef", i = "configmaps"), a.secretRef && (o = "secretRef", i = "secrets"), o && i) {
var s = a[o].name;
s in e && (a.selectedEnvFrom = e[s]), s in t && (a.selectedEnvFrom = t[s]), s in n ? a.duplicateEnvFrom = !0 : n[s] = !0, r(i, "get") || (a.isReadonly = !0);
var i, s;
if (a.configMapRef && (i = "configMapRef", s = "configmaps"), a.secretRef && (i = "secretRef", s = "secrets"), i && s) {
var c = a[i].name;
a.configMapRef && c in e && (a.selectedEnvFrom = e[c], c in n ? a.duplicateEnvFrom = !0 : n[c] = !0), a.secretRef && c in t && (a.selectedEnvFrom = t[c], c in o ? a.duplicateEnvFrom = !0 : o[c] = !0), r(s, "get") || (a.isReadonly = !0);
}
});
};
Expand Down

0 comments on commit b5f4b72

Please sign in to comment.