Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more tekton modules #77

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 []]