Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enterprise-3.11] Fix bug where cannot create new role and new rolebinding in single operation using template #3116

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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