Skip to content

Commit

Permalink
Merge pull request #77 from Peefy/add-more-tekton-modules
Browse files Browse the repository at this point in the history
feat: add more tekton modules
  • Loading branch information
Peefy authored Nov 13, 2023
2 parents 98758a9 + d961880 commit 6336472
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tekton-require-bundle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Introduction

`tekton-require-bundle` is a KCL validation module.

## Resource

The Code source and document are [here](https://github.com/kcl-lang/modules/tree/main/nginx-ingress/tekton-require-bundle)
5 changes: 5 additions & 0 deletions tekton-require-bundle/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "tekton-require-bundle"
edition = "*"
version = "0.1.0"
description = "`tekton-require-bundle` is a KCL validation module"
9 changes: 9 additions & 0 deletions tekton-require-bundle/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
validate = lambda item {
if item.kind in ["PipelineRun"]:
assert item.spec?.pipelineRef?.bundle, "A bundle is required."
elif item.kind in ["TaskeRun"]:
assert item.spec?.taskRef?.bundle, "A bundle is required."
item
}
# Validate All resource
items = [validate(i) for i in option("items") or []]
7 changes: 7 additions & 0 deletions tekton-require-namespace-pipeline-run/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Introduction

`tekton-require-namespace-pipeline-run` is a KCL validation module.

## Resource

The Code source and document are [here](https://github.com/kcl-lang/modules/tree/main/nginx-ingress/tekton-require-namespace-pipeline-run)
5 changes: 5 additions & 0 deletions tekton-require-namespace-pipeline-run/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "tekton-require-namespace-pipeline-run"
edition = "*"
version = "0.1.0"
description = "`tekton-require-namespace-pipeline-run` is a KCL validation module"
8 changes: 8 additions & 0 deletions tekton-require-namespace-pipeline-run/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
validate = lambda item {
if item.kind in ["PipelineRun"]:
ns = item.metadata.namespace or "default"
assert ns != "default", "A namespace is required and may not be set to default."
item
}
# Validate All resource
items = [validate(i) for i in option("items") or []]
7 changes: 7 additions & 0 deletions tekton-require-securitycontext/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Introduction

`tekton-require-securitycontext` is a KCL validation module.

## Resource

The Code source and document are [here](https://github.com/kcl-lang/modules/tree/main/nginx-ingress/tekton-require-securitycontext)
5 changes: 5 additions & 0 deletions tekton-require-securitycontext/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "tekton-require-securitycontext"
edition = "*"
version = "0.1.0"
description = "`tekton-require-securitycontext` is a KCL validation module"
10 changes: 10 additions & 0 deletions tekton-require-securitycontext/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
validate = lambda item {
if item.kind in ["TaskRun"]:
steps = [s for s in (item.status?.taskSpec?.steps or [] + item.spec?.steps or []) if s.name != digest-to-results]
assert all s in steps {
s.privileged == False and s.allowPrivilegeEscalation == False
}, "A securityContext is required with `privileged` and `allowPrivilegeEscalation` set to `false`."
item
}
# Validate All resource
items = [validate(i) for i in option("items") or []]

0 comments on commit 6336472

Please sign in to comment.