Skip to content

Commit

Permalink
feat: add cluster role binding
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Nov 9, 2023
1 parent 2b1616a commit 4f8a042
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions add-rolebinding/README.md
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)
5 changes: 5 additions & 0 deletions add-rolebinding/kcl.mod
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."

25 changes: 25 additions & 0 deletions add-rolebinding/main.k
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
]

0 comments on commit 4f8a042

Please sign in to comment.