Skip to content

Commit 489271d

Browse files
authored
Merge pull request #77 from benjaminapetersen/api-info-verbs
Update APIService.apiInfo to return verbs when possible
2 parents 4686534 + da199af commit 489271d

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
@@ -1971,6 +1971,13 @@ angular.module('openshiftCommonServices')
19711971
return resource;
19721972
}
19731973

1974+
function kindToResourceGroupVersion(kind) {
1975+
return toResourceGroupVersion({
1976+
resource: kindToResource(kind.kind),
1977+
group: kind.group
1978+
});
1979+
}
1980+
19741981
// apiInfo returns the host/port, prefix, group, and version for the given resource,
19751982
// or undefined if the specified resource/group/version is known not to exist.
19761983
var apiInfo = function(resource) {
@@ -2003,12 +2010,14 @@ angular.module('openshiftCommonServices')
20032010
}
20042011
var hostPrefixObj = _.get(APIS_CFG, ["groups", resource.group, 'hostPrefix']) || APIS_CFG;
20052012
return {
2013+
resource: resource.resource,
2014+
group: resource.group,
2015+
version: resource.version,
20062016
protocol: hostPrefixObj.protocol,
20072017
hostPort: hostPrefixObj.hostPort,
20082018
prefix: hostPrefixObj.prefix,
2009-
group: resource.group,
2010-
version: resource.version,
2011-
namespaced: discoveredResource.namespaced
2019+
namespaced: discoveredResource.namespaced,
2020+
verbs: discoveredResource.verbs
20122021
};
20132022
}
20142023

@@ -2022,10 +2031,12 @@ angular.module('openshiftCommonServices')
20222031
continue;
20232032
}
20242033
return {
2034+
resource: resource.resource,
2035+
version: resource.version,
20252036
hostPort: api.hostPort,
20262037
prefix: api.prefix,
2027-
version: resource.version,
2028-
namespaced: discoveredResource.namespaced
2038+
namespaced: discoveredResource.namespaced,
2039+
verbs: discoveredResource.verbs
20292040
};
20302041
}
20312042
return undefined;
@@ -2125,6 +2136,8 @@ angular.module('openshiftCommonServices')
21252136

21262137
kindToResource: kindToResource,
21272138

2139+
kindToResourceGroupVersion: kindToResourceGroupVersion,
2140+
21282141
apiInfo: apiInfo,
21292142

21302143
invalidObjectKindOrVersion: invalidObjectKindOrVersion,

dist/origin-web-common.min.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,12 @@ resource = humanizeKind(resource);
723723
}
724724
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;
725725
}
726+
function kindToResourceGroupVersion(kind) {
727+
return toResourceGroupVersion({
728+
resource:kindToResource(kind.kind),
729+
group:kind.group
730+
});
731+
}
726732
var defaultVersion = {
727733
"":"v1",
728734
extensions:"v1beta1"
@@ -769,20 +775,24 @@ if (resource.group) {
769775
if (discoveredResource = _.get(APIS_CFG, [ "groups", resource.group, "versions", resource.version, "resources", primaryResource ]), !discoveredResource) return void 0;
770776
var hostPrefixObj = _.get(APIS_CFG, [ "groups", resource.group, "hostPrefix" ]) || APIS_CFG;
771777
return {
778+
resource:resource.resource,
779+
group:resource.group,
780+
version:resource.version,
772781
protocol:hostPrefixObj.protocol,
773782
hostPort:hostPrefixObj.hostPort,
774783
prefix:hostPrefixObj.prefix,
775-
group:resource.group,
776-
version:resource.version,
777-
namespaced:discoveredResource.namespaced
784+
namespaced:discoveredResource.namespaced,
785+
verbs:discoveredResource.verbs
778786
};
779787
}
780788
var api;
781789
for (var apiName in API_CFG) if (api = API_CFG[apiName], discoveredResource = _.get(api, [ "resources", resource.version, primaryResource ])) return {
790+
resource:resource.resource,
791+
version:resource.version,
782792
hostPort:api.hostPort,
783793
prefix:api.prefix,
784-
version:resource.version,
785-
namespaced:discoveredResource.namespaced
794+
namespaced:discoveredResource.namespaced,
795+
verbs:discoveredResource.verbs
786796
};
787797
return void 0;
788798
}, invalidObjectKindOrVersion = function(apiObject) {
@@ -836,6 +846,7 @@ parseGroupVersion:parseGroupVersion,
836846
objectToResourceGroupVersion:objectToResourceGroupVersion,
837847
deriveTargetResource:deriveTargetResource,
838848
kindToResource:kindToResource,
849+
kindToResourceGroupVersion:kindToResourceGroupVersion,
839850
apiInfo:apiInfo,
840851
invalidObjectKindOrVersion:invalidObjectKindOrVersion,
841852
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)