Skip to content
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

Support typeless kubernetes resources when generating manifests #931

Merged

Conversation

chendouble
Copy link
Contributor

Typeless kubernetes resource has no Group and Plural value, so generating wrong policy rule.

Commit summary:

  1. Use ApiGroup value from GVK and '*' for Plural value if dependent resource is assignable from GenericKubernetesDependentResource 2) Merge verbs in rule for optimization if with same ApiGroups and Resources

xpie added 2 commits August 22, 2024 21:59
Typeless kubernetes resource has no Group and Plural value, so generating wrong policy rule.

Commit summary:
1) Use ApiGroup value from GVK and '*' for Plural value if dependent resource is assignable from GenericKubernetesDependentResource
2) Merge verbs in rule for optimization if with same ApiGroups and Resources
@metacosm metacosm self-requested a review August 23, 2024 10:25

return clusterRoleBuilder.build();
}

@NotNull
private static Set<PolicyRule> getNormalizedRules(Set<PolicyRule> collectedRules) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add tests for this method and maybe add more comments about what it's doing?

@@ -108,6 +99,8 @@ public void shouldCreateRolesAndRoleBindings() throws IOException {
.filter(rule -> rule.getResources().equals(List.of(RBACRule.ALL)))
.anyMatch(rule -> rule.getVerbs().equals(List.of(UPDATE))
&& rule.getApiGroups().equals(List.of(RBACRule.ALL))));
rules.stream().filter(rule -> rule.getApiGroups().equals(List.of(TypelessKubeResource.GROUP)))
Copy link
Member

Choose a reason for hiding this comment

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

This is missing an assertion.

@metacosm
Copy link
Member

Generally speaking, I will have some improvements, especially after operator-framework/java-operator-sdk#2515 is available in a release, as this will be more precise.

@chendouble
Copy link
Contributor Author

Generally speaking, I will have some improvements, especially after operator-framework/java-operator-sdk#2515 is available in a release, as this will be more precise.

I agree.

@metacosm
Copy link
Member

Thank you for the improvements. However, I think that the merging of rules targeting the same apiGroup/kind should be done while we're gathering them, not after, as this would be clearer to understand, in my opinion. Would you mind modifying your PR to do that?

@chendouble
Copy link
Contributor Author

Maybe the naming is the key, not about before or after.

Copy link
Member

@metacosm metacosm left a comment

Choose a reason for hiding this comment

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

Thank you!

@metacosm metacosm merged commit 3ad74ac into quarkiverse:main Aug 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants