Skip to content

Commit d963d71

Browse files
committed
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 <vdemeest@redhat.com>
1 parent c2098de commit d963d71

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

.env.sample

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# shellcheck shell=bash
2+
# This is an example of a .env file
3+
export GOMAXPROCS=6
4+
export KO_DOCKER_REPO=gcr.io/tektoncd/pipeline

.envrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# shellcheck shell=bash
2+
3+
# If .env missing; restore from .env.sample and validate
4+
# See https://github.com/direnv/direnv/wiki/.envrc-Boilerplate
5+
if [[ -f .env.sample ]]; then
6+
if [[ ! -f .env ]]; then
7+
if ! command -v createnv > /dev/null; then
8+
echo 'WARN|Createnv missing; try: pyenv local 3.x && pip install createnv'
9+
else
10+
createnv --use-default --overwrite || echo 'ERROR|https://github.com/cuducos/createnv'
11+
if command dotenv-linter --version >&/dev/null; then
12+
dotenv-linter .env || echo 'ERROR|https://dotenv-linter.github.io'
13+
fi
14+
fi
15+
fi
16+
fi
17+
18+
dotenv_if_exists || direnv status # https://direnv.net/man/direnv-stdlib.1.html

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ test/pullrequest/pullrequest-init
6060

6161
# Backup of API reference docs generated by sed
6262
docs/pipeline-api.md.backup
63+
64+
# Ignore .env files
65+
/.env

0 commit comments

Comments
 (0)