Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
HariSekhon authored Sep 7, 2024
0 parents commit 550755b
Show file tree
Hide file tree
Showing 26 changed files with 1,445 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2015-10-31 19:04:34 +0000 (Sat, 31 Oct 2015)
#
# https://github.com/HariSekhon/Template-repo
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback
# to help improve or steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#

# http://EditorConfig.org

# stop recursing upwards for other .editorconfig files
root = true

# Unix-style newlines with a newline ending every file
[*]
indent_size = 4
indent_style = space
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.go]
indent_size = 4
indent_style = tab
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_size = 4
indent_style = tab
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[{*.md,*.hcl,*.tf,*.tfvars}]
indent_size = 2
indent_style = space
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml,*.yaml]
indent_size = 2
indent_style = space
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[.*]
indent_size = 4
indent_style = space
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

# ============================================================================ #
# Older Stuff, don't think I use this any more
# ============================================================================ #

# Matches multiple files with brace expansion notation
# Set default charset
#[*.{js,py}]
#charset = utf-8

# Indentation override for all JS under lib directory
#[lib/**.js]
#indent_style = space
#indent_size = 2

# Matches the exact files either package.json or .travis.yml
#[{package.json,.travis.yml}]
#indent_style = space
#indent_size = 2

#[*.xml]
#indent_style = space
#indent_size = 2
203 changes: 203 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: Mon Feb 22 17:42:01 2021 +0000
#
# https://github.com/HariSekhon/Template-repo
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#

# ============================================================================ #
# D i r E n v
# ============================================================================ #

# https://direnv.net/man/direnv-stdlib.1.html

# See Also:
#
# .envrc-aws
# .envrc-gcp
# .envrc-kubernetes

# direnv stdlib - loads .envrc from parent dir up to /
#
# useful to accumulate parent and child directory .envrc settings eg. adding Kubernetes namespace, ArgoCD app etc.
#
# bypasses security authorization though - use with care
#source_up
#
# source_up must be loaded before set -u otherwise gets this error:
#
# direnv: loading .envrc
# /bin/bash: line 226: $1: unbound variable
#
# source_up causes this error is up .envrc is found in parent directories:
#
# direnv: No ancestor .envrc found

set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
src="$(readlink -f "${BASH_SOURCE[0]}")"
srcdir="$(cd "$(dirname "$src")" && pwd)"

# ============================================================================ #
# P r e - C o m m i t
# ============================================================================ #

# Automatically install Pre-Commit Git hooks if not already present

if ! type -P pre-commit &>/dev/null; then
if uname -s | grep -q Darwin &&
type -P brew &>/dev/null; then
echo
echo "Pre-commit is not installed - installing now using Homebrew..."
echo
brew install pre-commit
echo
elif type -P pip &>/dev/null; then
echo
echo "Pre-commit is not installed - installing now using Pip..."
echo
pip install pre-commit
fi
fi

if [ -f .pre-commit-config.yaml ] &&
type -P pre-commit &>/dev/null &&
git rev-parse --is-inside-work-tree &>/dev/null; then
if ! [ -f "$(git rev-parse --show-toplevel)/.git/hooks/pre-commit" ]; then
echo
echo "Pre-commit hook is not installed in local Git repo checkout - installing now..."
echo
pre-commit install
fi
fi

# ============================================================================ #
# D o c k e r C o m p o s e
# ============================================================================ #

export COMPOSE_PROJECT_NAME="Template-repo"

# ============================================================================ #
# G i t H u b
# ============================================================================ #

#export GITHUB_ORGANIZATION=HariSekhon

# ============================================================================ #
# A n s i b l e
# ============================================================================ #

# use the local repo's ansible.cfg rather than:
#
# $PWD/ansible.cfg
# ~/.ansible.cfg
# /etc/ansible/ansible.cfg
#
# set this in project repos to ensure user environment ANSIBLE_CONFIG doesn't get used
#export ANSIBLE_CONFIG="/path/to/ansible.cfg"

# ============================================================================ #
# C l o u d f l a r e
# ============================================================================ #

#export CLOUDFLARE_EMAIL=hari@...
#export CLOUDFLARE_API_KEY=... # generate here: https://dash.cloudflare.com/profile/api-tokens
#export CLOUDFLARE_TOKEN=... # used by cloudflare_api.sh but not by terraform module

# export the variables for terraform
#export TF_VAR_cloudflare_email="$CLOUDFLARE_EMAIL"
#export TF_VAR_cloudflare_api_key="$CLOUDFLARE_API_KEY" # must be a key, not a token using the link above

# ============================================================================ #
# Load External Envrc Files If Present
# ============================================================================ #

# XXX: safer to bring all these external .envrc inline if you're worried about changes
# to it bypassing 'direnv allow' authorization
load_if_exists(){
# first arg is a path to a .envrc
# all other args are passed to the sourcing of .envrc - used by .envrc-kubernetes
# to pass the context name 'docker-desktop' to switch to
local envrc="$1"
shift
if ! [[ "$envrc" =~ ^/ ]]; then
envrc="$srcdir/$envrc"
fi
if [ -f "$envrc" ]; then
# prevent looping on symlinks to this .envrc if given
if [ "$(readlink "$envrc")" = "$src" ]; then
return
fi
echo
echo "Loading $envrc"
# shellcheck disable=SC1090,SC1091
. "$envrc" "$@"
fi
}

# don't do this it may lead to an infinite loop if 'make link' symlinking ~/.envrc to this repo's .envrc
# (which I do to keep Python virtual automatically loaded at all times because recent pip on Python refuses
# to install to system Python)
#load_if_exists ~/.envrc

# ============================================================================ #
# P y t h o n
# ============================================================================ #

#.envrc-aws \
#.envrc-gcp \
#.envrc-terraform \
# shellcheck disable=SC2043
for envrc in \
.envrc-python \
; do
load_if_exists "$envrc"
done

# ============================================================================ #
# A W S
# ============================================================================ #

if [[ "$PWD" =~ /aws/ ]]; then
load_if_exists .envrc-aws
fi

# ============================================================================ #
# G C P
# ============================================================================ #

if [[ "$PWD" =~ /gcp/ ]]; then
load_if_exists .envrc-gcp
fi

# ============================================================================ #
# T e r r a f o r m
# ============================================================================ #

if [[ "$PWD" =~ /(terra(form)?|tf)(/|$) ]]; then
load_if_exists .envrc-terraform
fi

# ============================================================================ #
# K u b e r n e t e s
# ============================================================================ #

if [ -f "$srcdir/.envrc-kubernetes" ]; then
load_if_exists .envrc-kubernetes docker-desktop
fi

# ============================================================================ #
# . E n v
# ============================================================================ #

echo
# read .env too
#dotenv
43 changes: 43 additions & 0 deletions .envrc-python
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: Mon Feb 22 17:42:01 2021 +0000
#
# https://github.com/HariSekhon/Template-repo
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#

# ============================================================================ #
# P y t h o n D i r E n v
# ============================================================================ #

# .envrc to auto-load the virtualenv inside the 'venv' directory if present

# https://direnv.net/man/direnv-stdlib.1.html

set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
#srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# this is necessary because newer versions of pip no longer allow you to install PyPI packages in system-packages by default
for venv in "$PWD/venv" "$HOME/venv"; do
if [ -f "$venv/bin/activate" ]; then
echo
echo "Virtualenv directory found in: $venv"
echo
echo "Activating Virtualenv inside the directory: $venv"

# shellcheck disable=SC1091
source "$venv/bin/activate"
break
fi
done

# read .env too
#dotenv
60 changes: 60 additions & 0 deletions .github/workflows/grype.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#
# Author: Hari Sekhon
# Date: 2023-05-13 01:07:56 +0100 (Sat, 13 May 2023)
#
# vim:ts=2:sts=2:sw=2:et
#
# https://github.com/HariSekhon/Template-repo
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback
#
# https://www.linkedin.com/in/HariSekhon
#

# ============================================================================ #
# G r y p e
# ============================================================================ #

---
name: Grype

on:
push:
branches:
- master
- main
paths-ignore:
- '**/*.md'
pull_request:
branches:
- master
- main
paths-ignore:
- '**/*.md'
workflow_dispatch:
inputs:
debug:
type: boolean
required: false
default: false
schedule:
- cron: '0 0 * * 1'

permissions:
actions: read
contents: read
security-events: write

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
Grype:
# github.event.repository context not available in scheduled workflows
#if: github.event.repository.fork == false
if: github.repository_owner == 'HariSekhon'
name: Grype
uses: HariSekhon/GitHub-Actions/.github/workflows/grype.yaml@master
with:
debug: ${{ github.event.inputs.debug }}
Loading

0 comments on commit 550755b

Please sign in to comment.