-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundle type endpoint #927
Bundle type endpoint #927
Conversation
and fixes test for self link distinguishing between same type id in different bundles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM @ahgittin, we were definitely missing those endpoints!
I just have a few comments/questions (see below) + one request: we can request the latest type by passing latest
as the type's version (it also works like that for the all old catalog endpoints) Could you also add that to the lookup
method for bundles?
String version, | ||
@ApiParam(name = "typeSymbolicName", value = "Type name to query", required = true) | ||
@PathParam("typeSymbolicName") | ||
String typeSymbolicName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to understand the difference between this endpoint and the one below (i.e. /{symbolicName}/{version}/types/{typeSymbolicName}/{typeVersion}
).
It seems to that that it will be the same as "/{symbolicName}/{version}/types/{typeSymbolicName}/latest
so probably not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it isn't latest
- it is for case where type version = bundle version. i think as that should be the normal case we should have an endpoint which doesn't require repeating version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum I get your PoV. I believe it's better to specify everything but why not, and it's using the same codepath so I'm fine with that
@Override | ||
public List<TypeSummary> getTypes(String symbolicName, String version) { | ||
ManagedBundle b = lookup(symbolicName, version); | ||
return TypeTransformer.bundleDetails(brooklyn(), b, ui.getBaseUriBuilder(), mgmt()).getTypes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need an entitlement check on the bundle here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lookup
does the bundle entitlement check doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I did check that but forgot about it, ignore me then.
private final static boolean DISALLOW_DIFFERENCES_IN_SAME_TYPE_ID_FROM_DIFFERENT_BUNDLES = true; | ||
|
||
@Test | ||
public void testAddSameTypeTwiceInDifferentBundleDifferentDefinition_Disallowed() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this case is not allowed. Could you elaborate on this please @ahgittin ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be allowed in future, it certainly can be behind the scenes, but it can cause oddness as it is then ambiguous what type:version
would mean if there are two different implementations. so there is strong argument to discourage/prevent it.
however in a multi-tenant world different users might not be allowed to see other bundles, so user 1 and user 2 might add the same type:version
where they aren't allowed to see the other (and in fact shouldn't be allowed to know that someone else has defined that type:version
), so in that case we would allow this. (we'd weaken restrictions to allow it, maybe e.g. user 2 can add type:version
so long as he can't see any differing type:version
.) but it might mean that a user 3 who is allowed to see bundles from both user 1 and user 2 is then able to see differing definition, which is not ideal and potentially confusing but i think least bad option. cc @aledsage ?
(NB longer term discussion, not part of this PR which just clarifies and tests current behaviour in this regard)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah got it, makes sense
+1 to supporting |
Yep, the Merging |
Actually @ahgittin, it seems the new endpoint is not available: I get a 404 and it does not appear on the swagger page. Not sure what's going on here |
v strange. are you sure it was built correctly @tbouron ? it maybe had a |
I did but looks like I messed up my env somehow. Everything is fine now, sorry for the noise @ahgittin |
It was noted that if the same type is defined in two different bundles, the API does not let you distinguish between the two. This adds
/catalog/bundles/{symbolicName}/{version}/types/{typeSymbolicName}/{typeVersion}
to resolve that. (It also adds the two immediate ancestor paths, with../types
listing types in the bundle and../types/{typeSymbolicName}
givingTypeDetail
assumingtypeVersion==version
).It also adds a bunch of tests for behaviour when adding the same type ID:
the final test above fails after the first commit but is fixed by the second commit here, by changing the type's
self
link to use the unambiguousbundles/.../types/...
endpoint.