Skip to content

Commit

Permalink
Merge pull request #3116 from rhamilto/bz1673109
Browse files Browse the repository at this point in the history
Fix bug where cannot create new role and new rolebinding in single operation using template
  • Loading branch information
openshift-merge-robot authored Feb 26, 2019
2 parents 0141790 + ca5945c commit 4df3ce8
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 136 deletions.
61 changes: 29 additions & 32 deletions app/scripts/directives/processTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,38 +106,35 @@
var helpLinks = getHelpLinks(ctrl.template);
TaskList.clear();
TaskList.add(titles, helpLinks, ctrl.selectedProject.metadata.name, function() {
var d = $q.defer();
DataService.batch(processedResources, context).then(
function(result) {
var alerts = [];
var hasErrors = false;
if (result.failure.length > 0) {
hasErrors = true;
result.failure.forEach(
function(failure) {
alerts.push({
type: "error",
message: "Cannot create " + humanize(failure.object.kind).toLowerCase() + " \"" + failure.object.metadata.name + "\". ",
details: failure.data.message
});
}
);
result.success.forEach(
function(success) {
alerts.push({
type: "success",
message: "Created " + humanize(success.kind).toLowerCase() + " \"" + success.metadata.name + "\" successfully. "
});
}
);
} else {
alerts.push({ type: "success", message: "All items in template " + ctrl.templateDisplayName +
" were created successfully."});
}
d.resolve({alerts: alerts, hasErrors: hasErrors});
}
);
return d.promise;
var chain = $q.when();
var alerts = [];
var hasErrors = false;
_.each(processedResources, function(obj) {
var groupVersionKind = APIService.objectToResourceGroupVersion(obj);
chain = chain.then(function() {
return DataService.create(groupVersionKind, null, obj, context)
.then(function() {
alerts.push({
type: "success",
message: "Created " + humanize(obj.kind).toLowerCase() + " \"" + obj.metadata.name + "\" successfully. "
});
})
.catch(function(failure) {
hasErrors = true;
alerts.push({
type: "error",
message: "Cannot create " + humanize(obj.kind).toLowerCase() + " \"" + obj.metadata.name + "\". ",
details: failure.message
});
});
});
});
return chain.then(function() {
return {
alerts: alerts,
hasErrors: hasErrors
};
});
});

if (ctrl.isDialog) {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"jquery": "3.2.1",
"lodash": "4.17.4",
"matchHeight": "0.7.2",
"bootstrap": "3.4.0"
"bootstrap": ">= 3.4.0"
},
"overrides": {
"angular": {
Expand Down
31 changes: 16 additions & 15 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13769,28 +13769,29 @@ success: "Created " + h.templateDisplayName + " in project " + y(h.selectedProje
failure: "Failed to create " + h.templateDisplayName + " in project " + y(h.selectedProject)
}, r = f(h.template);
m.clear(), m.add(e, r, h.selectedProject.metadata.name, function() {
var e = t.defer();
return o.batch(S, v).then(function(t) {
var n = [], r = !1;
t.failure.length > 0 ? (r = !0, t.failure.forEach(function(e) {
var e = t.when(), n = [], r = !1;
return _.each(S, function(t) {
var i = a.objectToResourceGroupVersion(t);
e = e.then(function() {
return o.create(i, null, t, v).then(function() {
n.push({
type: "success",
message: "Created " + b(t.kind).toLowerCase() + ' "' + t.metadata.name + '" successfully. '
});
}).catch(function(e) {
r = !0, n.push({
type: "error",
message: "Cannot create " + b(e.object.kind).toLowerCase() + ' "' + e.object.metadata.name + '". ',
details: e.data.message
message: "Cannot create " + b(t.kind).toLowerCase() + ' "' + t.metadata.name + '". ',
details: e.message
});
}), t.success.forEach(function(e) {
n.push({
type: "success",
message: "Created " + b(e.kind).toLowerCase() + ' "' + e.metadata.name + '" successfully. '
});
})) : n.push({
type: "success",
message: "All items in template " + h.templateDisplayName + " were created successfully."
}), e.resolve({
});
}), e.then(function() {
return {
alerts: n,
hasErrors: r
};
});
}), e.promise;
}), h.isDialog ? n.$emit("templateInstantiated", {
project: h.selectedProject,
template: h.template
Expand Down
Loading

0 comments on commit 4df3ce8

Please sign in to comment.