From 5ca0a296cdc8bbeace8a5bdb2b6acbf456cba2d1 Mon Sep 17 00:00:00 2001 From: knqyf263 Date: Tue, 7 May 2024 11:15:54 +0400 Subject: [PATCH] feat: add namespaces Signed-off-by: knqyf263 --- .github/workflows/deploy-index.yaml | 4 +--- ci/concat.sh | 27 +++++++++++++++++++++++++ plugins/{ => aquasecurity}/aqua.yaml | 0 plugins/{ => aquasecurity}/kubectl.yaml | 0 site/data/.gitkeep | 0 site/layouts/index.html | 4 ++-- 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100755 ci/concat.sh rename plugins/{ => aquasecurity}/aqua.yaml (100%) rename plugins/{ => aquasecurity}/kubectl.yaml (100%) create mode 100644 site/data/.gitkeep diff --git a/.github/workflows/deploy-index.yaml b/.github/workflows/deploy-index.yaml index 1533f78..92dd21c 100644 --- a/.github/workflows/deploy-index.yaml +++ b/.github/workflows/deploy-index.yaml @@ -19,9 +19,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Generate a list of plugins - run: | - mkdir -p site/data/v1 site/v1 - cat plugins/*.yaml > site/data/plugins.yaml + run: ./ci/concat.sh site/data/plugins.yaml - name: Install Hugo CLI run: | wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ diff --git a/ci/concat.sh b/ci/concat.sh new file mode 100755 index 0000000..0a90549 --- /dev/null +++ b/ci/concat.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +output_file=$1 + +# Remove the output file if it exists +if [ -f "$output_file" ]; then + rm "$output_file" +fi + +# Process all YAML files under the plugins directory +for file in plugins/*/*.yaml; do + # Get the directory name as the namespace + namespace=$(basename "$(dirname "$file")") + + # Read the content of the YAML file, add the namespace, and append to the output file + while IFS= read -r line; do + if [[ $line == *"- name:"* ]]; then + echo "$line" >> "$output_file" + echo " namespace: $namespace" >> "$output_file" + else + echo "$line" >> "$output_file" + fi + done < "$file" + + # Add a separator line between files + echo "" >> "$output_file" +done diff --git a/plugins/aqua.yaml b/plugins/aquasecurity/aqua.yaml similarity index 100% rename from plugins/aqua.yaml rename to plugins/aquasecurity/aqua.yaml diff --git a/plugins/kubectl.yaml b/plugins/aquasecurity/kubectl.yaml similarity index 100% rename from plugins/kubectl.yaml rename to plugins/aquasecurity/kubectl.yaml diff --git a/site/data/.gitkeep b/site/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/site/layouts/index.html b/site/layouts/index.html index 6fc8359..b41a96a 100644 --- a/site/layouts/index.html +++ b/site/layouts/index.html @@ -20,9 +20,9 @@

{{ .Site.Title }}

- {{ range .Site.Data.v1.plugins }} + {{ range .Site.Data.plugins }} - {{ .name }} + {{ .namespace }}/{{ .name }} {{ if .type }}{{ .type }}{{ else }}generic{{ end }} {{ .summary }}