Skip to content

Commit 909e639

Browse files
Update CreatePersistentVolumeClaimController to use getPreferredVersion
1 parent 7f87b32 commit 909e639

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

app/scripts/controllers/createPersistentVolumeClaim.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ angular.module('openshiftConsole')
1313
$routeParams,
1414
$scope,
1515
$window,
16+
APIService,
1617
ApplicationGenerator,
1718
AuthorizationService,
1819
DataService,
@@ -24,6 +25,8 @@ angular.module('openshiftConsole')
2425
$scope.accessModes="ReadWriteOnce";
2526
$scope.claim = {};
2627

28+
var persistentVolumeClaimsVersion = APIService.getPreferredVersion('persistentvolumeclaims');
29+
2730
$scope.breadcrumbs = [
2831
{
2932
title: "Storage",
@@ -49,7 +52,7 @@ angular.module('openshiftConsole')
4952
.then(_.spread(function(project, context) {
5053
$scope.project = project;
5154

52-
if (!AuthorizationService.canI('persistentvolumeclaims', 'create', $routeParams.project)) {
55+
if (!AuthorizationService.canI(persistentVolumeClaimsVersion, 'create', $routeParams.project)) {
5356
Navigate.toErrorPage('You do not have authority to create persistent volume claims in project ' + $routeParams.project + '.', 'access_denied');
5457
return;
5558
}
@@ -59,7 +62,8 @@ angular.module('openshiftConsole')
5962
if ($scope.createPersistentVolumeClaimForm.$valid) {
6063
$scope.disableInputs = true;
6164
var claim = generatePersistentVolumeClaim();
62-
DataService.create('persistentvolumeclaims', null, claim, context)
65+
var createClaimVersion = APIService.objectToResourceGroupVersion(claim);
66+
DataService.create(createClaimVersion, null, claim, context)
6367
.then(function(claim) { // Success
6468
NotificationsService.addNotification({
6569
type: "success",

dist/scripts/scripts.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -8677,22 +8677,24 @@ kubernetes: n.VERSION.kubernetes
86778677
};
86788678
} ]), angular.module("openshiftConsole").controller("CommandLineController", [ "$scope", "DataService", "AuthService", "Constants", function(e, t, n, a) {
86798679
n.withUser(), e.cliDownloadURL = a.CLI, e.cliDownloadURLPresent = e.cliDownloadURL && !_.isEmpty(e.cliDownloadURL), e.loginBaseURL = t.openshiftAPIBaseUrl(), a.DISABLE_COPY_LOGIN_COMMAND || (e.sessionToken = n.UserStore().getToken());
8680-
} ]), angular.module("openshiftConsole").controller("CreatePersistentVolumeClaimController", [ "$filter", "$routeParams", "$scope", "$window", "ApplicationGenerator", "AuthorizationService", "DataService", "Navigate", "NotificationsService", "ProjectsService", "keyValueEditorUtils", function(e, t, n, a, r, o, i, s, c, l, u) {
8681-
n.projectName = t.project, n.accessModes = "ReadWriteOnce", n.claim = {}, n.breadcrumbs = [ {
8680+
} ]), angular.module("openshiftConsole").controller("CreatePersistentVolumeClaimController", [ "$filter", "$routeParams", "$scope", "$window", "APIService", "ApplicationGenerator", "AuthorizationService", "DataService", "Navigate", "NotificationsService", "ProjectsService", "keyValueEditorUtils", function(e, t, n, a, r, o, i, s, c, l, u, d) {
8681+
n.projectName = t.project, n.accessModes = "ReadWriteOnce", n.claim = {};
8682+
var p = r.getPreferredVersion("persistentvolumeclaims");
8683+
n.breadcrumbs = [ {
86828684
title: "Storage",
86838685
link: "project/" + n.projectName + "/browse/storage"
86848686
}, {
86858687
title: "Create Storage"
86868688
} ];
8687-
var d = function() {
8688-
c.hideNotification("create-pvc-error");
8689+
var m = function() {
8690+
l.hideNotification("create-pvc-error");
86898691
};
8690-
n.$on("$destroy", d);
8691-
var p = function() {
8692+
n.$on("$destroy", m);
8693+
var f = function() {
86928694
a.history.back();
86938695
};
8694-
n.cancel = p, l.get(t.project).then(_.spread(function(a, r) {
8695-
function l() {
8696+
n.cancel = f, u.get(t.project).then(_.spread(function(a, o) {
8697+
function u() {
86968698
var e = {
86978699
kind: "PersistentVolumeClaim",
86988700
apiVersion: "v1",
@@ -8710,30 +8712,30 @@ requests: {}
87108712
e.spec.accessModes = [ n.claim.accessModes || "ReadWriteOnce" ];
87118713
var t = n.claim.unit || "Mi";
87128714
if (e.spec.resources.requests.storage = n.claim.amount + t, n.claim.selectedLabels) {
8713-
var a = u.mapEntries(u.compactEntries(n.claim.selectedLabels));
8715+
var a = d.mapEntries(d.compactEntries(n.claim.selectedLabels));
87148716
_.isEmpty(a) || _.set(e, "spec.selector.matchLabels", a);
87158717
}
87168718
return n.claim.storageClass && "No Storage Class" !== n.claim.storageClass.metadata.name && (e.metadata.annotations["volume.beta.kubernetes.io/storage-class"] = n.claim.storageClass.metadata.name), e;
87178719
}
8718-
n.project = a, o.canI("persistentvolumeclaims", "create", t.project) ? n.createPersistentVolumeClaim = function() {
8719-
if (d(), n.createPersistentVolumeClaimForm.$valid) {
8720+
n.project = a, i.canI(p, "create", t.project) ? n.createPersistentVolumeClaim = function() {
8721+
if (m(), n.createPersistentVolumeClaimForm.$valid) {
87208722
n.disableInputs = !0;
8721-
var t = l();
8722-
i.create("persistentvolumeclaims", null, t, r).then(function(e) {
8723-
c.addNotification({
8723+
var t = u(), a = r.objectToResourceGroupVersion(t);
8724+
s.create(a, null, t, o).then(function(e) {
8725+
l.addNotification({
87248726
type: "success",
87258727
message: "Persistent volume claim " + e.metadata.name + " successfully created."
8726-
}), p();
8728+
}), f();
87278729
}, function(t) {
8728-
n.disableInputs = !1, c.addNotification({
8730+
n.disableInputs = !1, l.addNotification({
87298731
id: "create-pvc-error",
87308732
type: "error",
87318733
message: "An error occurred requesting storage.",
87328734
details: e("getErrorDetails")(t)
87338735
});
87348736
});
87358737
}
8736-
} : s.toErrorPage("You do not have authority to create persistent volume claims in project " + t.project + ".", "access_denied");
8738+
} : c.toErrorPage("You do not have authority to create persistent volume claims in project " + t.project + ".", "access_denied");
87378739
}));
87388740
} ]), angular.module("openshiftConsole").directive("buildClose", [ "$window", function(e) {
87398741
var t = function(e) {

0 commit comments

Comments
 (0)