Skip to content

Commit da199af

Browse files
Add verbs to objects returned by APIService.info
- also add APIService.kindToResourceGroupVersion - update APIService tests - update DataService tests that fail after fixture update
1 parent 2bedab2 commit da199af

File tree

7 files changed

+2258
-538
lines changed

7 files changed

+2258
-538
lines changed

dist/origin-web-common-services.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,13 @@ angular.module('openshiftCommonServices')
391391
return resource;
392392
}
393393

394+
function kindToResourceGroupVersion(kind) {
395+
return toResourceGroupVersion({
396+
resource: kindToResource(kind.kind),
397+
group: kind.group
398+
});
399+
}
400+
394401
// apiInfo returns the host/port, prefix, group, and version for the given resource,
395402
// or undefined if the specified resource/group/version is known not to exist.
396403
var apiInfo = function(resource) {
@@ -423,12 +430,14 @@ angular.module('openshiftCommonServices')
423430
}
424431
var hostPrefixObj = _.get(APIS_CFG, ["groups", resource.group, 'hostPrefix']) || APIS_CFG;
425432
return {
433+
resource: resource.resource,
434+
group: resource.group,
435+
version: resource.version,
426436
protocol: hostPrefixObj.protocol,
427437
hostPort: hostPrefixObj.hostPort,
428438
prefix: hostPrefixObj.prefix,
429-
group: resource.group,
430-
version: resource.version,
431-
namespaced: discoveredResource.namespaced
439+
namespaced: discoveredResource.namespaced,
440+
verbs: discoveredResource.verbs
432441
};
433442
}
434443

@@ -442,10 +451,12 @@ angular.module('openshiftCommonServices')
442451
continue;
443452
}
444453
return {
454+
resource: resource.resource,
455+
version: resource.version,
445456
hostPort: api.hostPort,
446457
prefix: api.prefix,
447-
version: resource.version,
448-
namespaced: discoveredResource.namespaced
458+
namespaced: discoveredResource.namespaced,
459+
verbs: discoveredResource.verbs
449460
};
450461
}
451462
return undefined;
@@ -545,6 +556,8 @@ angular.module('openshiftCommonServices')
545556

546557
kindToResource: kindToResource,
547558

559+
kindToResourceGroupVersion: kindToResourceGroupVersion,
560+
548561
apiInfo: apiInfo,
549562

550563
invalidObjectKindOrVersion: invalidObjectKindOrVersion,

dist/origin-web-common.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,6 +1937,13 @@ angular.module('openshiftCommonServices')
19371937
return resource;
19381938
}
19391939

1940+
function kindToResourceGroupVersion(kind) {
1941+
return toResourceGroupVersion({
1942+
resource: kindToResource(kind.kind),
1943+
group: kind.group
1944+
});
1945+
}
1946+
19401947
// apiInfo returns the host/port, prefix, group, and version for the given resource,
19411948
// or undefined if the specified resource/group/version is known not to exist.
19421949
var apiInfo = function(resource) {
@@ -1969,12 +1976,14 @@ angular.module('openshiftCommonServices')
19691976
}
19701977
var hostPrefixObj = _.get(APIS_CFG, ["groups", resource.group, 'hostPrefix']) || APIS_CFG;
19711978
return {
1979+
resource: resource.resource,
1980+
group: resource.group,
1981+
version: resource.version,
19721982
protocol: hostPrefixObj.protocol,
19731983
hostPort: hostPrefixObj.hostPort,
19741984
prefix: hostPrefixObj.prefix,
1975-
group: resource.group,
1976-
version: resource.version,
1977-
namespaced: discoveredResource.namespaced
1985+
namespaced: discoveredResource.namespaced,
1986+
verbs: discoveredResource.verbs
19781987
};
19791988
}
19801989

@@ -1988,10 +1997,12 @@ angular.module('openshiftCommonServices')
19881997
continue;
19891998
}
19901999
return {
2000+
resource: resource.resource,
2001+
version: resource.version,
19912002
hostPort: api.hostPort,
19922003
prefix: api.prefix,
1993-
version: resource.version,
1994-
namespaced: discoveredResource.namespaced
2004+
namespaced: discoveredResource.namespaced,
2005+
verbs: discoveredResource.verbs
19952006
};
19962007
}
19972008
return undefined;
@@ -2091,6 +2102,8 @@ angular.module('openshiftCommonServices')
20912102

20922103
kindToResource: kindToResource,
20932104

2105+
kindToResourceGroupVersion: kindToResourceGroupVersion,
2106+
20942107
apiInfo: apiInfo,
20952108

20962109
invalidObjectKindOrVersion: invalidObjectKindOrVersion,

dist/origin-web-common.min.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,12 @@ resource = humanizeKind(resource);
709709
}
710710
return resource = String(resource).toLowerCase(), "endpoints" === resource || "securitycontextconstraints" === resource || ("s" === resource[resource.length - 1] ? resource += "es" :"y" === resource[resource.length - 1] ? resource = resource.substring(0, resource.length - 1) + "ies" :resource += "s"), resource;
711711
}
712+
function kindToResourceGroupVersion(kind) {
713+
return toResourceGroupVersion({
714+
resource:kindToResource(kind.kind),
715+
group:kind.group
716+
});
717+
}
712718
var defaultVersion = {
713719
"":"v1",
714720
extensions:"v1beta1"
@@ -755,20 +761,24 @@ if (resource.group) {
755761
if (discoveredResource = _.get(APIS_CFG, [ "groups", resource.group, "versions", resource.version, "resources", primaryResource ]), !discoveredResource) return void 0;
756762
var hostPrefixObj = _.get(APIS_CFG, [ "groups", resource.group, "hostPrefix" ]) || APIS_CFG;
757763
return {
764+
resource:resource.resource,
765+
group:resource.group,
766+
version:resource.version,
758767
protocol:hostPrefixObj.protocol,
759768
hostPort:hostPrefixObj.hostPort,
760769
prefix:hostPrefixObj.prefix,
761-
group:resource.group,
762-
version:resource.version,
763-
namespaced:discoveredResource.namespaced
770+
namespaced:discoveredResource.namespaced,
771+
verbs:discoveredResource.verbs
764772
};
765773
}
766774
var api;
767775
for (var apiName in API_CFG) if (api = API_CFG[apiName], discoveredResource = _.get(api, [ "resources", resource.version, primaryResource ])) return {
776+
resource:resource.resource,
777+
version:resource.version,
768778
hostPort:api.hostPort,
769779
prefix:api.prefix,
770-
version:resource.version,
771-
namespaced:discoveredResource.namespaced
780+
namespaced:discoveredResource.namespaced,
781+
verbs:discoveredResource.verbs
772782
};
773783
return void 0;
774784
}, invalidObjectKindOrVersion = function(apiObject) {
@@ -822,6 +832,7 @@ parseGroupVersion:parseGroupVersion,
822832
objectToResourceGroupVersion:objectToResourceGroupVersion,
823833
deriveTargetResource:deriveTargetResource,
824834
kindToResource:kindToResource,
835+
kindToResourceGroupVersion:kindToResourceGroupVersion,
825836
apiInfo:apiInfo,
826837
invalidObjectKindOrVersion:invalidObjectKindOrVersion,
827838
unsupportedObjectKindOrVersion:unsupportedObjectKindOrVersion,

src/services/apiService.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ angular.module('openshiftCommonServices')
188188
return resource;
189189
}
190190

191+
function kindToResourceGroupVersion(kind) {
192+
return toResourceGroupVersion({
193+
resource: kindToResource(kind.kind),
194+
group: kind.group
195+
});
196+
}
197+
191198
// apiInfo returns the host/port, prefix, group, and version for the given resource,
192199
// or undefined if the specified resource/group/version is known not to exist.
193200
var apiInfo = function(resource) {
@@ -220,12 +227,14 @@ angular.module('openshiftCommonServices')
220227
}
221228
var hostPrefixObj = _.get(APIS_CFG, ["groups", resource.group, 'hostPrefix']) || APIS_CFG;
222229
return {
230+
resource: resource.resource,
231+
group: resource.group,
232+
version: resource.version,
223233
protocol: hostPrefixObj.protocol,
224234
hostPort: hostPrefixObj.hostPort,
225235
prefix: hostPrefixObj.prefix,
226-
group: resource.group,
227-
version: resource.version,
228-
namespaced: discoveredResource.namespaced
236+
namespaced: discoveredResource.namespaced,
237+
verbs: discoveredResource.verbs
229238
};
230239
}
231240

@@ -239,10 +248,12 @@ angular.module('openshiftCommonServices')
239248
continue;
240249
}
241250
return {
251+
resource: resource.resource,
252+
version: resource.version,
242253
hostPort: api.hostPort,
243254
prefix: api.prefix,
244-
version: resource.version,
245-
namespaced: discoveredResource.namespaced
255+
namespaced: discoveredResource.namespaced,
256+
verbs: discoveredResource.verbs
246257
};
247258
}
248259
return undefined;
@@ -342,6 +353,8 @@ angular.module('openshiftCommonServices')
342353

343354
kindToResource: kindToResource,
344355

356+
kindToResourceGroupVersion: kindToResourceGroupVersion,
357+
345358
apiInfo: apiInfo,
346359

347360
invalidObjectKindOrVersion: invalidObjectKindOrVersion,

0 commit comments

Comments
 (0)