Skip to content

List actor definitions for workspace #11336

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

Merged
merged 8 commits into from
Mar 23, 2022
Merged

Conversation

git-phu
Copy link
Contributor

@git-phu git-phu commented Mar 23, 2022

What

Part of #9652
Tech Spec

Implements routes to list all actor definitions a given workspace is configured to use. Depends on #11305

Recommended reading order

Easiest to view by commit

User Impact

Doesn't change the behavior of existing routes

@github-actions github-actions bot added area/platform issues related to the platform area/server labels Mar 23, 2022
@git-phu git-phu temporarily deployed to more-secrets March 23, 2022 00:06 Inactive
@git-phu git-phu temporarily deployed to more-secrets March 23, 2022 01:35 Inactive
@git-phu git-phu temporarily deployed to more-secrets March 23, 2022 01:37 Inactive
@git-phu git-phu force-pushed the peter/list-custom-definitions-crud branch from c383df9 to bbbed2c Compare March 23, 2022 21:13
@git-phu git-phu marked this pull request as ready for review March 23, 2022 21:20
@git-phu git-phu requested a review from pmossman March 23, 2022 21:20
Copy link
Contributor

@pmossman pmossman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Left a non-blocking suggestion about handling MockData

public void testSourceDefinitionGrants() throws IOException {
final UUID workspaceId = MockData.standardWorkspaces().get(0).getWorkspaceId();
final StandardSourceDefinition grantableDefinition1 = MockData.standardSourceDefinitions().get(1);
final StandardSourceDefinition customDefinition = MockData.standardSourceDefinitions().get(3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I'm trying to think if there's a more elegant/dependable way to set up the public/custom mock data more clearly. Instead of relying on the right definition being at index 3 here, I wonder if we could basically define them as public static fields of MockData.java so we could access them in tests by doing something like

final StandardSourceDefinition customDefinition = MockData.CUSTOM_SOURCE_DEFINITION;

instead of

final StandardSourceDefinition customDefinition = MockData.standardSourceDefinitions().get(3);

Would need a little bit of rearrangement within MockData.java but might be worth it? Like instead of defining each of the four SourceDefinitions inside the standardSourceDefinitions() method, you'd define them as public static fields and then update that method to just return something like:

return Arrays.asList(SOURCE_DEFINITION_PUBLIC_CATALOG, SOURCE_DEFINITION_PRIVATE_CATALOG, SOURCE_DEFINITION_PRIVATE_CUSTOM);

Or something like that.. there might be a better way that isn't occurring to me right now.

This might be more trouble than it's worth. At the very least, it might make sense to just add something to MockData.java like:

public SourceDefinition getPrivateCustomSourceDefinition() {
    return standardSourceDefinitions().get(3);
}

so that at least we don't need to externally rely on the third index as a magic number

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, great idea!
I think I like the idea of making each mock object a public static field but maybe we didn't want the class instantiation to be creating so many objects?
I'll go with creating a descriptively named getter method for each mock.

throws IOException {
return toDestinationDefinitionReadList(MoreLists.concat(
configRepository.listPublicDestinationDefinitions(false),
configRepository.listGrantedDestinationDefinitions(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to think through what would happen if a definition was somehow in both of these lists, like in a situation where a public: false definition later became public: true. But then I realized you're already filtering out public: true definitions in the granted query, so I think we're covered there!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right exactly! I asked about whether we should clean up old grants when I first thought of this too, but for now I think filtering out public in the granted query should be fine.

@git-phu git-phu temporarily deployed to more-secrets March 23, 2022 22:37 Inactive
@git-phu git-phu temporarily deployed to more-secrets March 23, 2022 22:37 Inactive
@git-phu git-phu merged commit 8fbbf4b into master Mar 23, 2022
@git-phu git-phu deleted the peter/list-custom-definitions-crud branch March 23, 2022 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants