Skip to content

Commit

Permalink
Merge pull request #65 from Peefy/add-add-rolebinding
Browse files Browse the repository at this point in the history
feat: add cluster role binding
  • Loading branch information
Peefy authored Nov 9, 2023
2 parents 2b1616a + 4f8a042 commit c35cf17
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 c35cf17

Please sign in to comment.