Skip to content

Commit

Permalink
Update bind types for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 committed Jun 1, 2017
1 parent 292072a commit 1911577
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
10 changes: 6 additions & 4 deletions app/scripts/directives/bindService.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function BindService($scope,
.concat(replicaSets)
.concat(statefulSets);
ctrl.applications = _.sortByAll(apiObjects, ['metadata.name', 'kind']);
ctrl.shouldBindToApp = ctrl.applications.length ? "true" : "false";
ctrl.bindType = ctrl.applications.length ? "application" : "secret-only";
}
};

Expand Down Expand Up @@ -133,7 +133,7 @@ function BindService($scope,

// TODO is it ever realistically possible for target to not be defined at this point
if (ctrl.target.kind === 'Instance') {
ctrl.shouldBindToApp = "false";
ctrl.bindType = "secret-only";
ctrl.appToBind = null;
ctrl.serviceToBind = ctrl.target.metadata.name;
// Load all the "application" types
Expand Down Expand Up @@ -168,6 +168,8 @@ function BindService($scope,
});
}
else {
ctrl.bindType = 'application';
ctrl.appToBind = ctrl.target;
DataService.list({
group: 'servicecatalog.k8s.io',
resource: 'instances'
Expand Down Expand Up @@ -195,13 +197,13 @@ function BindService($scope,

ctrl.bindService = function() {
var svcToBind = ctrl.target.kind === 'Instance' ? ctrl.target : ctrl.serviceInstances[ctrl.serviceToBind];
var appToBind = ctrl.target.kind !== 'Instance' ? ctrl.target : ctrl.appToBind;
var application = ctrl.bindType === 'application' ? _.get(ctrl.appToBind, 'metadata.name') : undefined;

var context = {
namespace: _.get(svcToBind, 'metadata.namespace')
};

BindingService.bindService(context, _.get(svcToBind, 'metadata.name'), _.get(appToBind, 'metadata.name')).then(function(binding){
BindingService.bindService(context, _.get(svcToBind, 'metadata.name'), application).then(function(binding){
ctrl.binding = binding;
ctrl.error = null;

Expand Down
5 changes: 2 additions & 3 deletions app/views/directives/bind-service/bind-service-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
service-class-name="ctrl.serviceClassName"
form-name="ctrl.selectionForm"
applications="ctrl.applications"
app-to-bind="ctrl.appToBind"
should-bind-to-app="ctrl.shouldBindToApp"
group-by-kind="ctrl.groupByKind">
bind-type="ctrl.bindType"
app-to-bind="ctrl.appToBind">
</bind-service-form>
</div>
1 change: 1 addition & 0 deletions app/views/directives/bind-service/results.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<bind-results error="ctrl.error"
binding="ctrl.binding"
service-to-bind="ctrl.serviceToBind"
bind-type="{{ctrl.bindType}}"
application-to-bind="ctrl.appToBind.metadata.name"
generated-secret-name="ctrl.generatedSecretName"
show-pod-presets="'pod_presets' | enableTechPreviewFeature"
Expand Down
10 changes: 5 additions & 5 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ return c === d && (c = _.get(a, "metadata.name", ""), d = _.get(b, "metadata.nam
}, p = function() {
if (g && h && i && j && k) {
var a = g.concat(h).concat(i).concat(j).concat(k);
l.applications = _.sortByAll(a, [ "metadata.name", "kind" ]), l.shouldBindToApp = l.applications.length ? "true" :"false";
l.applications = _.sortByAll(a, [ "metadata.name", "kind" ]), l.bindType = l.applications.length ? "application" :"secret-only";
}
}, q = function() {
l.nextTitle = "Bind", e = a.$watch("ctrl.selectionForm.$valid", function(a) {
Expand Down Expand Up @@ -573,7 +573,7 @@ group:"servicecatalog.k8s.io",
resource:"serviceclasses"
}, {}).then(function(a) {
l.serviceClasses = a.by("metadata.name"), "Instance" === l.target.kind && (l.serviceClass = l.serviceClasses[l.target.spec.serviceClassName], l.serviceClassName = l.target.spec.serviceClassName), o();
}), "Instance" === l.target.kind ? (l.shouldBindToApp = "false", l.appToBind = null, l.serviceToBind = l.target.metadata.name, c.list("deploymentconfigs", d).then(function(a) {
}), "Instance" === l.target.kind ? (l.bindType = "secret-only", l.appToBind = null, l.serviceToBind = l.target.metadata.name, c.list("deploymentconfigs", d).then(function(a) {
g = _.toArray(a.by("metadata.name")), p();
}), c.list("replicationcontrollers", d).then(function(a) {
i = _.reject(a.by("metadata.name"), b("hasDeploymentConfig")), p();
Expand All @@ -592,7 +592,7 @@ group:"apps",
resource:"statefulsets"
}, d).then(function(a) {
k = _.toArray(a.by("metadata.name")), p();
})) :(c.list({
})) :(l.bindType = "application", l.appToBind = l.target, c.list({
group:"servicecatalog.k8s.io",
resource:"instances"
}, d).then(function(a) {
Expand All @@ -601,10 +601,10 @@ l.serviceInstances = a.by("metadata.name"), l.serviceToBind || n(), o();
}, l.$onDestroy = function() {
e && (e(), e = void 0), f && c.unwatch(f);
}, l.bindService = function() {
var a = "Instance" === l.target.kind ? l.target :l.serviceInstances[l.serviceToBind], b = "Instance" !== l.target.kind ? l.target :l.appToBind, e = {
var a = "Instance" === l.target.kind ? l.target :l.serviceInstances[l.serviceToBind], b = "application" === l.bindType ? _.get(l.appToBind, "metadata.name") :void 0, e = {
namespace:_.get(a, "metadata.namespace")
};
d.bindService(e, _.get(a, "metadata.name"), _.get(b, "metadata.name")).then(function(a) {
d.bindService(e, _.get(a, "metadata.name"), b).then(function(a) {
l.binding = a, l.error = null, f = c.watchObject(d.bindingResource, _.get(l.binding, "metadata.name"), e, function(a) {
l.binding = a;
});
Expand Down
4 changes: 2 additions & 2 deletions dist/scripts/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -5802,14 +5802,14 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
"</bind-application-form>\n" +
"</div>\n" +
"<div ng-if=\"ctrl.target.kind === 'Instance'\">\n" +
"<bind-service-form selected-project=\"ctrl.project\" service-class=\"ctrl.serviceClass\" service-class-name=\"ctrl.serviceClassName\" form-name=\"ctrl.selectionForm\" applications=\"ctrl.applications\" app-to-bind=\"ctrl.appToBind\" should-bind-to-app=\"ctrl.shouldBindToApp\" group-by-kind=\"ctrl.groupByKind\">\n" +
"<bind-service-form selected-project=\"ctrl.project\" service-class=\"ctrl.serviceClass\" service-class-name=\"ctrl.serviceClassName\" form-name=\"ctrl.selectionForm\" applications=\"ctrl.applications\" bind-type=\"ctrl.bindType\" app-to-bind=\"ctrl.appToBind\">\n" +
"</bind-service-form>\n" +
"</div>"
);


$templateCache.put('views/directives/bind-service/results.html',
"<bind-results error=\"ctrl.error\" binding=\"ctrl.binding\" service-to-bind=\"ctrl.serviceToBind\" application-to-bind=\"ctrl.appToBind.metadata.name\" generated-secret-name=\"ctrl.generatedSecretName\" show-pod-presets=\"'pod_presets' | enableTechPreviewFeature\" secret-href=\"ctrl.generatedSecretName | navigateResourceURL : 'Secret' : ctrl.target.metadata.namespace\">\n" +
"<bind-results error=\"ctrl.error\" binding=\"ctrl.binding\" service-to-bind=\"ctrl.serviceToBind\" bind-type=\"{{ctrl.bindType}}\" application-to-bind=\"ctrl.appToBind.metadata.name\" generated-secret-name=\"ctrl.generatedSecretName\" show-pod-presets=\"'pod_presets' | enableTechPreviewFeature\" secret-href=\"ctrl.generatedSecretName | navigateResourceURL : 'Secret' : ctrl.target.metadata.namespace\">\n" +
"</bind-results>"
);

Expand Down
Loading

0 comments on commit 1911577

Please sign in to comment.