Skip to content

Commit 096fc19

Browse files
committed
Support binding parameters
Adds bind parameters to overview "Create Binding" action and in context provision binding. Bumps origin-web-common 0.0.52 -> 0.0.53 Bumps origin-web-catalog 0.0.42 -> to 0.0.43 https://trello.com/c/Sws4p5jU
1 parent 38eb4eb commit 096fc19

File tree

8 files changed

+351
-191
lines changed

8 files changed

+351
-191
lines changed

app/scripts/directives/bindService.js

+79-31
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
DataService,
2424
BindingService) {
2525
var ctrl = this;
26-
var validityWatcher;
26+
var bindFormStep;
27+
var bindParametersStep;
28+
var resultsStep;
29+
var selectionValidityWatcher;
30+
var parametersValidityWatcher;
2731
var bindingWatch;
2832
var statusCondition = $filter('statusCondition');
2933
var enableTechPreviewFeature = $filter('enableTechPreviewFeature');
@@ -70,18 +74,31 @@
7074
};
7175

7276
var showBind = function() {
77+
ctrl.nextTitle = bindParametersStep.hidden ? 'Bind' : 'Next >';
78+
if (ctrl.podPresets && !selectionValidityWatcher) {
79+
selectionValidityWatcher = $scope.$watch("ctrl.selectionForm.$valid", function(isValid) {
80+
bindFormStep.valid = isValid;
81+
});
82+
}
83+
};
84+
85+
var showParameters = function() {
7386
ctrl.nextTitle = 'Bind';
74-
if (ctrl.podPresets) {
75-
validityWatcher = $scope.$watch("ctrl.selectionForm.$valid", function(isValid) {
76-
ctrl.steps[0].valid = isValid;
87+
if (!parametersValidityWatcher) {
88+
parametersValidityWatcher = $scope.$watch("ctrl.parametersForm.$valid", function(isValid) {
89+
bindParametersStep.valid = isValid;
7790
});
7891
}
7992
};
8093

8194
var showResults = function() {
82-
if (validityWatcher) {
83-
validityWatcher();
84-
validityWatcher = undefined;
95+
if (selectionValidityWatcher) {
96+
selectionValidityWatcher();
97+
selectionValidityWatcher = undefined;
98+
}
99+
if (parametersValidityWatcher) {
100+
parametersValidityWatcher();
101+
parametersValidityWatcher = undefined;
85102
}
86103
ctrl.nextTitle = "Close";
87104
ctrl.wizardComplete = true;
@@ -141,38 +158,65 @@
141158
});
142159
};
143160

161+
bindFormStep = {
162+
id: 'bindForm',
163+
label: 'Binding',
164+
view: 'views/directives/bind-service/bind-service-form.html',
165+
valid: true,
166+
onShow: showBind
167+
};
168+
169+
bindParametersStep = {
170+
id: 'bindParameters',
171+
label: 'Parameters',
172+
view: 'views/directives/bind-service/bind-parameters.html',
173+
hidden: true,
174+
onShow: showParameters
175+
};
176+
177+
resultsStep = {
178+
id: 'results',
179+
label: 'Results',
180+
view: 'views/directives/bind-service/results.html',
181+
valid: true,
182+
onShow: showResults
183+
};
184+
185+
var updateInstance = function() {
186+
if (!ctrl.serviceClasses) {
187+
return;
188+
}
189+
190+
var instance = ctrl.target.kind === 'Instance' ? ctrl.target : ctrl.serviceToBind;
191+
if (!instance) {
192+
return;
193+
}
194+
195+
ctrl.serviceClass = ctrl.serviceClasses[instance.spec.serviceClassName];
196+
ctrl.serviceClassName = instance.spec.serviceClassName;
197+
ctrl.plan = BindingService.getPlanForInstance(instance, ctrl.serviceClass);
198+
ctrl.parameterSchema = _.get(ctrl.plan, 'alphaBindingCreateParameterSchema');
199+
bindParametersStep.hidden = !_.has(ctrl.parameterSchema, 'properties');
200+
ctrl.nextTitle = bindParametersStep.hidden ? 'Bind' : 'Next >';
201+
};
202+
203+
$scope.$watch("ctrl.serviceToBind", updateInstance);
204+
144205
ctrl.$onInit = function() {
145206
ctrl.serviceSelection = {};
146207
ctrl.projectDisplayName = $filter('displayName')(ctrl.project);
147208
ctrl.podPresets = enableTechPreviewFeature('pod_presets');
209+
ctrl.parameterData = {};
148210

149-
ctrl.steps = [
150-
{
151-
id: 'bindForm',
152-
label: "Binding",
153-
view: 'views/directives/bind-service/bind-service-form.html',
154-
valid: true,
155-
onShow: showBind
156-
},
157-
{
158-
label: 'Results',
159-
id: 'results',
160-
view: 'views/directives/bind-service/results.html',
161-
valid: true,
162-
onShow: showResults
163-
}
164-
];
211+
ctrl.steps = [ bindFormStep, bindParametersStep, resultsStep ];
165212

166213
// We will want ServiceClasses either way for display purposes
167214
DataService.list({
168215
group: 'servicecatalog.k8s.io',
169216
resource: 'serviceclasses'
170217
}, {}).then(function(serviceClasses) {
171218
ctrl.serviceClasses = serviceClasses.by('metadata.name');
172-
if (ctrl.target.kind === 'Instance') {
173-
ctrl.serviceClass = ctrl.serviceClasses[ctrl.target.spec.serviceClassName];
174-
ctrl.serviceClassName = ctrl.target.spec.serviceClassName;
175-
}
219+
updateInstance();
176220
sortServiceInstances();
177221
});
178222

@@ -198,9 +242,13 @@
198242
};
199243

200244
ctrl.$onDestroy = function() {
201-
if (validityWatcher) {
202-
validityWatcher();
203-
validityWatcher = undefined;
245+
if (selectionValidityWatcher) {
246+
selectionValidityWatcher();
247+
selectionValidityWatcher = undefined;
248+
}
249+
if (parametersValidityWatcher) {
250+
parametersValidityWatcher();
251+
parametersValidityWatcher = undefined;
204252
}
205253
if (bindingWatch) {
206254
DataService.unwatch(bindingWatch);
@@ -216,7 +264,7 @@
216264
};
217265

218266
var serviceClass = BindingService.getServiceClassForInstance(svcToBind, ctrl.serviceClasses);
219-
BindingService.bindService(svcToBind, application, serviceClass).then(function(binding){
267+
BindingService.bindService(svcToBind, application, serviceClass, ctrl.parameterData).then(function(binding){
220268
ctrl.binding = binding;
221269
ctrl.error = null;
222270

app/views/directives/bind-service.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
<pf-wizard
33
hide-header="true"
44
hide-sidebar="true"
5-
hide-back-button="true"
65
step-class="bind-service-wizard-step"
76
wizard-ready="ctrl.wizardReady"
87
next-title="ctrl.nextTitle"
98
on-finish="ctrl.closeWizard()"
109
on-cancel="ctrl.closeWizard()"
11-
wizard-done="ctrl.wizardComplete"
12-
class="pf-wizard-no-back">
10+
wizard-done="ctrl.wizardComplete">
1311
<pf-wizard-step ng-repeat="step in ctrl.steps track by $index"
1412
step-title="{{step.label}}"
1513
next-enabled="step.valid"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<form name="ctrl.parametersForm">
2+
<catalog-parameters model="ctrl.parameterData" parameter-schema="ctrl.parameterSchema"></catalog-parameters>
3+
</form>

bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"angular-moment": "1.0.0",
4747
"angular-utf8-base64": "0.0.5",
4848
"file-saver": "1.3.3",
49-
"origin-web-common": "0.0.52",
50-
"origin-web-catalog": "0.0.42"
49+
"origin-web-common": "0.0.53",
50+
"origin-web-catalog": "0.0.43"
5151
},
5252
"devDependencies": {
5353
"angular-mocks": "1.5.11",

dist/scripts/scripts.js

+65-48
Original file line numberDiff line numberDiff line change
@@ -12249,96 +12249,113 @@ templateUrl: "views/directives/route-service-bar-chart.html"
1224912249
}(), function() {
1225012250
angular.module("openshiftConsole").component("bindService", {
1225112251
controller: [ "$scope", "$filter", "DataService", "BindingService", function(e, t, n, a) {
12252-
var r, o, i, s, c, l, u, d = this, m = t("statusCondition"), p = t("enableTechPreviewFeature"), f = function() {
12252+
var r, o, i, s, c, l, u, d, m, p, f, g = this, h = t("statusCondition"), v = t("enableTechPreviewFeature"), y = function() {
1225312253
var e, t;
12254-
_.each(d.serviceInstances, function(n) {
12255-
var a = "True" === _.get(m(n, "Ready"), "status");
12254+
_.each(g.serviceInstances, function(n) {
12255+
var a = "True" === _.get(h(n, "Ready"), "status");
1225612256
a && (!e || n.metadata.creationTimestamp > e.metadata.creationTimestamp) && (e = n), a || t && !(n.metadata.creationTimestamp > t.metadata.creationTimestamp) || (t = n);
12257-
}), d.serviceToBind = e || t;
12258-
}, g = function() {
12259-
d.serviceClasses && d.serviceInstances && (d.serviceInstances = a.filterBindableServiceInstances(d.serviceInstances, d.serviceClasses), d.orderedServiceInstances = a.sortServiceInstances(d.serviceInstances, d.serviceClasses), d.serviceToBind || f());
12260-
}, h = function() {
12261-
if (i && s && c && l && u) {
12262-
var e = [].concat(i).concat(s).concat(c).concat(l).concat(u);
12263-
d.applications = _.sortBy(e, [ "metadata.name", "kind" ]), d.bindType = d.applications.length ? "application" : "secret-only";
12264-
}
12265-
}, v = function() {
12266-
d.nextTitle = "Bind", d.podPresets && (r = e.$watch("ctrl.selectionForm.$valid", function(e) {
12267-
d.steps[0].valid = e;
12268-
}));
12269-
}, y = function() {
12270-
r && (r(), r = void 0), d.nextTitle = "Close", d.wizardComplete = !0, d.bindService();
12257+
}), g.serviceToBind = e || t;
1227112258
}, b = function() {
12259+
g.serviceClasses && g.serviceInstances && (g.serviceInstances = a.filterBindableServiceInstances(g.serviceInstances, g.serviceClasses), g.orderedServiceInstances = a.sortServiceInstances(g.serviceInstances, g.serviceClasses), g.serviceToBind || y());
12260+
}, C = function() {
12261+
if (u && d && m && p && f) {
12262+
var e = [].concat(u).concat(d).concat(m).concat(p).concat(f);
12263+
g.applications = _.sortBy(e, [ "metadata.name", "kind" ]), g.bindType = g.applications.length ? "application" : "secret-only";
12264+
}
12265+
}, S = function() {
1227212266
var e = {
12273-
namespace: _.get(d.target, "metadata.namespace")
12267+
namespace: _.get(g.target, "metadata.namespace")
1227412268
};
1227512269
n.list("deploymentconfigs", e).then(function(e) {
12276-
i = _.toArray(e.by("metadata.name")), h();
12270+
u = _.toArray(e.by("metadata.name")), C();
1227712271
}), n.list("replicationcontrollers", e).then(function(e) {
12278-
c = _.reject(e.by("metadata.name"), t("hasDeploymentConfig")), h();
12272+
m = _.reject(e.by("metadata.name"), t("hasDeploymentConfig")), C();
1227912273
}), n.list({
1228012274
group: "apps",
1228112275
resource: "deployments"
1228212276
}, e).then(function(e) {
12283-
s = _.toArray(e.by("metadata.name")), h();
12277+
d = _.toArray(e.by("metadata.name")), C();
1228412278
}), n.list({
1228512279
group: "extensions",
1228612280
resource: "replicasets"
1228712281
}, e).then(function(e) {
12288-
l = _.reject(e.by("metadata.name"), t("hasDeployment")), h();
12282+
p = _.reject(e.by("metadata.name"), t("hasDeployment")), C();
1228912283
}), n.list({
1229012284
group: "apps",
1229112285
resource: "statefulsets"
1229212286
}, e).then(function(e) {
12293-
u = _.toArray(e.by("metadata.name")), h();
12287+
f = _.toArray(e.by("metadata.name")), C();
1229412288
});
12295-
}, C = function() {
12289+
}, w = function() {
1229612290
var e = {
12297-
namespace: _.get(d.target, "metadata.namespace")
12291+
namespace: _.get(g.target, "metadata.namespace")
1229812292
};
1229912293
n.list({
1230012294
group: "servicecatalog.k8s.io",
1230112295
resource: "instances"
1230212296
}, e).then(function(e) {
12303-
d.serviceInstances = e.by("metadata.name"), g();
12297+
g.serviceInstances = e.by("metadata.name"), b();
1230412298
});
1230512299
};
12306-
d.$onInit = function() {
12307-
d.serviceSelection = {}, d.projectDisplayName = t("displayName")(d.project), d.podPresets = p("pod_presets"), d.steps = [ {
12300+
r = {
1230812301
id: "bindForm",
1230912302
label: "Binding",
1231012303
view: "views/directives/bind-service/bind-service-form.html",
1231112304
valid: !0,
12312-
onShow: v
12313-
}, {
12314-
label: "Results",
12305+
onShow: function() {
12306+
g.nextTitle = o.hidden ? "Bind" : "Next >", g.podPresets && !s && (s = e.$watch("ctrl.selectionForm.$valid", function(e) {
12307+
r.valid = e;
12308+
}));
12309+
}
12310+
}, o = {
12311+
id: "bindParameters",
12312+
label: "Parameters",
12313+
view: "views/directives/bind-service/bind-parameters.html",
12314+
hidden: !0,
12315+
onShow: function() {
12316+
g.nextTitle = "Bind", c || (c = e.$watch("ctrl.parametersForm.$valid", function(e) {
12317+
o.valid = e;
12318+
}));
12319+
}
12320+
}, i = {
1231512321
id: "results",
12322+
label: "Results",
1231612323
view: "views/directives/bind-service/results.html",
1231712324
valid: !0,
12318-
onShow: y
12319-
} ], n.list({
12325+
onShow: function() {
12326+
s && (s(), s = void 0), c && (c(), c = void 0), g.nextTitle = "Close", g.wizardComplete = !0, g.bindService();
12327+
}
12328+
};
12329+
var k = function() {
12330+
if (g.serviceClasses) {
12331+
var e = "Instance" === g.target.kind ? g.target : g.serviceToBind;
12332+
e && (g.serviceClass = g.serviceClasses[e.spec.serviceClassName], g.serviceClassName = e.spec.serviceClassName, g.plan = a.getPlanForInstance(e, g.serviceClass), g.parameterSchema = _.get(g.plan, "alphaBindingCreateParameterSchema"), o.hidden = !_.has(g.parameterSchema, "properties"), g.nextTitle = o.hidden ? "Bind" : "Next >");
12333+
}
12334+
};
12335+
e.$watch("ctrl.serviceToBind", k), g.$onInit = function() {
12336+
g.serviceSelection = {}, g.projectDisplayName = t("displayName")(g.project), g.podPresets = v("pod_presets"), g.parameterData = {}, g.steps = [ r, o, i ], n.list({
1232012337
group: "servicecatalog.k8s.io",
1232112338
resource: "serviceclasses"
1232212339
}, {}).then(function(e) {
12323-
d.serviceClasses = e.by("metadata.name"), "Instance" === d.target.kind && (d.serviceClass = d.serviceClasses[d.target.spec.serviceClassName], d.serviceClassName = d.target.spec.serviceClassName), g();
12324-
}), "Instance" === d.target.kind ? (d.bindType = "secret-only", d.appToBind = null, d.serviceToBind = d.target, d.podPresets && b()) : (d.bindType = "application", d.appToBind = d.target, C());
12325-
}, d.$onChanges = function(e) {
12326-
e.project && !e.project.isFirstChange() && (d.projectDisplayName = t("displayName")(d.project));
12327-
}, d.$onDestroy = function() {
12328-
r && (r(), r = void 0), o && n.unwatch(o);
12329-
}, d.bindService = function() {
12330-
var e = "Instance" === d.target.kind ? d.target : d.serviceToBind, t = "application" === d.bindType ? d.appToBind : void 0, r = {
12340+
g.serviceClasses = e.by("metadata.name"), k(), b();
12341+
}), "Instance" === g.target.kind ? (g.bindType = "secret-only", g.appToBind = null, g.serviceToBind = g.target, g.podPresets && S()) : (g.bindType = "application", g.appToBind = g.target, w());
12342+
}, g.$onChanges = function(e) {
12343+
e.project && !e.project.isFirstChange() && (g.projectDisplayName = t("displayName")(g.project));
12344+
}, g.$onDestroy = function() {
12345+
s && (s(), s = void 0), c && (c(), c = void 0), l && n.unwatch(l);
12346+
}, g.bindService = function() {
12347+
var e = "Instance" === g.target.kind ? g.target : g.serviceToBind, t = "application" === g.bindType ? g.appToBind : void 0, r = {
1233112348
namespace: _.get(e, "metadata.namespace")
12332-
}, i = a.getServiceClassForInstance(e, d.serviceClasses);
12333-
a.bindService(e, t, i).then(function(e) {
12334-
d.binding = e, d.error = null, o = n.watchObject(a.bindingResource, _.get(d.binding, "metadata.name"), r, function(e) {
12335-
d.binding = e;
12349+
}, o = a.getServiceClassForInstance(e, g.serviceClasses);
12350+
a.bindService(e, t, o, g.parameterData).then(function(e) {
12351+
g.binding = e, g.error = null, l = n.watchObject(a.bindingResource, _.get(g.binding, "metadata.name"), r, function(e) {
12352+
g.binding = e;
1233612353
});
1233712354
}, function(e) {
12338-
d.error = e;
12355+
g.error = e;
1233912356
});
12340-
}, d.closeWizard = function() {
12341-
_.isFunction(d.onClose) && d.onClose();
12357+
}, g.closeWizard = function() {
12358+
_.isFunction(g.onClose) && g.onClose();
1234212359
};
1234312360
} ],
1234412361
controllerAs: "ctrl",

dist/scripts/templates.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -5559,7 +5559,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
55595559

55605560
$templateCache.put('views/directives/bind-service.html',
55615561
"<div class=\"bind-service-wizard\">\n" +
5562-
"<pf-wizard hide-header=\"true\" hide-sidebar=\"true\" hide-back-button=\"true\" step-class=\"bind-service-wizard-step\" wizard-ready=\"ctrl.wizardReady\" next-title=\"ctrl.nextTitle\" on-finish=\"ctrl.closeWizard()\" on-cancel=\"ctrl.closeWizard()\" wizard-done=\"ctrl.wizardComplete\" class=\"pf-wizard-no-back\">\n" +
5562+
"<pf-wizard hide-header=\"true\" hide-sidebar=\"true\" step-class=\"bind-service-wizard-step\" wizard-ready=\"ctrl.wizardReady\" next-title=\"ctrl.nextTitle\" on-finish=\"ctrl.closeWizard()\" on-cancel=\"ctrl.closeWizard()\" wizard-done=\"ctrl.wizardComplete\">\n" +
55635563
"<pf-wizard-step ng-repeat=\"step in ctrl.steps track by $index\" step-title=\"{{step.label}}\" next-enabled=\"step.valid\" on-show=\"step.onShow\" step-id=\"{{step.id}}\" step-priority=\"{{$index}}\">\n" +
55645564
"<div class=\"wizard-pf-main-inner-shadow-covers\">\n" +
55655565
"<div class=\"bind-service-config\">\n" +
@@ -5572,6 +5572,13 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
55725572
);
55735573

55745574

5575+
$templateCache.put('views/directives/bind-service/bind-parameters.html',
5576+
"<form name=\"ctrl.parametersForm\">\n" +
5577+
"<catalog-parameters model=\"ctrl.parameterData\" parameter-schema=\"ctrl.parameterSchema\"></catalog-parameters>\n" +
5578+
"</form>"
5579+
);
5580+
5581+
55755582
$templateCache.put('views/directives/bind-service/bind-service-form.html',
55765583
"<div ng-if=\"ctrl.target.kind !== 'Instance'\">\n" +
55775584
"<bind-application-form application-name=\"ctrl.target.metadata.name\" form-name=\"ctrl.selectionForm\" service-classes=\"ctrl.serviceClasses\" service-instances=\"ctrl.orderedServiceInstances\" service-to-bind=\"ctrl.serviceToBind\">\n" +

0 commit comments

Comments
 (0)