-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: peefy <[email protected]>
- Loading branch information
Showing
3 changed files
with
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## Introduction | ||
|
||
`add-rolebinding` is a KCL mutation module. | ||
|
||
## Resource | ||
|
||
The Code source and documents are [here](https://github.com/kcl-lang/artifacthub/tree/main/add-rolebinding) |
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,5 @@ | ||
[package] | ||
name = "add-rolebinding" | ||
version = "0.1.0" | ||
description = "`add-rolebinding` is a KCL mutation module." | ||
|
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,25 @@ | ||
ns_list = [item.metadata.name for item in option("items") if item.kind == "Namespace"] | ||
username = option("params")?.username or "user" | ||
|
||
items = option("items") + [ | ||
{ | ||
synchronize: True | ||
apiVersion: "rbac.authorization.k8s.io/v1" | ||
kind: "RoleBinding" | ||
name: "${username}-admin-binding" | ||
namespace: ns.metadata.name | ||
data: { | ||
roleRef: { | ||
apiGroup: "rbac.authorization.k8s.io" | ||
kind: "ClusterRole" | ||
name: "admin" | ||
} | ||
subjects: [ | ||
{ | ||
kind: "User" | ||
name: "${username}" | ||
} | ||
] | ||
} | ||
} for ns in ns_list | ||
] |