-
Notifications
You must be signed in to change notification settings - Fork 55
Add apiService.getPreferredVersion, and constant apiPreferredVersions #161
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
Add apiService.getPreferredVersion, and constant apiPreferredVersions #161
Conversation
If the approach is right, I may work on this PR first & get as many entries in here as possible, then merge & work on updates to using this feature in follow-on PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjaminapetersen Looks good, I like the approach.
I'm wondering if we shouldn't add in specific versions, but that is easy to change later if we do this way. I'd leave it as-is for now.
Thanks @benjaminapetersen
'use strict'; | ||
|
||
angular.module('openshiftCommonServices') | ||
.constant('apiPreferredVersions', (function(undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All caps since it's a constant?
I'd rather not start declaring functions as taking undefined
since we don't do that anywhere else. Let's stick to the styles we've established when it makes sense for consistency in our code. Even if we don't have a README declaring the code style, we've established a certain style over time.
.constant('API_PREFERRED_VERSIONS', function() {
// ...
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh def, sorry, copy paste oops (forgot if constants had any special treatment), def don't need that.
deployments: { group: 'apps', resource: 'deployments'}, | ||
pods: 'pods', | ||
replicasets: {group: 'extensions', resource: 'replicasets'}, | ||
// bindings: must be manually deduplicated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove this comment since it will no longer be an issue.
angular.module('openshiftCommonServices') | ||
.constant('apiPreferredVersions', (function(undefined) { | ||
return { | ||
builds: 'builds', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{resource: 'builds', group: 'build.openshift.io'}
.constant('apiPreferredVersions', (function(undefined) { | ||
return { | ||
builds: 'builds', | ||
buildconfigs: 'buildconfigs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{resource: 'buildconfigs', group: 'build.openshift.io'}
src/services/apiService.js
Outdated
var getPreferredVersion = function(resource) { | ||
return apiPreferredVersions[resource]; | ||
// TODO: if missing or needs dedupe, should we: | ||
// new Error(resource + ' must be manually deduplicated, please create your own {resource:"", group:"", version: "" object.}'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just log it and return null
.
src/services/apiService.js
Outdated
@@ -339,6 +340,12 @@ angular.module('openshiftCommonServices') | |||
return includeClusterScoped ? allKinds : namespacedKinds; | |||
}; | |||
|
|||
var getPreferredVersion = function(resource) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment explaining what this is and why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
buildconfigs: {group: 'build.openshift.io', resource: 'buildconfigs'}, | ||
configmaps: 'configmaps', | ||
deployments: {group: 'apps', resource: 'deployments'}, | ||
deploymentconfigs: 'deploymentconfigs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group: 'apps.openshift.io',
configmaps: 'configmaps', | ||
deployments: {group: 'apps', resource: 'deployments'}, | ||
deploymentconfigs: 'deploymentconfigs', | ||
imagestreams: 'imagestreams', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group: 'image.openshift.io'
deployments: {group: 'apps', resource: 'deployments'}, | ||
deploymentconfigs: 'deploymentconfigs', | ||
imagestreams: 'imagestreams', | ||
imagestreamtags: 'imagestreamtags', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group: 'image.openshift.io'
replicationcontrollers: 'replicationcontrollers', | ||
resourcequotas: 'resourcequotas', | ||
rolebindings: 'rolebindings', | ||
routes: 'routes', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group: 'route.openshift.io'
instances: {group: 'servicecatalog.k8s.io', resource: 'instances'}, | ||
limitranges: 'limitranges', | ||
pods: 'pods', | ||
projects: 'projects', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group: 'project.openshift.io'
services: 'services', | ||
serviceaccounts: 'serviceaccounts', | ||
serviceclasses: {group: 'servicecatalog.k8s.io', resource: 'serviceclasses'}, | ||
statefulsets: {group: 'apps', resource: 'statefulsets'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
storageclasses: {group: 'storage.k8s.io', resource: 'storageclasses'}
rolebindings: 'rolebindings', | ||
routes: 'routes', | ||
secrets: 'secrets', | ||
selfsubjectrulesreviews: 'selfsubjectrulesreviews', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group: 'authorization.openshift.io'
src/services/apiService.js
Outdated
console.log('available kinds:'); | ||
console.log('available kinds:'); | ||
console.log(calculateAvailableKinds(true)); | ||
console.log(JSON.stringify(calculateAvailableKinds(true))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove log messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOp, sorry, should have said "Do not review" on the last one, just pushed it to switch gears back to drawer. 🙁
This will get cleaned up in my next pass.
replicasets: {group: 'extensions', resource: 'replicasets'}, | ||
replicationcontrollers: 'replicationcontrollers', | ||
resourcequotas: 'resourcequotas', | ||
rolebindings: 'rolebindings', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group: 'authorization.openshift.io'
configmaps: 'configmaps', | ||
deployments: {group: 'apps', resource: 'deployments'}, | ||
deploymentconfigs: 'deploymentconfigs', | ||
imagestreams: 'imagestreams', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
horizontalpodautoscalers: {group: 'autoscaling', resource: 'horizontalpodautoscalers'}
Thinking again about |
5becb12
to
3b3d67b
Compare
Updated. |
@spadgett this should be good to go. I can always add more to the config if I find something missing with the follow-up PRs to update controllers, etc. Thoughts? |
Hey @benjaminapetersen see my comment openshift/origin-web-console#2098 (comment) I think we'll want to go ahead and create a filter for preferred version. Let's do it in this PR to avoid cutting multiple releases. |
@spadgett agree, will do. |
3b3d67b
to
ffa8187
Compare
@spadgett filter added. |
src/filters/getPreferredVersion.js
Outdated
|
||
angular | ||
.module('openshiftCommonUI') | ||
.filter('getPreferredVersion', function(APIService) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just
.filter('preferredVersion', function(APIService) {
return APIService.getPreferredVersion;
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works for me, updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated again 😃
6ffb82e
to
e0bd42c
Compare
e0bd42c
to
c45e325
Compare
Closing and reopening to kick travis tests |
Concept for Switch to use openshift APIs under API groups - phase 1
@spadgett