From c749ff8f902d1745da07a9657474748fbb5b8d75 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Wed, 29 Nov 2023 16:07:50 -0500 Subject: [PATCH] fix: add task for updating from the upstream template Signed-off-by: Devin Buhl --- .gitignore | 2 ++ Taskfile.yaml | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index 3967685d1ab..4ad3e0699bb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ kubeconfig *.key # Ansible .venv* +# Taskfile +.tasks diff --git a/Taskfile.yaml b/Taskfile.yaml index 89825508495..44ef86cb81f 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -28,6 +28,7 @@ tasks: deps: desc: Create a Python virtual env and install required packages + summary: task {{.TASK}} cmds: - "{{.PYTHON_BIN}} -m venv {{.ROOT_DIR}}/.venv" - .venv/bin/python3 -m pip install --upgrade pip setuptools wheel @@ -36,6 +37,7 @@ tasks: init: desc: Initialize configuration files + summary: task {{.TASK}} dir: "{{.BOOTSTRAP_DIR}}" cmds: - cp -n vars/addons.sample.yaml vars/addons.yaml @@ -54,6 +56,7 @@ tasks: configure: desc: Configure repository from Ansible vars + summary: task {{.TASK}} # TODO: Only prompt when directories exist # https://github.com/go-task/task/issues/1330 prompt: Any conflicting config in the root kubernetes and ansible directories will be overwritten... continue? @@ -61,3 +64,19 @@ tasks: cmd: ansible-playbook configure.yaml env: ANSIBLE_DISPLAY_SKIPPED_HOSTS: "false" + + update-template: + desc: Update from the upstream flux-cluster-template repository + summary: task {{.TASK}} + cmds: + - mkdir -p $(dirname {{.shafile}}) + - touch {{.shafile}} + - git remote get-url template >/dev/null 2>&1 || git remote add template git@github.com:onedr0p/flux-cluster-template + - git fetch --all + - git cherry-pick --no-commit --allow-empty $(cat {{.shafile}})..template/main + - git ls-remote template HEAD | awk '{ print $1}' > {{.shafile}} + vars: + shafile: "{{.ROOT_DIR}}/.tasks/.latest-template.sha" + preconditions: + - { msg: "Git repository not up-to-date", sh: "git diff --exit-code" } + - { msg: "Git repository not up-to-date", sh: "git diff --cached --exit-code" }