From 3782fe2ccfae321c55cc95d81b2be37070e90284 Mon Sep 17 00:00:00 2001 From: peefy Date: Mon, 13 Nov 2023 22:23:25 +0800 Subject: [PATCH] feat: publish more nginx ingress modules Signed-off-by: peefy --- nginx-ingress-check-config-map/README.md | 7 +++++++ nginx-ingress-check-config-map/kcl.mod | 5 +++++ nginx-ingress-check-config-map/main.k | 7 +++++++ nginx-ingress-disallow-custom-snippets/README.md | 7 +++++++ nginx-ingress-disallow-custom-snippets/kcl.mod | 5 +++++ nginx-ingress-disallow-custom-snippets/main.k | 10 ++++++++++ 6 files changed, 41 insertions(+) create mode 100644 nginx-ingress-check-config-map/README.md create mode 100644 nginx-ingress-check-config-map/kcl.mod create mode 100644 nginx-ingress-check-config-map/main.k create mode 100644 nginx-ingress-disallow-custom-snippets/README.md create mode 100644 nginx-ingress-disallow-custom-snippets/kcl.mod create mode 100644 nginx-ingress-disallow-custom-snippets/main.k diff --git a/nginx-ingress-check-config-map/README.md b/nginx-ingress-check-config-map/README.md new file mode 100644 index 00000000..4a327055 --- /dev/null +++ b/nginx-ingress-check-config-map/README.md @@ -0,0 +1,7 @@ +## Introduction + +`nginx-ingress-check-config-map` is a KCL validation module. + +## Resource + +The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/nginx-ingress/nginx-ingress-check-config-map) diff --git a/nginx-ingress-check-config-map/kcl.mod b/nginx-ingress-check-config-map/kcl.mod new file mode 100644 index 00000000..d753c5a7 --- /dev/null +++ b/nginx-ingress-check-config-map/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "nginx-ingress-check-config-map" +edition = "*" +version = "0.1.0" +description = "`nginx-ingress-check-config-map` is a KCL validation module" diff --git a/nginx-ingress-check-config-map/main.k b/nginx-ingress-check-config-map/main.k new file mode 100644 index 00000000..04995225 --- /dev/null +++ b/nginx-ingress-check-config-map/main.k @@ -0,0 +1,7 @@ +validate = lambda item: {str:} { + if item.kind == "ConfigMap": + assert item?.data?["allow-snippet-annotations"] == "false", "ingress-nginx allow-snippet-annotations must be set to false" + item +} +# Validate All resource +items = [validate(i) for i in option("items") or []] diff --git a/nginx-ingress-disallow-custom-snippets/README.md b/nginx-ingress-disallow-custom-snippets/README.md new file mode 100644 index 00000000..166928ca --- /dev/null +++ b/nginx-ingress-disallow-custom-snippets/README.md @@ -0,0 +1,7 @@ +## Introduction + +`nginx-ingress-disallow-custom-snippets` is a KCL validation module. + +## Resource + +The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/nginx-ingress/nginx-ingress-disallow-custom-snippets) diff --git a/nginx-ingress-disallow-custom-snippets/kcl.mod b/nginx-ingress-disallow-custom-snippets/kcl.mod new file mode 100644 index 00000000..db35710b --- /dev/null +++ b/nginx-ingress-disallow-custom-snippets/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "nginx-ingress-disallow-custom-snippets" +edition = "*" +version = "0.1.0" +description = "`nginx-ingress-disallow-custom-snippets` is a KCL validation module" diff --git a/nginx-ingress-disallow-custom-snippets/main.k b/nginx-ingress-disallow-custom-snippets/main.k new file mode 100644 index 00000000..908683ed --- /dev/null +++ b/nginx-ingress-disallow-custom-snippets/main.k @@ -0,0 +1,10 @@ +validate = lambda item: {str:} { + if item.kind == "Ingress": + annotations: {str:str} = item?.metadata?.annotations or {} + assert all key in annotations { + not key.endswith("-snippet") + }, "ingress-nginx custom snippets are not allowed" + item +} +# Validate All resource +items = [validate(i) for i in option("items") or []]