From dbc39993c3c9c19fb21e3b6073b4c1b774050935 Mon Sep 17 00:00:00 2001 From: Janik von Rotz Date: Sun, 11 Oct 2026 21:49:13 +0200 Subject: [PATCH] chore: remove unused pass/kubeconfig commands and simplify init-dotenv script --- bin/create-dotenv | 20 ++++++++++---------- bin/init-dotenv-sops | 2 +- docs/index.md | 9 +++++++++ docs/library.md | 2 +- task.template | 10 +++++----- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/bin/create-dotenv b/bin/create-dotenv index 6c04240..cd46533 100755 --- a/bin/create-dotenv +++ b/bin/create-dotenv @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - create-dotenv() { if [[ -z "$1" ]]; then echo "\$1/env is empty." @@ -14,19 +12,22 @@ create-dotenv() { local template="$2" local env_filename="${env_name}.env" local template_file="$HOME/taskfile.build/templates/${template}.env.template" - TASK_DOTENV_DIR=${TASK_DOTENV_DIR:="$HOME/.config/taskfile.build"} + local TASK_DOTENV_DIR="${TASK_DOTENV_DIR:-$HOME/.config/taskfile.build}" if [[ ! -f "$template_file" ]]; then echo "Template not found: $template_file" return 1 fi - init-dotenv-dir - local env_filepath if [[ "$template" == "secrets" ]]; then + if [[ ! -f ".sops.yaml" ]]; then + echo "Error: .sops.yaml not found. Run init-dotenv-sops first." + return 1 + fi env_filepath="$env_filename" else + init-dotenv-dir env_filepath="$TASK_DOTENV_DIR/$env_filename" fi @@ -39,12 +40,11 @@ create-dotenv() { cp "$template_file" "$env_filepath" if [[ "$template" == "secrets" ]]; then - if [[ ! -f ".sops.yaml" ]]; then - echo "Error: .sops.yaml not found. Run init-dotenv-sops first." - rm "$env_filepath" + if ! sops --encrypt --in-place "$env_filepath"; then + echo "Encryption failed; removing $env_filepath" + rm -f "$env_filepath" return 1 fi - sops --encrypt --in-place "$env_filepath" echo "Encrypted $env_filepath with sops." fi @@ -52,4 +52,4 @@ create-dotenv() { } crd() { create-dotenv "$@" -} +} \ No newline at end of file diff --git a/bin/init-dotenv-sops b/bin/init-dotenv-sops index e5b2f52..dde2a95 100755 --- a/bin/init-dotenv-sops +++ b/bin/init-dotenv-sops @@ -35,7 +35,7 @@ init-dotenv-sops() { if [[ ! -f ".sops.yaml" ]]; then echo "Create .sops.yaml" - printf 'creation_rules:\n - path_regex: ".*secrets\\.env$"\n age: "%s"\n' "$public_key" > ".sops.yaml" + printf "creation_rules:\n - path_regex: '.*secrets\\.env$'\n age: '%s'\n" "$public_key" > ".sops.yaml" fi echo "Age key file: $age_key_file" diff --git a/docs/index.md b/docs/index.md index e02ad78..81da85e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -44,6 +44,15 @@ Next append the abort on error setting: set -e ``` +Load env vars from `.env` by default. + +```bash +if [[ -f ".env" ]]; then + # shellcheck source=/dev/null + source ".env" +fi +``` + The Taskfile generates a help table. You simply append new help entries and the `help-table` functions generates a beautiful table. ```bash diff --git a/docs/library.md b/docs/library.md index 1edab99..e67016d 100644 --- a/docs/library.md +++ b/docs/library.md @@ -201,7 +201,7 @@ Secrets files ending in `secrets.env` are encrypted with [sops](https://getsops. ### create-dotenv ```bash -rows+=("create-dotenv|