From 057b1ec1fffc94fb3af6c0a653fc76de7b47f794 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Tue, 14 Nov 2023 16:31:08 +0100 Subject: [PATCH] Add direnv support with boilerplate This add a .envrc file that will be used by direnv to setup the environment for the project if `direnv` is enabled. It also adds a `.env.sample` to give an example of what it could be useful for. And it adds `.env` to gitignore to make sure people do not commit their specific environment configurations. Signed-off-by: Vincent Demeester --- .env.sample | 4 ++++ .envrc | 18 ++++++++++++++++++ .gitignore | 1 + 3 files changed, 23 insertions(+) create mode 100644 .env.sample create mode 100644 .envrc diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000000..9d2db2f345 --- /dev/null +++ b/.env.sample @@ -0,0 +1,4 @@ +# shellcheck shell=bash +# This is an example of a .env file +export GOMAXPROCS=6 +export KO_DOCKER_REPO=gcr.io/tektoncd/pipeline diff --git a/.envrc b/.envrc new file mode 100644 index 0000000000..57593a21e4 --- /dev/null +++ b/.envrc @@ -0,0 +1,18 @@ +# shellcheck shell=bash + +# If .env missing; restore from .env.sample and validate +# See https://github.com/direnv/direnv/wiki/.envrc-Boilerplate +if [[ -f .env.sample ]]; then + if [[ ! -f .env ]]; then + if ! command -v createnv > /dev/null; then + echo 'WARN|Createnv missing; try: pyenv local 3.x && pip install createnv' + else + createnv --use-default --overwrite || echo 'ERROR|https://github.com/cuducos/createnv' + if command dotenv-linter --version >&/dev/null; then + dotenv-linter .env || echo 'ERROR|https://dotenv-linter.github.io' + fi + fi + fi +fi + +dotenv_if_exists || direnv status # https://direnv.net/man/direnv-stdlib.1.html diff --git a/.gitignore b/.gitignore index 28e603b9c0..e3c34c889c 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ tags *.nupkg .bin +.env \ No newline at end of file