Skip to content

Commit c35cf17

Browse files
authored
Merge pull request #65 from Peefy/add-add-rolebinding
feat: add cluster role binding
2 parents 2b1616a + 4f8a042 commit c35cf17

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

add-rolebinding/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Introduction
2+
3+
`add-rolebinding` is a KCL mutation module.
4+
5+
## Resource
6+
7+
The Code source and documents are [here](https://github.com/kcl-lang/artifacthub/tree/main/add-rolebinding)

add-rolebinding/kcl.mod

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[package]
2+
name = "add-rolebinding"
3+
version = "0.1.0"
4+
description = "`add-rolebinding` is a KCL mutation module."
5+

add-rolebinding/main.k

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ns_list = [item.metadata.name for item in option("items") if item.kind == "Namespace"]
2+
username = option("params")?.username or "user"
3+
4+
items = option("items") + [
5+
{
6+
synchronize: True
7+
apiVersion: "rbac.authorization.k8s.io/v1"
8+
kind: "RoleBinding"
9+
name: "${username}-admin-binding"
10+
namespace: ns.metadata.name
11+
data: {
12+
roleRef: {
13+
apiGroup: "rbac.authorization.k8s.io"
14+
kind: "ClusterRole"
15+
name: "admin"
16+
}
17+
subjects: [
18+
{
19+
kind: "User"
20+
name: "${username}"
21+
}
22+
]
23+
}
24+
} for ns in ns_list
25+
]

0 commit comments

Comments
 (0)