-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add decorator to remove namespace from ClusterRole and ClusterRoleBin…
…ding
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 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
28 changes: 28 additions & 0 deletions
28
...java/io/quarkus/kubernetes/deployment/RemoveNamespaceFromClusterRoleBindingDecorator.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,28 @@ | ||
package io.quarkus.kubernetes.deployment; | ||
|
||
import io.dekorate.kubernetes.decorator.Decorator; | ||
import io.dekorate.kubernetes.decorator.NamedResourceDecorator; | ||
import io.fabric8.kubernetes.api.model.ObjectMeta; | ||
import io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder; | ||
|
||
/** | ||
* Decorator responsible for remove namespace from ClusterRoleBinding resource. | ||
* | ||
* This decorator executes after {@link AddNamespaceDecorator}. | ||
*/ | ||
public class RemoveNamespaceFromClusterRoleBindingDecorator extends NamedResourceDecorator<ClusterRoleBindingBuilder> { | ||
|
||
@Override | ||
public void andThenVisit(ClusterRoleBindingBuilder clusterRoleBindingBuilder, ObjectMeta objectMeta) { | ||
clusterRoleBindingBuilder | ||
.withNewMetadata() | ||
.withNamespace(null) | ||
.withName(objectMeta.getName()) | ||
.endMetadata(); | ||
} | ||
|
||
@Override | ||
public Class<? extends Decorator>[] after() { | ||
return new Class[] { AddNamespaceDecorator.class }; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...c/main/java/io/quarkus/kubernetes/deployment/RemoveNamespaceFromClusterRoleDecorator.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,28 @@ | ||
package io.quarkus.kubernetes.deployment; | ||
|
||
import io.dekorate.kubernetes.decorator.Decorator; | ||
import io.dekorate.kubernetes.decorator.NamedResourceDecorator; | ||
import io.fabric8.kubernetes.api.model.ObjectMeta; | ||
import io.fabric8.kubernetes.api.model.rbac.ClusterRoleBuilder; | ||
|
||
/** | ||
* Decorator responsible for remove namespace from ClusterRole resource. | ||
* | ||
* This decorator executes after {@link AddNamespaceDecorator}. | ||
*/ | ||
public class RemoveNamespaceFromClusterRoleDecorator extends NamedResourceDecorator<ClusterRoleBuilder> { | ||
|
||
@Override | ||
public void andThenVisit(ClusterRoleBuilder clusterRoleBuilder, ObjectMeta objectMeta) { | ||
clusterRoleBuilder | ||
.withNewMetadata() | ||
.withNamespace(null) | ||
.withName(objectMeta.getName()) | ||
.endMetadata(); | ||
} | ||
|
||
@Override | ||
public Class<? extends Decorator>[] after() { | ||
return new Class[] { AddNamespaceDecorator.class }; | ||
} | ||
} |
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