Commit 5e5ba739 by Sam Padgett Committed by GitHub

Merge pull request #161 from benjaminapetersen/bpeterse/trello/switch-oapi-to-api-groups

Add apiService.getPreferredVersion, and constant apiPreferredVersions
parents 2a98c3d5 c45e3254
...@@ -234,6 +234,7 @@ ResourceGroupVersion.prototype.equals = function(resource, group, version) { ...@@ -234,6 +234,7 @@ ResourceGroupVersion.prototype.equals = function(resource, group, version) {
angular.module('openshiftCommonServices') angular.module('openshiftCommonServices')
.factory('APIService', function(API_CFG, .factory('APIService', function(API_CFG,
APIS_CFG, APIS_CFG,
API_PREFERRED_VERSIONS,
AuthService, AuthService,
Constants, Constants,
Logger, Logger,
...@@ -532,6 +533,17 @@ angular.module('openshiftCommonServices') ...@@ -532,6 +533,17 @@ angular.module('openshiftCommonServices')
return includeClusterScoped ? allKinds : namespacedKinds; return includeClusterScoped ? allKinds : namespacedKinds;
}; };
// Provides us a way to ensure we consistently use the
// correct {resource, group} for API calls. Version
// will typically fallback to the preferredVersion of the API
var getPreferredVersion = function(resource) {
var preferred = API_PREFERRED_VERSIONS[resource];
if(!preferred) {
Logger.log("No preferred version for ", resource);
}
return preferred;
};
return { return {
toResourceGroupVersion: toResourceGroupVersion, toResourceGroupVersion: toResourceGroupVersion,
...@@ -549,7 +561,8 @@ angular.module('openshiftCommonServices') ...@@ -549,7 +561,8 @@ angular.module('openshiftCommonServices')
invalidObjectKindOrVersion: invalidObjectKindOrVersion, invalidObjectKindOrVersion: invalidObjectKindOrVersion,
unsupportedObjectKindOrVersion: unsupportedObjectKindOrVersion, unsupportedObjectKindOrVersion: unsupportedObjectKindOrVersion,
availableKinds: availableKinds availableKinds: availableKinds,
getPreferredVersion: getPreferredVersion
}; };
}); });
;'use strict'; ;'use strict';
......
...@@ -1568,6 +1568,12 @@ angular.module('openshiftCommonUI') ...@@ -1568,6 +1568,12 @@ angular.module('openshiftCommonUI')
;'use strict'; ;'use strict';
angular.module('openshiftCommonUI') angular.module('openshiftCommonUI')
.filter('preferredVersion', function(APIService) {
return APIService.getPreferredVersion;
});
;'use strict';
angular.module('openshiftCommonUI')
.filter('prettifyJSON', function(parseJSONFilter) { .filter('prettifyJSON', function(parseJSONFilter) {
return function(json) { return function(json) {
var jsonObj = parseJSONFilter(json); var jsonObj = parseJSONFilter(json);
......
...@@ -1421,6 +1421,39 @@ angular.module('openshiftCommonUI') ...@@ -1421,6 +1421,39 @@ angular.module('openshiftCommonUI')
}]); }]);
;'use strict'; ;'use strict';
angular.module('openshiftCommonServices')
.constant('API_PREFERRED_VERSIONS', {
autoscaling: {group: 'autoscaling', resource: 'horizontalpodautoscalers' },
appliedclusterresourcequotas: {group: 'quota.openshift.io', resource: 'appliedclusterresourcequotas' },
bindings: {group: 'servicecatalog.k8s.io', resource: 'bindings' },
builds: {group: 'build.openshift.io', resource: 'builds' },
buildconfigs: {group: 'build.openshift.io', resource: 'buildconfigs' },
configmaps: 'configmaps',
deployments: {group: 'apps', resource: 'deployments' },
deploymentconfigs: {group: 'apps.openshift.io', resource: 'deploymentconfigs' },
imagestreams: {group: 'image.openshift.io', resource: 'imagestreams' },
imagestreamtags: {group: 'image.openshift.io', resource: 'imagestreamtags' },
instances: {group: 'servicecatalog.k8s.io', resource: 'instances' },
limitranges: 'limitranges',
pods: 'pods',
projects: {group: 'project.openshift.io', resource: 'projects'},
projectrequests: {group: 'project.openshift.io', resource: 'projectrequests'},
persistentvolumeclaims: 'persistentvolumeclaims',
replicasets: {group: 'extensions', resource: 'replicasets' },
replicationcontrollers: 'replicationcontrollers',
resourcequotas: 'resourcequotas',
rolebindings: 'rolebindings',
routes: {group: 'route.openshift.io', resource: 'routes' },
secrets: 'secrets',
selfsubjectrulesreviews: {group: 'authorization.k8s.io', resource: 'selfsubjectrulesreviews'},
services: 'services',
serviceaccounts: 'serviceaccounts',
serviceclasses: {group: 'servicecatalog.k8s.io', resource: 'serviceclasses' },
statefulsets: {group: 'apps', resource: 'statefulsets' },
templates: {group: 'template.openshift.io', resource: 'templates'}
});
;'use strict';
angular.module('openshiftCommonUI') angular.module('openshiftCommonUI')
.filter("alertStatus", function() { .filter("alertStatus", function() {
return function (type) { return function (type) {
...@@ -1739,6 +1772,12 @@ angular.module('openshiftCommonUI') ...@@ -1739,6 +1772,12 @@ angular.module('openshiftCommonUI')
;'use strict'; ;'use strict';
angular.module('openshiftCommonUI') angular.module('openshiftCommonUI')
.filter('preferredVersion', ["APIService", function(APIService) {
return APIService.getPreferredVersion;
}]);
;'use strict';
angular.module('openshiftCommonUI')
.filter('prettifyJSON', ["parseJSONFilter", function(parseJSONFilter) { .filter('prettifyJSON', ["parseJSONFilter", function(parseJSONFilter) {
return function(json) { return function(json) {
var jsonObj = parseJSONFilter(json); var jsonObj = parseJSONFilter(json);
...@@ -2117,8 +2156,9 @@ ResourceGroupVersion.prototype.equals = function(resource, group, version) { ...@@ -2117,8 +2156,9 @@ ResourceGroupVersion.prototype.equals = function(resource, group, version) {
}; };
angular.module('openshiftCommonServices') angular.module('openshiftCommonServices')
.factory('APIService', ["API_CFG", "APIS_CFG", "AuthService", "Constants", "Logger", "$q", "$http", "$filter", "$window", function(API_CFG, .factory('APIService', ["API_CFG", "APIS_CFG", "API_PREFERRED_VERSIONS", "AuthService", "Constants", "Logger", "$q", "$http", "$filter", "$window", function(API_CFG,
APIS_CFG, APIS_CFG,
API_PREFERRED_VERSIONS,
AuthService, AuthService,
Constants, Constants,
Logger, Logger,
...@@ -2417,6 +2457,17 @@ angular.module('openshiftCommonServices') ...@@ -2417,6 +2457,17 @@ angular.module('openshiftCommonServices')
return includeClusterScoped ? allKinds : namespacedKinds; return includeClusterScoped ? allKinds : namespacedKinds;
}; };
// Provides us a way to ensure we consistently use the
// correct {resource, group} for API calls. Version
// will typically fallback to the preferredVersion of the API
var getPreferredVersion = function(resource) {
var preferred = API_PREFERRED_VERSIONS[resource];
if(!preferred) {
Logger.log("No preferred version for ", resource);
}
return preferred;
};
return { return {
toResourceGroupVersion: toResourceGroupVersion, toResourceGroupVersion: toResourceGroupVersion,
...@@ -2434,7 +2485,8 @@ angular.module('openshiftCommonServices') ...@@ -2434,7 +2485,8 @@ angular.module('openshiftCommonServices')
invalidObjectKindOrVersion: invalidObjectKindOrVersion, invalidObjectKindOrVersion: invalidObjectKindOrVersion,
unsupportedObjectKindOrVersion: unsupportedObjectKindOrVersion, unsupportedObjectKindOrVersion: unsupportedObjectKindOrVersion,
availableKinds: availableKinds availableKinds: availableKinds,
getPreferredVersion: getPreferredVersion
}; };
}]); }]);
;'use strict'; ;'use strict';
......
...@@ -485,7 +485,90 @@ content ? (scope.truncatedContent = truncateFilter(content, scope.limit, scope.u ...@@ -485,7 +485,90 @@ content ? (scope.truncatedContent = truncateFilter(content, scope.limit, scope.u
}); });
} }
}; };
} ]), angular.module("openshiftCommonUI").filter("alertStatus", function() { } ]), angular.module("openshiftCommonServices").constant("API_PREFERRED_VERSIONS", {
autoscaling:{
group:"autoscaling",
resource:"horizontalpodautoscalers"
},
appliedclusterresourcequotas:{
group:"quota.openshift.io",
resource:"appliedclusterresourcequotas"
},
bindings:{
group:"servicecatalog.k8s.io",
resource:"bindings"
},
builds:{
group:"build.openshift.io",
resource:"builds"
},
buildconfigs:{
group:"build.openshift.io",
resource:"buildconfigs"
},
configmaps:"configmaps",
deployments:{
group:"apps",
resource:"deployments"
},
deploymentconfigs:{
group:"apps.openshift.io",
resource:"deploymentconfigs"
},
imagestreams:{
group:"image.openshift.io",
resource:"imagestreams"
},
imagestreamtags:{
group:"image.openshift.io",
resource:"imagestreamtags"
},
instances:{
group:"servicecatalog.k8s.io",
resource:"instances"
},
limitranges:"limitranges",
pods:"pods",
projects:{
group:"project.openshift.io",
resource:"projects"
},
projectrequests:{
group:"project.openshift.io",
resource:"projectrequests"
},
persistentvolumeclaims:"persistentvolumeclaims",
replicasets:{
group:"extensions",
resource:"replicasets"
},
replicationcontrollers:"replicationcontrollers",
resourcequotas:"resourcequotas",
rolebindings:"rolebindings",
routes:{
group:"route.openshift.io",
resource:"routes"
},
secrets:"secrets",
selfsubjectrulesreviews:{
group:"authorization.k8s.io",
resource:"selfsubjectrulesreviews"
},
services:"services",
serviceaccounts:"serviceaccounts",
serviceclasses:{
group:"servicecatalog.k8s.io",
resource:"serviceclasses"
},
statefulsets:{
group:"apps",
resource:"statefulsets"
},
templates:{
group:"template.openshift.io",
resource:"templates"
}
}), angular.module("openshiftCommonUI").filter("alertStatus", function() {
return function(type) { return function(type) {
var status; var status;
switch (type.toLowerCase()) { switch (type.toLowerCase()) {
...@@ -646,7 +729,9 @@ return "object" == typeof jsonObj ? jsonObj :null; ...@@ -646,7 +729,9 @@ return "object" == typeof jsonObj ? jsonObj :null;
return null; return null;
} }
}; };
}), angular.module("openshiftCommonUI").filter("prettifyJSON", [ "parseJSONFilter", function(parseJSONFilter) { }), angular.module("openshiftCommonUI").filter("preferredVersion", [ "APIService", function(APIService) {
return APIService.getPreferredVersion;
} ]), angular.module("openshiftCommonUI").filter("prettifyJSON", [ "parseJSONFilter", function(parseJSONFilter) {
return function(json) { return function(json) {
var jsonObj = parseJSONFilter(json); var jsonObj = parseJSONFilter(json);
return jsonObj ? JSON.stringify(jsonObj, null, 4) :json; return jsonObj ? JSON.stringify(jsonObj, null, 4) :json;
...@@ -816,7 +901,7 @@ var segments = (this.resource || "").split("/"); ...@@ -816,7 +901,7 @@ var segments = (this.resource || "").split("/");
return segments.shift(), segments; return segments.shift(), segments;
}, ResourceGroupVersion.prototype.equals = function(resource, group, version) { }, ResourceGroupVersion.prototype.equals = function(resource, group, version) {
return this.resource !== resource ? !1 :1 === arguments.length ? !0 :this.group !== group ? !1 :2 === arguments.length ? !0 :this.version !== version ? !1 :!0; return this.resource !== resource ? !1 :1 === arguments.length ? !0 :this.group !== group ? !1 :2 === arguments.length ? !0 :this.version !== version ? !1 :!0;
}, angular.module("openshiftCommonServices").factory("APIService", [ "API_CFG", "APIS_CFG", "AuthService", "Constants", "Logger", "$q", "$http", "$filter", "$window", function(API_CFG, APIS_CFG, AuthService, Constants, Logger, $q, $http, $filter, $window) { }, angular.module("openshiftCommonServices").factory("APIService", [ "API_CFG", "APIS_CFG", "API_PREFERRED_VERSIONS", "AuthService", "Constants", "Logger", "$q", "$http", "$filter", "$window", function(API_CFG, APIS_CFG, API_PREFERRED_VERSIONS, AuthService, Constants, Logger, $q, $http, $filter, $window) {
function normalizeResource(resource) { function normalizeResource(resource) {
if (!resource) return resource; if (!resource) return resource;
var i = resource.indexOf("/"); var i = resource.indexOf("/");
...@@ -947,6 +1032,9 @@ return value.group + "/" + value.kind; ...@@ -947,6 +1032,9 @@ return value.group + "/" + value.kind;
}); });
}, namespacedKinds = calculateAvailableKinds(!1), allKinds = calculateAvailableKinds(!0), availableKinds = function(includeClusterScoped) { }, namespacedKinds = calculateAvailableKinds(!1), allKinds = calculateAvailableKinds(!0), availableKinds = function(includeClusterScoped) {
return includeClusterScoped ? allKinds :namespacedKinds; return includeClusterScoped ? allKinds :namespacedKinds;
}, getPreferredVersion = function(resource) {
var preferred = API_PREFERRED_VERSIONS[resource];
return preferred || Logger.log("No preferred version for ", resource), preferred;
}; };
return { return {
toResourceGroupVersion:toResourceGroupVersion, toResourceGroupVersion:toResourceGroupVersion,
...@@ -958,7 +1046,8 @@ kindToResourceGroupVersion:kindToResourceGroupVersion, ...@@ -958,7 +1046,8 @@ kindToResourceGroupVersion:kindToResourceGroupVersion,
apiInfo:apiInfo, apiInfo:apiInfo,
invalidObjectKindOrVersion:invalidObjectKindOrVersion, invalidObjectKindOrVersion:invalidObjectKindOrVersion,
unsupportedObjectKindOrVersion:unsupportedObjectKindOrVersion, unsupportedObjectKindOrVersion:unsupportedObjectKindOrVersion,
availableKinds:availableKinds availableKinds:availableKinds,
getPreferredVersion:getPreferredVersion
}; };
} ]), angular.module("openshiftCommonServices").service("ApplicationsService", [ "$q", "DataService", function($q, DataService) { } ]), angular.module("openshiftCommonServices").service("ApplicationsService", [ "$q", "DataService", function($q, DataService) {
var listStandaloneReplicationControllers = function(context) { var listStandaloneReplicationControllers = function(context) {
......
'use strict';
angular.module('openshiftCommonServices')
.constant('API_PREFERRED_VERSIONS', {
autoscaling: {group: 'autoscaling', resource: 'horizontalpodautoscalers' },
appliedclusterresourcequotas: {group: 'quota.openshift.io', resource: 'appliedclusterresourcequotas' },
bindings: {group: 'servicecatalog.k8s.io', resource: 'bindings' },
builds: {group: 'build.openshift.io', resource: 'builds' },
buildconfigs: {group: 'build.openshift.io', resource: 'buildconfigs' },
configmaps: 'configmaps',
deployments: {group: 'apps', resource: 'deployments' },
deploymentconfigs: {group: 'apps.openshift.io', resource: 'deploymentconfigs' },
imagestreams: {group: 'image.openshift.io', resource: 'imagestreams' },
imagestreamtags: {group: 'image.openshift.io', resource: 'imagestreamtags' },
instances: {group: 'servicecatalog.k8s.io', resource: 'instances' },
limitranges: 'limitranges',
pods: 'pods',
projects: {group: 'project.openshift.io', resource: 'projects'},
projectrequests: {group: 'project.openshift.io', resource: 'projectrequests'},
persistentvolumeclaims: 'persistentvolumeclaims',
replicasets: {group: 'extensions', resource: 'replicasets' },
replicationcontrollers: 'replicationcontrollers',
resourcequotas: 'resourcequotas',
rolebindings: 'rolebindings',
routes: {group: 'route.openshift.io', resource: 'routes' },
secrets: 'secrets',
selfsubjectrulesreviews: {group: 'authorization.k8s.io', resource: 'selfsubjectrulesreviews'},
services: 'services',
serviceaccounts: 'serviceaccounts',
serviceclasses: {group: 'servicecatalog.k8s.io', resource: 'serviceclasses' },
statefulsets: {group: 'apps', resource: 'statefulsets' },
templates: {group: 'template.openshift.io', resource: 'templates'}
});
'use strict';
angular.module('openshiftCommonUI')
.filter('preferredVersion', function(APIService) {
return APIService.getPreferredVersion;
});
...@@ -41,6 +41,7 @@ ResourceGroupVersion.prototype.equals = function(resource, group, version) { ...@@ -41,6 +41,7 @@ ResourceGroupVersion.prototype.equals = function(resource, group, version) {
angular.module('openshiftCommonServices') angular.module('openshiftCommonServices')
.factory('APIService', function(API_CFG, .factory('APIService', function(API_CFG,
APIS_CFG, APIS_CFG,
API_PREFERRED_VERSIONS,
AuthService, AuthService,
Constants, Constants,
Logger, Logger,
...@@ -339,6 +340,17 @@ angular.module('openshiftCommonServices') ...@@ -339,6 +340,17 @@ angular.module('openshiftCommonServices')
return includeClusterScoped ? allKinds : namespacedKinds; return includeClusterScoped ? allKinds : namespacedKinds;
}; };
// Provides us a way to ensure we consistently use the
// correct {resource, group} for API calls. Version
// will typically fallback to the preferredVersion of the API
var getPreferredVersion = function(resource) {
var preferred = API_PREFERRED_VERSIONS[resource];
if(!preferred) {
Logger.log("No preferred version for ", resource);
}
return preferred;
};
return { return {
toResourceGroupVersion: toResourceGroupVersion, toResourceGroupVersion: toResourceGroupVersion,
...@@ -356,6 +368,7 @@ angular.module('openshiftCommonServices') ...@@ -356,6 +368,7 @@ angular.module('openshiftCommonServices')
invalidObjectKindOrVersion: invalidObjectKindOrVersion, invalidObjectKindOrVersion: invalidObjectKindOrVersion,
unsupportedObjectKindOrVersion: unsupportedObjectKindOrVersion, unsupportedObjectKindOrVersion: unsupportedObjectKindOrVersion,
availableKinds: availableKinds availableKinds: availableKinds,
getPreferredVersion: getPreferredVersion
}; };
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment