generated from quarkiverse/quarkiverse-template
-
Notifications
You must be signed in to change notification settings - Fork 51
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
metacosm
merged 4 commits into
quarkiverse:main
from
chendouble:support-typeless-kubernetes-resource
Aug 26, 2024
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,17 +28,7 @@ | |
import io.quarkiverse.operatorsdk.annotations.RBACVerbs; | ||
import io.quarkiverse.operatorsdk.deployment.AddClusterRolesDecorator; | ||
import io.quarkiverse.operatorsdk.deployment.AddRoleBindingsDecorator; | ||
import io.quarkiverse.operatorsdk.test.sources.CRUDConfigMap; | ||
import io.quarkiverse.operatorsdk.test.sources.CreateOnlyService; | ||
import io.quarkiverse.operatorsdk.test.sources.Foo; | ||
import io.quarkiverse.operatorsdk.test.sources.NonKubeResource; | ||
import io.quarkiverse.operatorsdk.test.sources.ReadOnlySecret; | ||
import io.quarkiverse.operatorsdk.test.sources.SimpleCR; | ||
import io.quarkiverse.operatorsdk.test.sources.SimpleReconciler; | ||
import io.quarkiverse.operatorsdk.test.sources.SimpleSpec; | ||
import io.quarkiverse.operatorsdk.test.sources.SimpleStatus; | ||
import io.quarkiverse.operatorsdk.test.sources.TestCR; | ||
import io.quarkiverse.operatorsdk.test.sources.TestReconciler; | ||
import io.quarkiverse.operatorsdk.test.sources.*; | ||
import io.quarkus.test.ProdBuildResults; | ||
import io.quarkus.test.ProdModeTestResults; | ||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
@@ -53,6 +43,7 @@ public class OperatorSDKTest { | |
.withApplicationRoot((jar) -> jar | ||
.addClasses(TestReconciler.class, TestCR.class, CRUDConfigMap.class, ReadOnlySecret.class, | ||
CreateOnlyService.class, NonKubeResource.class, Foo.class, | ||
TypelessKubeResource.class, TypelessAnotherKubeResource.class, | ||
SimpleReconciler.class, SimpleCR.class, SimpleSpec.class, SimpleStatus.class)); | ||
|
||
@ProdBuildResults | ||
|
@@ -79,7 +70,7 @@ public void shouldCreateRolesAndRoleBindings() throws IOException { | |
.map(ClusterRole.class::cast) | ||
.forEach(cr -> { | ||
final var rules = cr.getRules(); | ||
assertEquals(5, rules.size()); | ||
assertEquals(6, rules.size()); | ||
assertTrue(rules.stream() | ||
.filter(rule -> rule.getApiGroups().equals(List.of(HasMetadata.getGroup(TestCR.class)))) | ||
.anyMatch(rule -> { | ||
|
@@ -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))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing an assertion. |
||
.anyMatch(rule -> rule.getResources().equals(List.of("*"))); | ||
}); | ||
|
||
// check that we have a role binding for TestReconciler and that it uses the operator-level specified namespace | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...nt/src/test/java/io/quarkiverse/operatorsdk/test/sources/TypelessAnotherKubeResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.quarkiverse.operatorsdk.test.sources; | ||
|
||
import io.javaoperatorsdk.operator.api.reconciler.dependent.Deleter; | ||
import io.javaoperatorsdk.operator.processing.GroupVersionKind; | ||
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.GenericKubernetesDependentResource; | ||
|
||
public class TypelessAnotherKubeResource extends GenericKubernetesDependentResource<TestCR> implements Deleter<TestCR> { | ||
|
||
public static final String GROUP = "crd.josdk.quarkiverse.io"; | ||
public static final String KIND = "typelessAnother"; | ||
public static final String VERSION = "v1"; | ||
private static final GroupVersionKind GVK = new GroupVersionKind(GROUP, VERSION, KIND); | ||
|
||
public TypelessAnotherKubeResource() { | ||
super(GVK); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...eployment/src/test/java/io/quarkiverse/operatorsdk/test/sources/TypelessKubeResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.quarkiverse.operatorsdk.test.sources; | ||
|
||
import io.javaoperatorsdk.operator.processing.GroupVersionKind; | ||
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.GenericKubernetesDependentResource; | ||
|
||
public class TypelessKubeResource extends GenericKubernetesDependentResource<TestCR> { | ||
|
||
public static final String GROUP = "crd.josdk.quarkiverse.io"; | ||
public static final String KIND = "typeless"; | ||
public static final String VERSION = "v1"; | ||
private static final GroupVersionKind GVK = new GroupVersionKind(GROUP, VERSION, KIND); | ||
|
||
public TypelessKubeResource() { | ||
super(GVK); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you add tests for this method and maybe add more comments about what it's doing?