Commit 882df2f5 by Jessica Forrester Committed by GitHub

Merge pull request #91 from benjaminapetersen/bpeterse/bug/1457609/list-jobs

Remove kind:jobs, group: batch from internal filter
parents 9137df07 176923e3
...@@ -518,9 +518,7 @@ angular.module('openshiftCommonServices') ...@@ -518,9 +518,7 @@ angular.module('openshiftCommonServices')
// Exclude duplicate kinds we know about that map to the same storage as another group/kind // 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 // This is unusual, so we are special casing these
if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler" || if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler") {
group.name === "batch" && resource.kind === "Job"
) {
return; return;
} }
......
...@@ -2125,9 +2125,7 @@ angular.module('openshiftCommonServices') ...@@ -2125,9 +2125,7 @@ angular.module('openshiftCommonServices')
// Exclude duplicate kinds we know about that map to the same storage as another group/kind // 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 // This is unusual, so we are special casing these
if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler" || if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler") {
group.name === "batch" && resource.kind === "Job"
) {
return; return;
} }
......
...@@ -844,7 +844,7 @@ _.each(group.versions[preferredVersion].resources, function(resource) { ...@@ -844,7 +844,7 @@ _.each(group.versions[preferredVersion].resources, function(resource) {
_.contains(resource.name, "/") || _.find(rejectedKinds, { _.contains(resource.name, "/") || _.find(rejectedKinds, {
kind:resource.kind, kind:resource.kind,
group:group.name 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, kind:resource.kind,
group:group.name group:group.name
}); });
......
...@@ -315,9 +315,7 @@ angular.module('openshiftCommonServices') ...@@ -315,9 +315,7 @@ angular.module('openshiftCommonServices')
// Exclude duplicate kinds we know about that map to the same storage as another group/kind // 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 // This is unusual, so we are special casing these
if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler" || if (group.name === "extensions" && resource.kind === "HorizontalPodAutoscaler") {
group.name === "batch" && resource.kind === "Job"
) {
return; return;
} }
......
...@@ -309,15 +309,15 @@ describe("APIService", function() { ...@@ -309,15 +309,15 @@ describe("APIService", function() {
describe('#availableKinds', 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']; 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'); var namespacedKinds = _.map(APIService.availableKinds(), 'kind');
expect( _.difference(bothSample, namespacedKinds).length ).toEqual(0); 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'); var namespacedKinds = _.map(APIService.availableKinds(), 'kind');
expect( _.difference(onlyClusterSample, namespacedKinds).length ).toEqual(onlyClusterSample.length); expect( _.difference(onlyClusterSample, namespacedKinds).length ).toEqual(onlyClusterSample.length);
}); });
...@@ -328,6 +328,7 @@ describe("APIService", function() { ...@@ -328,6 +328,7 @@ describe("APIService", function() {
expect( _.difference(onlyClusterSample, allKinds).length ).toEqual(0); expect( _.difference(onlyClusterSample, allKinds).length ).toEqual(0);
}); });
// kinds from the old /oapi should not be iterated at all. // 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() { it('should not list kinds from the old /oapi namespace (that do not have a group)', function() {
var allKinds = APIService.availableKinds(true); var allKinds = APIService.availableKinds(true);
...@@ -393,6 +394,21 @@ describe("APIService", function() { ...@@ -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