Skip to content

Commit

Permalink
Add direnv support with boilerplate
Browse files Browse the repository at this point in the history
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 <vdemeest@redhat.com>
  • Loading branch information
vdemeester authored and tekton-robot committed Nov 13, 2023
1 parent f975869 commit 89ac5c2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ test/pullrequest/pullrequest-init

# Backup of API reference docs generated by sed
docs/pipeline-api.md.backup

# Ignore .env files
/.env

0 comments on commit 89ac5c2

Please sign in to comment.