forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#43378 from metacosm/add-crb-bi
Add build item for extensions to contribute ClusterRoleBindings
- Loading branch information
Showing
9 changed files
with
108 additions
and
11 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
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
70 changes: 70 additions & 0 deletions
70
...es/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesClusterRoleBindingBuildItem.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,70 @@ | ||
package io.quarkus.kubernetes.spi; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
/** | ||
* Produce this build item to request the Kubernetes extension to generate | ||
* a Kubernetes {@code ClusterRoleBinding} resource. The configuration here is limited; | ||
* in particular, you can't specify subjects of the role binding. The role will always | ||
* be bound to the application's service account. | ||
*/ | ||
public final class KubernetesClusterRoleBindingBuildItem extends BaseTargetable { | ||
/** | ||
* Name of the generated {@code RoleBinding} resource. | ||
* Can be {@code null}, in which case the resource name is autogenerated. | ||
*/ | ||
private final String name; | ||
/** | ||
* RoleRef configuration. | ||
*/ | ||
private final RoleRef roleRef; | ||
/** | ||
* The target subjects. | ||
*/ | ||
private final Subject[] subjects; | ||
|
||
/** | ||
* The labels of the cluster role resource. | ||
*/ | ||
private final Map<String, String> labels; | ||
|
||
public KubernetesClusterRoleBindingBuildItem(String role, boolean clusterWide) { | ||
this(null, role, clusterWide, null); | ||
} | ||
|
||
public KubernetesClusterRoleBindingBuildItem(String name, String role, boolean clusterWide) { | ||
this(name, role, clusterWide, null); | ||
} | ||
|
||
public KubernetesClusterRoleBindingBuildItem(String name, String role, boolean clusterWide, String target) { | ||
this(name, target, Collections.emptyMap(), | ||
new RoleRef(role, clusterWide), | ||
new Subject("", "ServiceAccount", name, null)); | ||
} | ||
|
||
public KubernetesClusterRoleBindingBuildItem(String name, String target, Map<String, String> labels, RoleRef roleRef, | ||
Subject... subjects) { | ||
super(target); | ||
this.name = name; | ||
this.labels = labels; | ||
this.roleRef = roleRef; | ||
this.subjects = subjects; | ||
} | ||
|
||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
public Map<String, String> getLabels() { | ||
return labels; | ||
} | ||
|
||
public RoleRef getRoleRef() { | ||
return roleRef; | ||
} | ||
|
||
public Subject[] getSubjects() { | ||
return subjects; | ||
} | ||
} |
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