Skip to content

feat: add more validation modules about fluxcd #70

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

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 flux-check-buckets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Introduction

`flux-check-buckets` is a KCL validation module

## Resource

The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/flux-check-buckets)
4 changes: 4 additions & 0 deletions flux-check-buckets/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "flux-check-buckets"
version = "0.1.1"
description = "`flux-check-buckets` is a KCL validation module"
13 changes: 13 additions & 0 deletions flux-check-buckets/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
endpoints: [str] = option("params")?.endpoints or []

# Define the validation function
validate = lambda item, endpoints: [str] {
if item.kind == "Bucket" and endpoints:
endpoint: str = item?.spec?.endpoint
assert any e in endpoints {
endpoint.endswith(e)
}, ".spec.endpoint must reference an address within the organizations ${endpoints}."
item
}
# Validate All resource
items = [validate(i, endpoints) for i in option("items") or []]
7 changes: 7 additions & 0 deletions flux-check-github-repositories/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Introduction

`flux-check-github-repositories` is a KCL validation module

## Resource

The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/flux-check-github-repositories)
4 changes: 4 additions & 0 deletions flux-check-github-repositories/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "flux-check-github-repositories"
version = "0.1.1"
description = "`flux-check-github-repositories` is a KCL validation module"
13 changes: 13 additions & 0 deletions flux-check-github-repositories/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos: [str] = option("params")?.repos or []

# Define the validation function
validate = lambda item, repos: [str] {
if item.kind == "GitRepository" and repos:
url: str = item?.spec?.url
assert any r in repos {
url.startswith("https://github.com/${r}/") or url.startswith("ssh://[email protected]:${r}/")
}, ".spec.url must be from a repository within the myorg organization."
item
}
# Validate All resource
items = [validate(i, repos) for i in option("items") or []]
7 changes: 7 additions & 0 deletions flux-check-helm-repositories/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Introduction

`flux-check-helm-repositories` is a KCL validation module

## Resource

The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/flux-check-helm-repositories)
4 changes: 4 additions & 0 deletions flux-check-helm-repositories/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "flux-check-helm-repositories"
version = "0.1.1"
description = "`flux-check-helm-repositories` is a KCL validation module"
15 changes: 15 additions & 0 deletions flux-check-helm-repositories/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import regex

repos: [str] = option("params")?.repos or []

# Define the validation function
validate = lambda item, repos: [str] {
if item.kind == "HelmRepository" and repos:
url: str = item?.spec?.url
assert any r in repos {
regex.match(url, "https://?*.${r}.com/*")
}, ".spec.url must be from a repository within the organizations ${repos}."
item
}
# Validate All resource
items = [validate(i, repos) for i in option("items") or []]
7 changes: 7 additions & 0 deletions flux-check-image-repositories/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Introduction

`flux-check-image-repositories` is a KCL validation module

## Resource

The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/flux-check-image-repositories)
4 changes: 4 additions & 0 deletions flux-check-image-repositories/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "flux-check-image-repositories"
version = "0.1.1"
description = "`flux-check-image-repositories` is a KCL validation module"
13 changes: 13 additions & 0 deletions flux-check-image-repositories/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos: [str] = option("params")?.repos or []

# Define the validation function
validate = lambda item, repos: [str] {
if item.kind == "ImageRepository" and repos:
image: str = item?.spec?.image
assert any r in repos {
image.startswith(r)
}, ".spec.image must be from an image repository within the organizations ${repos}."
item
}
# Validate All resource
items = [validate(i, repos) for i in option("items") or []]
7 changes: 7 additions & 0 deletions flux-check-url/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Introduction

`flux-check-url` is a KCL validation module

## Resource

The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/flux-check-url)
4 changes: 4 additions & 0 deletions flux-check-url/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "flux-check-url"
version = "0.1.1"
description = "`flux-check-url` is a KCL validation module"
16 changes: 16 additions & 0 deletions flux-check-url/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos: [str] = option("params")?.repos or []
urls: [str] = option("params")?.urls or []

# Define the validation function
validate = lambda item, repos: [str] {
if item.kind == "GitRepository" and urls and repos:
url: str = item?.spec?.url
assert any r in repos {
any u in urls {
url.startswith("${u}/${r}/")
}
}, ".spec.url must be from a repository within the urls ${urls} and repos ${repos}"
item
}
# Validate All resource
items = [validate(i, repos) for i in option("items") or []]