forked from feniix/asdf-sops
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
189 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[*] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Main workflow | ||
|
||
on: | ||
pull_request: | ||
push: | ||
schedule: | ||
- cron: 0 0 * * 5 | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- macos-latest | ||
- ubuntu-latest | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: jdx/mise-action@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
cache: false | ||
- run: mkdir -p ~/.local/share/mise/plugins | ||
- run: ln -s $PWD ~/.local/share/mise/plugins/sops | ||
- run: mise i sops@latest | ||
- run: mise x sops@latest -- sops --version | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Homebrew | ||
id: set-up-homebrew | ||
uses: Homebrew/actions/setup-homebrew@master | ||
|
||
- name: Install ShellCheck | ||
run: brew install shellcheck | ||
|
||
- name: Run ShellCheck | ||
run: make lint | ||
|
||
format: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Homebrew | ||
id: set-up-homebrew | ||
uses: Homebrew/actions/setup-homebrew@master | ||
|
||
- name: Install shfmt | ||
run: brew update && brew install shfmt | ||
|
||
- name: Run shfmt | ||
run: make format-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
external-sources=true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
SH_SRCFILES = $(shell git ls-files "bin/*") | ||
SHFMT_BASE_FLAGS = -i 2 -ci | ||
|
||
fmt: | ||
shfmt -w $(SHFMT_BASE_FLAGS) $(SH_SRCFILES) | ||
.PHONY: fmt | ||
|
||
format-check: | ||
shfmt -d $(SHFMT_BASE_FLAGS) $(SH_SRCFILES) | ||
.PHONY: format-check | ||
|
||
lint: | ||
shellcheck $(SH_SRCFILES) | ||
.PHONY: lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
# asdf-sops | ||
[![Build Status](https://travis-ci.org/feniix/asdf-sops.svg?branch=master)](https://travis-ci.org/feniix/asdf-sops) | ||
# mise-sops | ||
|
||
[Sops](https://github.com/mozilla/sops) plugin for the [asdf](https://github.com/asdf-vm/asdf) version manager. | ||
[Sops](https://github.com/mozilla/sops) plugin for the | ||
[Mise](https://github.com/jdx/mise) version manager. | ||
|
||
## Install | ||
|
||
``` | ||
asdf plugin-add sops https://github.com/feniix/asdf-sops.git | ||
sops plugin-add sops https://github.com/joshbode/mise-sops.git | ||
``` | ||
|
||
## Use | ||
## Environment Activation | ||
|
||
Check out the [asdf](https://github.com/asdf-vm/asdf) readme for instructions. | ||
Automatically activate the SOPS environment when entering the directory with the | ||
following `.mise.toml`: | ||
|
||
```toml | ||
[tools] | ||
sops = { version = "latest", filename = ".sops.env" } | ||
``` | ||
|
||
## License | ||
|
||
Licensed under the | ||
[MIT license](https://github.com/joshbode/mise-sops/blob/main/LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# shellcheck source-path=. | ||
source "${MISE_PLUGIN_PATH}/bin/utils.sh" | ||
|
||
# shellcheck disable=SC1090 | ||
source <(sops_env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
#!/usr/bin/env bash | ||
#! /usr/bin/env bash | ||
|
||
releases_path=https://api.github.com/repos/getsops/sops/releases | ||
cmd="curl -s" | ||
if [ -n "$GITHUB_API_TOKEN" ]; then | ||
cmd="$cmd -H 'Authorization: token $GITHUB_API_TOKEN'" | ||
fi | ||
set -euo pipefail | ||
|
||
RELEASES_PATH=https://api.github.com/repos/getsops/sops/releases | ||
|
||
cmd="$cmd $releases_path" | ||
if [[ -n ${GITHUB_API_TOKEN-} ]]; then | ||
set -- "$@" -H "Authorization: token ${GITHUB_API_TOKEN}" | ||
fi | ||
|
||
function sort_versions() { | ||
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | \ | ||
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | | ||
LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}' | ||
} | ||
|
||
# stripping off the 'v' prefix as it causes issues with 'asdf install foo latest' | ||
echo $(eval "$cmd" | grep -oE "tag_name\": \".{1,15}\"," | grep -v "2.0.10" | sed 's/tag_name": "//; s/^v//; s/",//' | sort_versions) | ||
|
||
# stripping off the 'v' prefix as it causes issues with 'mise install foo latest' | ||
curl -qsSL "$@" "${RELEASES_PATH}" | | ||
grep -oE "tag_name\": \".{1,15}\"," | | ||
grep -v "2.0.10" | | ||
sed 's/tag_name": "//; s/^v//; s/",//' | | ||
sort_versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#! /usr/bin/env bash | ||
|
||
if [ "${MISE_TRACE-}" = "1" ]; then | ||
set -x | ||
fi | ||
|
||
echoerr() { | ||
echo "$1" >&2 | ||
} | ||
|
||
sops_bin() { | ||
echo "$MISE_INSTALL_PATH/bin/sops" | ||
} | ||
|
||
sops_env() { | ||
local filename | ||
filename=$(eval "printf '%s' '${MISE_TOOL_OPTS__FILENAME-}'") | ||
if [[ -z ${filename} ]]; then | ||
echoerr "mise-sops: No filename provided." | ||
return 1 | ||
fi | ||
if [[ ${filename} != /* ]] && [[ -n ${MISE_PROJECT_ROOT-} ]]; then | ||
filename="${MISE_PROJECT_ROOT-}/${filename}" | ||
fi | ||
if [[ ! -f ${filename} ]]; then | ||
echoerr "mise-sops: Filename '${filename}' not found." | ||
return 1 | ||
fi | ||
"$(sops_bin)" -d "${filename}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[exec-env] | ||
cache-key = [ | ||
""" | ||
{% if project_root %} | ||
{{ project_root | canonicalize }} | ||
{% endif %} | ||
""", | ||
""" | ||
{% if opts.filename %} | ||
{{ opts.filename }} | ||
{% endif %} | ||
""" | ||
] | ||
|
||
[list-bin-paths] | ||
cache-key = [ | ||
""" | ||
{% if project_root %} | ||
{{ project_root | canonicalize }} | ||
{% endif %} | ||
""", | ||
""" | ||
{% if opts.filename %} | ||
{{ opts.filename }} | ||
{% endif %} | ||
""" | ||
] |