Skip to content

Commit b09dafe

Browse files
author
OpenShift Bot
authored
Merge pull request #2160 from benjaminapetersen/bpetersen/trello/api-groups/create-pvc
Merged by openshift-bot
2 parents 0177053 + eb19bc2 commit b09dafe

File tree

2 files changed

+43
-40
lines changed

2 files changed

+43
-40
lines changed

Diff for: app/scripts/controllers/createPersistentVolumeClaim.js

+21-18
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,
@@ -34,6 +35,22 @@ angular.module('openshiftConsole')
3435
}
3536
];
3637

38+
var pvcTemplate = {
39+
kind: "PersistentVolumeClaim",
40+
apiVersion: "v1",
41+
metadata: {
42+
name: undefined,
43+
labels: {},
44+
annotations: {}
45+
},
46+
spec: {
47+
resources: {
48+
requests:{}
49+
}
50+
}
51+
};
52+
var createPVCVersion = APIService.objectToResourceGroupVersion(pvcTemplate);
53+
3754
var hideErrorNotifications = function() {
3855
NotificationsService.hideNotification("create-pvc-error");
3956
};
@@ -48,8 +65,7 @@ angular.module('openshiftConsole')
4865
.get($routeParams.project)
4966
.then(_.spread(function(project, context) {
5067
$scope.project = project;
51-
52-
if (!AuthorizationService.canI('persistentvolumeclaims', 'create', $routeParams.project)) {
68+
if (!AuthorizationService.canI(createPVCVersion, 'create', $routeParams.project)) {
5369
Navigate.toErrorPage('You do not have authority to create persistent volume claims in project ' + $routeParams.project + '.', 'access_denied');
5470
return;
5571
}
@@ -59,7 +75,7 @@ angular.module('openshiftConsole')
5975
if ($scope.createPersistentVolumeClaimForm.$valid) {
6076
$scope.disableInputs = true;
6177
var claim = generatePersistentVolumeClaim();
62-
DataService.create('persistentvolumeclaims', null, claim, context)
78+
DataService.create(createPVCVersion, null, claim, context)
6379
.then(function(claim) { // Success
6480
NotificationsService.addNotification({
6581
type: "success",
@@ -81,21 +97,8 @@ angular.module('openshiftConsole')
8197
};
8298

8399
function generatePersistentVolumeClaim() {
84-
var pvc = {
85-
kind: "PersistentVolumeClaim",
86-
apiVersion: "v1",
87-
metadata: {
88-
name: $scope.claim.name,
89-
labels: {},
90-
annotations: {}
91-
},
92-
spec: {
93-
resources: {
94-
requests:{}
95-
}
96-
}
97-
};
98-
100+
var pvc = angular.copy(pvcTemplate);
101+
pvc.metadata.name = $scope.claim.name;
99102
pvc.spec.accessModes = [$scope.claim.accessModes || "ReadWriteOnce"] ;
100103
var unit = $scope.claim.unit || "Mi";
101104
pvc.spec.resources.requests.storage = $scope.claim.amount + unit;

Diff for: dist/scripts/scripts.js

+22-22
Original file line numberDiff line numberDiff line change
@@ -8707,27 +8707,18 @@ kubernetes: n.VERSION.kubernetes
87078707
};
87088708
} ]), angular.module("openshiftConsole").controller("CommandLineController", [ "$scope", "DataService", "AuthService", "Constants", function(e, t, n, a) {
87098709
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());
8710-
} ]), 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) {
8710+
} ]), 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) {
87118711
n.projectName = t.project, n.accessModes = "ReadWriteOnce", n.claim = {}, n.breadcrumbs = [ {
87128712
title: "Storage",
87138713
link: "project/" + n.projectName + "/browse/storage"
87148714
}, {
87158715
title: "Create Storage"
87168716
} ];
8717-
var d = function() {
8718-
c.hideNotification("create-pvc-error");
8719-
};
8720-
n.$on("$destroy", d);
8721-
var p = function() {
8722-
a.history.back();
8723-
};
8724-
n.cancel = p, l.get(t.project).then(_.spread(function(a, r) {
8725-
function l() {
8726-
var e = {
8717+
var p = {
87278718
kind: "PersistentVolumeClaim",
87288719
apiVersion: "v1",
87298720
metadata: {
8730-
name: n.claim.name,
8721+
name: void 0,
87318722
labels: {},
87328723
annotations: {}
87338724
},
@@ -8736,34 +8727,43 @@ resources: {
87368727
requests: {}
87378728
}
87388729
}
8730+
}, m = r.objectToResourceGroupVersion(p), f = function() {
8731+
l.hideNotification("create-pvc-error");
87398732
};
8740-
e.spec.accessModes = [ n.claim.accessModes || "ReadWriteOnce" ];
8733+
n.$on("$destroy", f);
8734+
var g = function() {
8735+
a.history.back();
8736+
};
8737+
n.cancel = g, u.get(t.project).then(_.spread(function(a, r) {
8738+
function o() {
8739+
var e = angular.copy(p);
8740+
e.metadata.name = n.claim.name, e.spec.accessModes = [ n.claim.accessModes || "ReadWriteOnce" ];
87418741
var t = n.claim.unit || "Mi";
87428742
if (e.spec.resources.requests.storage = n.claim.amount + t, n.claim.selectedLabels) {
8743-
var a = u.mapEntries(u.compactEntries(n.claim.selectedLabels));
8743+
var a = d.mapEntries(d.compactEntries(n.claim.selectedLabels));
87448744
_.isEmpty(a) || _.set(e, "spec.selector.matchLabels", a);
87458745
}
87468746
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;
87478747
}
8748-
n.project = a, o.canI("persistentvolumeclaims", "create", t.project) ? n.createPersistentVolumeClaim = function() {
8749-
if (d(), n.createPersistentVolumeClaimForm.$valid) {
8748+
n.project = a, i.canI(m, "create", t.project) ? n.createPersistentVolumeClaim = function() {
8749+
if (f(), n.createPersistentVolumeClaimForm.$valid) {
87508750
n.disableInputs = !0;
8751-
var t = l();
8752-
i.create("persistentvolumeclaims", null, t, r).then(function(e) {
8753-
c.addNotification({
8751+
var t = o();
8752+
s.create(m, null, t, r).then(function(e) {
8753+
l.addNotification({
87548754
type: "success",
87558755
message: "Persistent volume claim " + e.metadata.name + " successfully created."
8756-
}), p();
8756+
}), g();
87578757
}, function(t) {
8758-
n.disableInputs = !1, c.addNotification({
8758+
n.disableInputs = !1, l.addNotification({
87598759
id: "create-pvc-error",
87608760
type: "error",
87618761
message: "An error occurred requesting storage.",
87628762
details: e("getErrorDetails")(t)
87638763
});
87648764
});
87658765
}
8766-
} : s.toErrorPage("You do not have authority to create persistent volume claims in project " + t.project + ".", "access_denied");
8766+
} : c.toErrorPage("You do not have authority to create persistent volume claims in project " + t.project + ".", "access_denied");
87678767
}));
87688768
} ]), angular.module("openshiftConsole").directive("buildClose", [ "$window", function(e) {
87698769
var t = function(e) {

0 commit comments

Comments
 (0)