Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check services for bindability before creating bindings #1599

Merged
merged 1 commit into from
Jun 8, 2017

Conversation

jeff-phillips-18
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 commented May 26, 2017

No description provided.

@@ -25,7 +25,7 @@
</li>
<!-- FIXME: Can't enable canI checks on svc cat resources until we have aggregation
<li ng-if="(row.state.serviceInstances | hashSize) > 0 && {resource: 'bindings', group: 'servicecatalog.k8s.io'} | canI : 'create'" role="menuitem"> -->
<li ng-if="('pod_presets' | enableTechPreviewFeature) && (row.state.serviceInstances | hashSize) > 0" role="menuitem">
<li ng-if="('pod_presets' | enableTechPreviewFeature) && (row.state.bindableServiceInstances | hashSize) > 0" role="menuitem">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bindableServiceInstances should be an array now, since you used _.filter, so you can just check row.state.bindableServiceInstances.length

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2017
@@ -71,6 +71,7 @@ function BindService($scope,
.concat(replicaSets)
.concat(statefulSets);
ctrl.applications = _.sortByAll(apiObjects, ['metadata.name', 'kind']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious about reason for making these bools into strings "true" : "false"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three options:

  • 'true' = bind to a selected application
  • 'false' = bind, but not to an application
  • 'none' = do not bind

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if that is something that can be clarified. "false" meaning "yes, but no" and none meaning "false" (ie, what you thought false would have meant) seems confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like

bindingType = 'application' | 'secret-only' | 'none'

to avoid confusion around types?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, something that clearly indicates intent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 31, 2017
@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 5, 2017
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 6, 2017
@jeff-phillips-18
Copy link
Member Author

Removed WIP status, ready for final reviews.

@jeff-phillips-18 jeff-phillips-18 changed the title [WIP] Check services for bindability before creating bindings Check services for bindability before creating bindings Jun 7, 2017
return;
}
state.orderedServiceInstances = _.toArray(state.serviceInstances).sort(function(left, right) {

Copy link
Contributor

@benjaminapetersen benjaminapetersen Jun 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, rather than creating a duplicate array serviceInstancesArray, _.filter works fine on a hash as does _.sortBy instead of [].sort. Possible to use the _ version?

I've seen this done a few times now but haven't looked closely before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use _.sortByAll. Thanks!

@@ -168,6 +169,8 @@
});
}
else {
ctrl.bindType = 'application';
ctrl.appToBind = ctrl.target;
Copy link
Contributor

@benjaminapetersen benjaminapetersen Jun 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 173 and 184 seem to be the same & I believe one can be removed.

I'd actually prefer to see some of this logic broken out into separate functions. Its a gnarly big if/else & there might be some long term maintenance benefits to breaking it down into smaller pieces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks!


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){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So DataService patterns don't lead with context, they tend towards something like (resource, name, context, opts). We missed this & should prob open an issue in common to keep these consistent. I'm curious if application even ends up as part of context in the end, but I'd have to look.

@spadgett
Copy link
Member

spadgett commented Jun 8, 2017

We should prioritize getting this in because binding is currently broken in the web console. We updated common without making the corresponding the corresponding console change for openshift/origin-web-common#90

@jeff-phillips-18
Copy link
Member Author

@spadgett ah yes, sorry about that.

@jwforres
Copy link
Member

jwforres commented Jun 8, 2017

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to c79065a

@openshift-bot
Copy link

openshift-bot commented Jun 8, 2017

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_web_console/1488/) (Base Commit: 23aa410)

@openshift-bot openshift-bot merged commit 9fd7f5b into openshift:master Jun 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants