Skip to content

Commit b60172f

Browse files
author
OpenShift Bot
authored
Merge pull request #650 from zherman0/AddSelectorLabels
Merged by openshift-bot
2 parents f60dfc6 + 050f177 commit b60172f

File tree

6 files changed

+86
-28
lines changed

6 files changed

+86
-28
lines changed

app/scripts/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ window.OPENSHIFT_CONSTANTS = {
2727
"pull_secret": "https://docs.openshift.org/latest/dev_guide/managing_images.html#using-image-pull-secrets",
2828
"managing_secrets": "https://docs.openshift.org/latest/dev_guide/service_accounts.html#managing-allowed-secrets",
2929
"creating_secrets": "https://docs.openshift.org/latest/dev_guide/secrets.html#creating-and-using-secrets",
30+
"selector_label": "https://docs.openshift.org/latest/install_config/persistent_storage/selector_label_binding.html",
3031
"default": "https://docs.openshift.org/latest/welcome/index.html"
3132
},
3233
// Maps links names to URL's where the CLI tools can be downloaded, may point directly to files or to external pages in a CDN, for example.

app/scripts/controllers/createPersistentVolumeClaim.js

+23-21
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Controller of the openshiftConsole
99
*/
1010
angular.module('openshiftConsole')
11-
.controller('CreatePersistentVolumeClaimController', function ($filter, $routeParams, $scope, $window, ApplicationGenerator, DataService, Navigate, ProjectsService) {
11+
.controller('CreatePersistentVolumeClaimController', function ($filter, $routeParams, $scope, $window, ApplicationGenerator, DataService, Navigate, ProjectsService,keyValueEditorUtils) {
1212
$scope.alerts = {};
1313
$scope.projectName = $routeParams.project;
1414
$scope.accessModes="ReadWriteOnce";
@@ -55,29 +55,31 @@ angular.module('openshiftConsole')
5555
}
5656
};
5757

58-
function generatePersistentVolumeClaim() {
59-
var pvc = {
60-
kind: "PersistentVolumeClaim",
61-
apiVersion: "v1",
62-
metadata: {
63-
name: $scope.claim.name,
64-
labels: {}
65-
},
66-
spec: {
67-
resources: {
68-
requests:{}
69-
58+
function generatePersistentVolumeClaim() {
59+
var pvc = {
60+
kind: "PersistentVolumeClaim",
61+
apiVersion: "v1",
62+
metadata: {
63+
name: $scope.claim.name,
64+
labels: {}
65+
},
66+
spec: {
67+
resources: {
68+
requests:{}
69+
},
70+
selector:{
71+
matchLabels:{}
72+
}
7073
}
71-
}
72-
};
73-
74-
pvc.spec.accessModes = [$scope.claim.accessModes || "ReadWriteOnce"] ;
75-
var unit = $scope.claim.unit || "Mi";
76-
pvc.spec.resources.requests.storage = $scope.claim.amount + unit;
74+
};
7775

78-
return pvc;
79-
}
76+
pvc.spec.accessModes = [$scope.claim.accessModes || "ReadWriteOnce"] ;
77+
var unit = $scope.claim.unit || "Mi";
78+
pvc.spec.resources.requests.storage = $scope.claim.amount + unit;
79+
pvc.spec.selector.matchLabels = keyValueEditorUtils.mapEntries( keyValueEditorUtils.compactEntries($scope.claim.selectedLabels) );
8080

81+
return pvc;
82+
}
8183

8284
}));
8385
});

app/scripts/directives/oscPersistentVolumeClaim.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ angular.module("openshiftConsole")
1313
scope.units = [{
1414
value: "Mi",
1515
label: "MiB"
16-
}, {
16+
}, {
1717
value: "Gi",
1818
label: "GiB"
19-
}, {
19+
}, {
2020
value: "Ti",
2121
label: "TiB"
22-
}, {
22+
}, {
2323
value: "Pi",
2424
label: "PiB"
25-
}];
25+
}];
26+
scope.claim.selectedLabels = [];
2627
}
2728
};
2829
});

app/views/directives/osc-persistent-volume-claim.html

+31
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,36 @@
9191
</div>
9292
</fieldset>
9393
</div>
94+
<!--advanced options-->
95+
<div>
96+
<a href=""
97+
ng-click="showAdvancedOptions = true"
98+
ng-show="!showAdvancedOptions">Use label selectors in the storage request </a>
99+
<a href=""
100+
ng-click="showAdvancedOptions = false"
101+
ng-show="showAdvancedOptions">Hide label selectors in the storage request</a>
102+
103+
104+
<div ng-show="showAdvancedOptions" class="form-group" >
105+
<fieldset class="compute-resource" >
106+
<label for="claim-name" >Label Selector</label>
107+
<div>
108+
<span id="claim-label-help" class="help-block">
109+
Enter a label and value to use with your requested storage.
110+
<div class="learn-more-block" ng-class="{ 'gutter-bottom': showPodWarning }">
111+
<a href="{{'selector_label' | helpLink}}" target="_blank">Learn more <i class="fa fa-external-link" aria-hidden="true"> </i></a>
112+
</div>
113+
</span>
114+
</div>
115+
<key-value-editor
116+
entries="claim.selectedLabels"
117+
key-placeholder="label"
118+
value-placeholder="value"
119+
key-validator="[a-zA-Z][a-zA-Z0-9_-]*"
120+
key-validator-error-tooltip="A valid label name is an alphanumeric (a-z and 0-9) string beginning with a letter that may contain underscores and dashes."
121+
add-row-link="Add Label"></key-value-editor>
122+
</fieldset>
123+
</div>
124+
</div>
94125
</fieldset>
95126
</ng-form>

dist/scripts/scripts.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ git_secret:"https://docs.openshift.org/latest/dev_guide/builds.html#using-privat
2424
pull_secret:"https://docs.openshift.org/latest/dev_guide/managing_images.html#using-image-pull-secrets",
2525
managing_secrets:"https://docs.openshift.org/latest/dev_guide/service_accounts.html#managing-allowed-secrets",
2626
creating_secrets:"https://docs.openshift.org/latest/dev_guide/secrets.html#creating-and-using-secrets",
27+
selector_label:"https://docs.openshift.org/latest/install_config/persistent_storage/selector_label_binding.html",
2728
"default":"https://docs.openshift.org/latest/welcome/index.html"
2829
},
2930
CLI:{
@@ -6958,7 +6959,7 @@ kubernetes:c.VERSION.kubernetes
69586959
c.withUser(), a.cliDownloadURL = d.CLI, a.cliDownloadURLPresent = a.cliDownloadURL && !_.isEmpty(a.cliDownloadURL), a.loginBaseURL = b.openshiftAPIBaseUrl(), a.sessionToken = c.UserStore().getToken(), a.showSessionToken = !1, a.toggleShowSessionToken = function() {
69596960
a.showSessionToken = !a.showSessionToken;
69606961
};
6961-
} ]), angular.module("openshiftConsole").controller("CreatePersistentVolumeClaimController", [ "$filter", "$routeParams", "$scope", "$window", "ApplicationGenerator", "DataService", "Navigate", "ProjectsService", function(a, b, c, d, e, f, g, h) {
6962+
} ]), angular.module("openshiftConsole").controller("CreatePersistentVolumeClaimController", [ "$filter", "$routeParams", "$scope", "$window", "ApplicationGenerator", "DataService", "Navigate", "ProjectsService", "keyValueEditorUtils", function(a, b, c, d, e, f, g, h, i) {
69626963
c.alerts = {}, c.projectName = b.project, c.accessModes = "ReadWriteOnce", c.claim = {}, c.breadcrumbs = [ {
69636964
title:c.projectName,
69646965
link:"project/" + c.projectName
@@ -6979,12 +6980,15 @@ labels:{}
69796980
spec:{
69806981
resources:{
69816982
requests:{}
6983+
},
6984+
selector:{
6985+
matchLabels:{}
69826986
}
69836987
}
69846988
};
69856989
a.spec.accessModes = [ c.claim.accessModes || "ReadWriteOnce" ];
69866990
var b = c.claim.unit || "Mi";
6987-
return a.spec.resources.requests.storage = c.claim.amount + b, a;
6991+
return a.spec.resources.requests.storage = c.claim.amount + b, a.spec.selector.matchLabels = i.mapEntries(i.compactEntries(c.claim.selectedLabels)), a;
69886992
}
69896993
c.project = b, c.breadcrumbs[0].title = a("displayName")(b), c.createPersistentVolumeClaim = function() {
69906994
if (c.createPersistentVolumeClaimForm.$valid) {
@@ -8064,7 +8068,7 @@ label:"TiB"
80648068
}, {
80658069
value:"Pi",
80668070
label:"PiB"
8067-
} ];
8071+
} ], a.claim.selectedLabels = [];
80688072
}
80698073
};
80708074
}), angular.module("openshiftConsole").directive("oscUnique", function() {

dist/scripts/templates.js

+19
Original file line numberDiff line numberDiff line change
@@ -6326,6 +6326,25 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
63266326
"</div>\n" +
63276327
"</fieldset>\n" +
63286328
"</div>\n" +
6329+
"\n" +
6330+
"<div>\n" +
6331+
"<a href=\"\" ng-click=\"showAdvancedOptions = true\" ng-show=\"!showAdvancedOptions\">Use label selectors in the storage request </a>\n" +
6332+
"<a href=\"\" ng-click=\"showAdvancedOptions = false\" ng-show=\"showAdvancedOptions\">Hide label selectors in the storage request</a>\n" +
6333+
"<div ng-show=\"showAdvancedOptions\" class=\"form-group\">\n" +
6334+
"<fieldset class=\"compute-resource\">\n" +
6335+
"<label for=\"claim-name\">Label Selector</label>\n" +
6336+
"<div>\n" +
6337+
"<span id=\"claim-label-help\" class=\"help-block\">\n" +
6338+
"Enter a label and value to use with your requested storage.\n" +
6339+
"<div class=\"learn-more-block\" ng-class=\"{ 'gutter-bottom': showPodWarning }\">\n" +
6340+
"<a href=\"{{'selector_label' | helpLink}}\" target=\"_blank\">Learn more <i class=\"fa fa-external-link\" aria-hidden=\"true\"> </i></a>\n" +
6341+
"</div>\n" +
6342+
"</span>\n" +
6343+
"</div>\n" +
6344+
"<key-value-editor entries=\"claim.selectedLabels\" key-placeholder=\"label\" value-placeholder=\"value\" key-validator=\"[a-zA-Z][a-zA-Z0-9_-]*\" key-validator-error-tooltip=\"A valid label name is an alphanumeric (a-z and 0-9) string beginning with a letter that may contain underscores and dashes.\" add-row-link=\"Add Label\"></key-value-editor>\n" +
6345+
"</fieldset>\n" +
6346+
"</div>\n" +
6347+
"</div>\n" +
63296348
"</fieldset>\n" +
63306349
"</ng-form>"
63316350
);

0 commit comments

Comments
 (0)