generated from quarkiverse/quarkiverse-template
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support adding extra RBAC rules via annotations (#701)
* chore: remove unneeded dependency * feat: add annotations module with RBAC-related annotations * refactor: move verb constants to new Verbs class in annotations module * refactor: rename constants more appropriately, add more * refactor: rename Verbs to more precise RBACVerbs * feat: make RBACRule repeatable, add ALL constant * feat: support adding extra RBAC rules via annotations See SimpleReconciler for a usage example. Fixes #696 * fix: properly handle case where there's only one RBACRule
- Loading branch information
Showing
16 changed files
with
226 additions
and
55 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkiverse.operatorsdk</groupId> | ||
<artifactId>quarkus-operator-sdk-parent</artifactId> | ||
<version>6.3.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>quarkus-operator-sdk-annotations</artifactId> | ||
<name>Quarkus - Operator SDK - Annotations</name> | ||
|
||
</project> |
13 changes: 13 additions & 0 deletions
13
annotations/src/main/java/io/quarkiverse/operatorsdk/annotations/AdditionalRBACRules.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,13 @@ | ||
package io.quarkiverse.operatorsdk.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE }) | ||
@SuppressWarnings("unused") | ||
public @interface AdditionalRBACRules { | ||
RBACRule[] value(); | ||
} |
24 changes: 24 additions & 0 deletions
24
annotations/src/main/java/io/quarkiverse/operatorsdk/annotations/RBACRule.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,24 @@ | ||
package io.quarkiverse.operatorsdk.annotations; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE }) | ||
@Repeatable(AdditionalRBACRules.class) | ||
@SuppressWarnings("unused") | ||
public @interface RBACRule { | ||
/** | ||
* Represents a wildcard string that matches any RBAC-related value (verb, resource, etc…). | ||
*/ | ||
String ALL = "*"; | ||
|
||
String[] apiGroups() default {}; | ||
|
||
String[] verbs(); | ||
|
||
String[] resources() default {}; | ||
|
||
String[] resourceNames() default {}; | ||
|
||
String[] nonResourceURLs() default {}; | ||
} |
29 changes: 29 additions & 0 deletions
29
annotations/src/main/java/io/quarkiverse/operatorsdk/annotations/RBACVerbs.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,29 @@ | ||
package io.quarkiverse.operatorsdk.annotations; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
public class RBACVerbs { | ||
public static final String CREATE = "create"; | ||
public static final String PATCH = "patch"; | ||
public static final String UPDATE = "update"; | ||
public static final String GET = "get"; | ||
public static final String LIST = "list"; | ||
public static final String WATCH = "watch"; | ||
public static final String DELETE = "delete"; | ||
public static final String[] UPDATE_VERBS = new String[] { PATCH, UPDATE }; | ||
public static final String[] READ_VERBS = new String[] { GET, LIST, WATCH }; | ||
public static final String[] ALL_COMMON_VERBS; | ||
|
||
static { | ||
final var verbs = new ArrayList<String>(READ_VERBS.length + UPDATE_VERBS.length + 2); | ||
verbs.addAll(Arrays.asList(READ_VERBS)); | ||
verbs.addAll(Arrays.asList(UPDATE_VERBS)); | ||
verbs.add(CREATE); | ||
verbs.add(DELETE); | ||
ALL_COMMON_VERBS = verbs.toArray(new String[0]); | ||
} | ||
|
||
private RBACVerbs() { | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.