-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from Peefy/add-more-flux-modules
feat: add more validation modules about fluxcd
- Loading branch information
Showing
15 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 []] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 []] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 []] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 []] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 []] |