Skip to content

Commit

Permalink
[meta] updated pre-commit versioning and taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberdev committed Sep 9, 2023
1 parent c6519de commit 35ef794
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.16.2
rev: v8.18.0
hooks:
- id: gitleaks
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.29.0
rev: v1.32.0
hooks:
- id: yamllint
args: [-c=.yamllint]
Expand Down
15 changes: 12 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ includes:
cluster: ./tasks/cluster.yaml
matrix: ./tasks/matrix.yaml
test: ./tasks/test.yaml
talos: ./tasks/talos.yaml
commit: ./tasks/commit.yaml

vars:
CYAN: tput setaf 6
Expand All @@ -27,7 +29,7 @@ vars:
RESET: tput sgr0
CLEAR: tput reset
PATH_ERROR: is not installed or correctly configured in PATH.
K8S_VERSION: 1.26.1
K8S_VERSION: 1.28.1

dotenv: ['.env']

Expand Down Expand Up @@ -124,8 +126,9 @@ tasks:
- sh: "which kuota-calc"
msg: "kuota-calc {{.PATH_ERROR}}"
cmds:
- find . -maxdepth 20 -name deployment.yaml -exec cat {} \; | kuota-calc --detailed
- find . -maxdepth 20 -name statefulset.yaml -exec cat {} \; | kuota-calc --detailed
- find . -maxdepth 50 -name deployment.yaml -exec cat {} \; | kuota-calc --detailed
- find . -maxdepth 50 -name statefulset.yaml -exec cat {} \; | kuota-calc --detailed
- find . -maxdepth 50 -name daemonset.yaml -exec cat {} \; | kuota-calc --detailed

test:k3d:
desc: Starts your local k3d cluster.
Expand Down Expand Up @@ -196,6 +199,7 @@ tasks:
- helm repo add pixie-operator https://pixie-operator-charts.storage.googleapis.com
- helm repo add eraser https://azure.github.io/eraser/charts
- helm repo add vmware-tanzu https://vmware-tanzu.github.io/helm-charts
- helm repo add mayastor https://openebs.github.io/mayastor-extensions/
- task: clear
- echo -e "This will add new repositories to your local Helm\n"
- task: highlight_normal
Expand Down Expand Up @@ -224,3 +228,8 @@ tasks:
- echo -e "Added 'k8s.localhost' and related domains to your hosts file!"
- task: reset
ignore_error: true

run:
cmds:
- task: validate
- task: commit
52 changes: 52 additions & 0 deletions tasks/commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: '3'
vars:
CYAN: tput setaf 6
RED: tput setaf 1
YELLOW: tput setaf 3
GREEN: tput setaf 2
BLUE: tput setaf 1
PURPLE: tput setaf 5
BG_B: tput setab 0
BOLD: tput bold
RESET: tput sgr0
CLEAR: tput reset
PATH_ERROR: is not installed or correctly configured in PATH.
env:
VERSION: "1.3.1"

silent: true

# Thanks https://avasdream.engineer/kubernetes-longhorn-stuck-terminating

tasks:
install:
preconditions:
- sh: "which pre-commit"
msg: "pre-commit {{.PATH_ERROR}}"
cmds:
- pre-commit install
- pre-commit install-hooks
ignore_error: true

test:
preconditions:
- sh: "which pre-commit"
msg: "pre-commit {{.PATH_ERROR}}"
cmds:
- pre-commit run --all-files

update:
preconditions:
- sh: "which pre-commit"
msg: "pre-commit {{.PATH_ERROR}}"
cmds:
- pre-commit autoupdate

default:
preconditions:
- sh: "which pre-commit"
msg: "pre-commit {{.PATH_ERROR}}"
cmds:
- task: install
- task: update
- task: test
55 changes: 55 additions & 0 deletions tasks/talos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3'

silent: true

vars:
CONTROLLER_IPV4: https://192.168.1.2:6443
BACKUP_TIME:
sh: echo $(date +%s)

tasks:
gen:init:
dir: config/talos
cmds:
- task: gen:backup
- task: gen:clean
- talosctl gen config homelab {{.CONTROLLER_IPV4}}
ignore_error: true

gen:clean:
dir: config/talos
cmds:
- rm controlplane.yaml worker.yaml talosconfig

gen:init:patch:
dir: config/talos
cmds:
- task: gen:backup
- task: gen:clean
- |
talosctl gen config homelab {{.CONTROLLER_IPV4}} \
--config-patch @patch.yaml \
--config-patch-control-plane @controller-patch.yaml \
--config-patch-worker @worker-patch.yaml
ignore_error: true

gen:patch:
dir: config/talos
cmds:
- task: gen:backup
- talosctl machineconfig patch worker.yaml --patch @worker-patch.yaml -o worker.yaml
- talosctl machineconfig patch controlplane.yaml --patch @controller-patch.yaml -o controlplane.yaml
ignore_error: true

gen:backup:
dir: config/talos
cmds:
- |
for file in controller.yaml controlplane.yaml worker.yaml talosconfig; do
if [ -f "$file" ]; then
filename=$(basename -- "$file")
extension="${filename##*.}"
filename="${filename%.*}"
cp "$file" "backup/${filename}_{{.BACKUP_TIME}}.${extension}"
fi
done

0 comments on commit 35ef794

Please sign in to comment.