feat: add kubeconform workflow and make kubeconform/kustomize required (#1159)

This commit is contained in:
Devin Buhl authored and GitHub committed 2024-01-15 09:42:50 -05:00
1 parent e6fbc6e128
commit ea31a49817
7 files changed
+43 -5

No files matched your search

File renamed without changes.
+1 -1
View File
@@ -114,7 +114,7 @@ jobs:
- name: Run kubeconform - name: Run kubeconform
shell: bash shell: bash
run: ./scripts/kubeconform.sh ./kubernetes run: ./.github/scripts/kubeconform.sh ./kubernetes
- name: List Hosts with Ansible - name: List Hosts with Ansible
if: ${{ steps.config-env.outputs.distribution == 'k3s' || steps.config-env.outputs.distribution == 'k0s' }} if: ${{ steps.config-env.outputs.distribution == 'k3s' || steps.config-env.outputs.distribution == 'k0s' }}
+28
View File
@@ -0,0 +1,28 @@
---
name: "Kubeconform"
on:
pull_request:
branches: ["main"]
paths: ["kubernetes/**"]
env:
KUBERNETES_DIR: ./kubernetes
jobs:
kubeconform:
name: Kubeconform
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Setup Workflow Tools
run: brew install fluxcd/tap/flux kubeconform kustomize
- name: Run kubeconform
shell: bash
run: ./.github/scripts/kubeconform.sh ${{ env.KUBERNETES_DIR }}
+1
View File
@@ -13,3 +13,4 @@ kustomize
moreutils moreutils
sops sops
stern-bin stern-bin
talhelper-bin
+1
View File
@@ -15,4 +15,5 @@ brew "kustomize"
brew "moreutils" brew "moreutils"
brew "sops" brew "sops"
brew "stern" brew "stern"
brew "talhelper"
brew "yq" brew "yq"
+11 -3
View File
@@ -48,11 +48,11 @@ tasks:
desc: Configure repository from Ansible vars desc: Configure repository from Ansible vars
prompt: Any conflicting config in the root kubernetes and ansible directories will be overwritten... continue? prompt: Any conflicting config in the root kubernetes and ansible directories will be overwritten... continue?
cmds: cmds:
- task: .validate - task: .pre-validate
- task: .template - task: .template
- task: sops:encrypt:all - task: .post-validate
.validate: .pre-validate:
internal: true internal: true
cmd: ./.venv/bin/ansible-playbook {{.BOOTSTRAP_DIR}}/validate.yaml cmd: ./.venv/bin/ansible-playbook {{.BOOTSTRAP_DIR}}/validate.yaml
env: env:
@@ -65,9 +65,17 @@ tasks:
internal: true internal: true
cmds: cmds:
- ./.venv/bin/makejinja - ./.venv/bin/makejinja
- task: sops:encrypt:all
# TODO: https://github.com/mirkolenz/makejinja/issues/94
- find {{.ANSIBLE_DIR}} {{.KUBERNETES_DIR}} -type d -empty -delete - find {{.ANSIBLE_DIR}} {{.KUBERNETES_DIR}} -type d -empty -delete
preconditions: preconditions:
- { msg: "bootstrap addons file not found", sh: "test -f {{.BOOTSTRAP_DIR}}/vars/addons.yaml" } - { msg: "bootstrap addons file not found", sh: "test -f {{.BOOTSTRAP_DIR}}/vars/addons.yaml" }
- { msg: "bootstrap config file not found", sh: "test -f {{.BOOTSTRAP_DIR}}/vars/config.yaml" } - { msg: "bootstrap config file not found", sh: "test -f {{.BOOTSTRAP_DIR}}/vars/config.yaml" }
- { msg: "makejinja loader file not found", sh: "test -f {{.BOOTSTRAP_DIR}}/scripts/loader.py" } - { msg: "makejinja loader file not found", sh: "test -f {{.BOOTSTRAP_DIR}}/scripts/loader.py" }
- { msg: "makejinja config file not found", sh: "test -f {{.ROOT_DIR}}/makejinja.toml" } - { msg: "makejinja config file not found", sh: "test -f {{.ROOT_DIR}}/makejinja.toml" }
.post-validate:
internal: true
cmd: ./.github/scripts/kubeconform.sh {{.KUBERNETES_DIR}}
preconditions:
- { msg: "kubeconform file not found", sh: "test -f ./.github/scripts/kubeconform.sh" }
+1 -1
View File
@@ -2,7 +2,7 @@
- name: Check if required CLI tools are present - name: Check if required CLI tools are present
ansible.builtin.shell: | ansible.builtin.shell: |
command -v {{ item }} >/dev/null 2>&1 command -v {{ item }} >/dev/null 2>&1
loop: [age, cloudflared, flux, sops, jq] loop: ["age", "cloudflared", "flux", "sops", "jq", "kubeconform", "kustomize"]
changed_when: false changed_when: false
check_mode: false check_mode: false
register: result register: result