Commit 176923e3 by benjaminapetersen

Remove kind:jobs, group: batch from internal filter in APIService.calculateAvailableKinds()

parent 9137df07
......@@ -518,9 +518,7 @@ angular.module('openshiftCommonServices')
// Exclude duplicate kinds we know about that map to the same storage as another group/kind
// This is unusual, so we are special casing these
if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler" ||
group.name === "batch" && resource.kind === "Job"
) {
if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler") {
return;
}
......
......@@ -2125,9 +2125,7 @@ angular.module('openshiftCommonServices')
// Exclude duplicate kinds we know about that map to the same storage as another group/kind
// This is unusual, so we are special casing these
if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler" ||
group.name === "batch" && resource.kind === "Job"
) {
if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler") {
return;
}
......
......@@ -844,7 +844,7 @@ _.each(group.versions[preferredVersion].resources, function(resource) {
_.contains(resource.name, "/") || _.find(rejectedKinds, {
kind:resource.kind,
group:group.name
}) || "extensions" === group.name && "HorizontalPodAutoscaler" === resource.kind || "batch" === group.name && "Job" === resource.kind || (resource.namespaced || includeClusterScoped) && kinds.push({
}) || ("extensions" !== group.name || "HorizontalPodAutoscaler" !== resource.kind) && (resource.namespaced || includeClusterScoped) && kinds.push({
kind:resource.kind,
group:group.name
});
......
......@@ -315,9 +315,7 @@ angular.module('openshiftCommonServices')
// Exclude duplicate kinds we know about that map to the same storage as another group/kind
// This is unusual, so we are special casing these
if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler" ||
group.name === "batch" && resource.kind === "Job"
) {
if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler") {
return;
}
......
......@@ -309,15 +309,15 @@ describe("APIService", function() {
describe('#availableKinds', function() {
var bothSample = ['Binding','ConfigMap','DeploymentConfig','Event','LimitRange','Pod','ReplicaSet','Role','Service', 'Template'];
var bothSample = ['Binding','ConfigMap','DeploymentConfig','Event','LimitRange','Pod','ReplicaSet','Role','Service', 'Template', 'Job'];
var onlyClusterSample = ['ClusterResourceQuota','Namespace','OAuthAccessToken','PersistentVolume','ProjectRequest','User'];
it('should return list of kinds that are scoped to a namespace by default', function() {
it('should return a list of kinds that are scoped to a namespace by default', function() {
var namespacedKinds = _.map(APIService.availableKinds(), 'kind');
expect( _.difference(bothSample, namespacedKinds).length ).toEqual(0);
});
it('should not return list cluster scoped kinds by default', function() {
it('should not return a list of cluster scoped kinds by default', function() {
var namespacedKinds = _.map(APIService.availableKinds(), 'kind');
expect( _.difference(onlyClusterSample, namespacedKinds).length ).toEqual(onlyClusterSample.length);
});
......@@ -328,6 +328,7 @@ describe("APIService", function() {
expect( _.difference(onlyClusterSample, allKinds).length ).toEqual(0);
});
// kinds from the old /oapi should not be iterated at all.
it('should not list kinds from the old /oapi namespace (that do not have a group)', function() {
var allKinds = APIService.availableKinds(true);
......@@ -393,6 +394,21 @@ describe("APIService", function() {
});
});
// this tests a hard-coded filter list within calculateAvailableKinds
it('should not return duplicate kinds that map to the same storage as another group/kind', function() {
var allKinds = APIService.availableKinds(true);
var kindsToExclude = [{kind: 'HorizontalPodAutoscaler', group: 'extensions'}];
// the same as above, but in the correct group, validating that we do still list these kinds
var matchingKindsToInclude = [{kind: 'HorizontalPodAutoscaler', group: 'autoscaling'}];
_.each(kindsToExclude, function(kind) {
expect(_.find(allKinds, kind)).toEqual(undefined);
});
_.each(matchingKindsToInclude, function(kind) {
expect(_.find(allKinds, kind)).toEqual(kind);
});
});
});
});
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