Skip to content

Commit

Permalink
chore: improve devcontainer setup & docs
Browse files Browse the repository at this point in the history
- Improve install for curl install with go install jq command.
- Improve devcontainer to mount dsv local config if it's available.
  • Loading branch information
sheldonhull committed Jan 12, 2023
1 parent b6ab3d4 commit 170219b
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .changes/unreleased/🤖 Development-20230112-004952.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: "\U0001F916 Development"
body:
Devcontainer attempts to mount existing dsv cli configuration from filestore
if this is available. This will ease local devcontainer usage setup and allow testing
and `$HOME/.envrc` configurations to be autoloaded.
time: 2023-01-12T00:49:52.438142024Z
custom:
azure-boards-workitemid-fixed: ''
azure-boards-workitemid-related: ''
github-contributor: sheldonhull
github-link: ''
2 changes: 2 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.kube,target=/home/vscode/.kube/,type=bind,consistency=cached", // support for SSH keys
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/vscode/.ssh/,type=bind,consistency=cached", // support for SSH keys
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.envrc,target=/home/vscode/.envrc,type=bind,consistency=cached", // envrc from home to allow direnv to mount credentials
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.thy,target=/home/vscode/.thy/,type=bind,consistency=cached", // support for dsv-cli filestore based store
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.dsv.yml,target=/home/vscode/.dsv.yml/,type=bind,consistency=cached", // mounting for dsv-config
// cache gopath directory
"source=go-path,target=/home/vscode/go/,type=volume"
],
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/init
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
touch "$HOME/.envrc" && echo "$HOME/.envrc initialized"
mkdir "$HOME/.ssh" || echo "✅ .ssh dir already exists"
mkdir "$HOME/.kube" || echo "✅ .kube dir already exists"
mkdir "$HOME/.thy" || echo "✅ .thy dir already exists"
echo '✅ prep.sh setup complete'
2 changes: 1 addition & 1 deletion .devcontainer/init.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "New-Item (Join-Path $ENV:USERPROFILE '.ssh') -ItemType Directory -EA 0; New-Item (Join-Path $ENV:USERPROFILE '.envrc') -ItemType File -EA 0; New-Item (Join-Path $ENV:USERPROFILE '.kube') -ItemType Directory -EA 0;"
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "New-Item (Join-Path $ENV:USERPROFILE '.ssh') -ItemType Directory -EA 0; New-Item (Join-Path $ENV:USERPROFILE '.envrc') -ItemType File -EA 0; New-Item (Join-Path $ENV:USERPROFILE '.kube') -ItemType Directory -EA 0;New-Item (Join-Path $ENV:USERPROFILE '.thy') -ItemType Directory -EA 0; New-Item (Join-Path $ENV:USERPROFILE '.dsv.yml') -ItemType File -EA 0"
echo '✅ prep setup complete'
6 changes: 6 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
export PATH="${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin:$PATH" # for those using aqua this will ensure it's in the path
export DIRENV_LOG_FORMAT=""
export DIRENV_WARN_TIMEOUT='10s'
dotenv_if_exists "${HOME}/.env"
source_env_if_exists "${HOME}/.envrc"
export PATH="${GOPATH}/bin:${PATH}"
export MAGEFILE_ENABLE_COLOR=1
export MAGEFILE_HASHFAST=1

# friendly helpers for devs

alias tcc='trunk check --ci'
1 change: 1 addition & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ lint:
paths:
- .devcontainer/init
- vendor/*
- '**/*/mage_output_file.go'
- linters: [yamllint]
paths:
- .changes/unreleased/*.yaml
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ An automation tool for the management of credentials for applications, databases
- Curl (requires Go installed):

```shell
go install github.com/mikefarah/yq/v4@latest
version=$(curl -sb -H "Accept: application/json" https://s3.amazonaws.com/dsv.secretsvaultcloud.com/cli-version.json | $(go env GOPATH)/bin/yq '.latest')
echo "version: $version"
curl -fSsl https://dsv.secretsvaultcloud.com/downloads/cli/$version/dsv-darwin-x64 -o dsv && chmod +x ./dsv && sudo mv ./dsv /usr/local/bin
Expand Down
4 changes: 3 additions & 1 deletion aqua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://aquaproj.github.io/
registries:
- type: standard
ref: v3.118.0 # renovate: depName=aquaproj/aqua-registry
ref: v3.120.0 # renovate: depName=aquaproj/aqua-registry
packages:
- name: miniscruff/changie@v1.10.2
tags: ['ci']
Expand Down Expand Up @@ -38,3 +38,5 @@ packages:
- name: charmbracelet/gum@v0.8.0
- name: DelineaXPM/dsv-cli@v1.39.13
tags: ['ci']
- name: sharkdp/hyperfine@v1.15.0
- name: mikefarah/yq@v4.30.6
12 changes: 12 additions & 0 deletions magefiles/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ func Init() error {
}
pterm.Success.Println("snapcraft installed")
}
// Aqua install is run in devcontainer/codespace automatically.
// If this environment isn't being used, try to jump start, but if failure, output warning and let the developer choose if they want to go install or not.
if err := sh.RunV("aqua", "install"); err != nil {
pterm.Warning.Printfln("aqua install not successful.\n" +
"This is optional, but will ensure every tool for the project is installed and matching version." +
"To install see developer docs or go to https://aquaproj.github.io/docs/reference/install")
}
pterm.Success.Printfln("Init() completed [%s]\n", relTime(start))
return nil
}
Expand All @@ -145,3 +152,8 @@ func InstallTrunk() error {

return nil
}

// TrunkInit ensures the required runtimes are installed.
func TrunkInit() error {
return sh.RunV("trunk", "install")
}

0 comments on commit 170219b

Please sign in to comment.