Skip to content

Commit

Permalink
feat: add kubeconform workflow and make kubeconform/kustomize required (
Browse files Browse the repository at this point in the history
  • Loading branch information
onedr0p committed Jan 15, 2024
1 parent e6fbc6e commit ea31a49
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:

- name: Run kubeconform
shell: bash
run: ./scripts/kubeconform.sh ./kubernetes
run: ./.github/scripts/kubeconform.sh ./kubernetes

- name: List Hosts with Ansible
if: ${{ steps.config-env.outputs.distribution == 'k3s' || steps.config-env.outputs.distribution == 'k0s' }}
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/kubeconform.yaml
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions .taskfiles/Workstation/ArchPackages
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ kustomize
moreutils
sops
stern-bin
talhelper-bin
1 change: 1 addition & 0 deletions .taskfiles/Workstation/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ brew "kustomize"
brew "moreutils"
brew "sops"
brew "stern"
brew "talhelper"
brew "yq"
14 changes: 11 additions & 3 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ tasks:
desc: Configure repository from Ansible vars
prompt: Any conflicting config in the root kubernetes and ansible directories will be overwritten... continue?
cmds:
- task: .validate
- task: .pre-validate
- task: .template
- task: sops:encrypt:all
- task: .post-validate

.validate:
.pre-validate:
internal: true
cmd: ./.venv/bin/ansible-playbook {{.BOOTSTRAP_DIR}}/validate.yaml
env:
Expand All @@ -65,9 +65,17 @@ tasks:
internal: true
cmds:
- ./.venv/bin/makejinja
- task: sops:encrypt:all
# TODO: https://github.com/mirkolenz/makejinja/issues/94
- find {{.ANSIBLE_DIR}} {{.KUBERNETES_DIR}} -type d -empty -delete
preconditions:
- { 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: "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" }

.post-validate:
internal: true
cmd: ./.github/scripts/kubeconform.sh {{.KUBERNETES_DIR}}
preconditions:
- { msg: "kubeconform file not found", sh: "test -f ./.github/scripts/kubeconform.sh" }
2 changes: 1 addition & 1 deletion bootstrap/tasks/validation/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Check if required CLI tools are present
ansible.builtin.shell: |
command -v {{ item }} >/dev/null 2>&1
loop: [age, cloudflared, flux, sops, jq]
loop: ["age", "cloudflared", "flux", "sops", "jq", "kubeconform", "kustomize"]
changed_when: false
check_mode: false
register: result
Expand Down

0 comments on commit ea31a49

Please sign in to comment.