Skip to content

Commit

Permalink
refactor: refactor downloader
Browse files Browse the repository at this point in the history
Refactor as a subcommand in order to support :
- remote files
- all secrets drivers (sops, vault, ...)
  • Loading branch information
jBouyoud committed Nov 4, 2020
1 parent a9c3760 commit 4dfd707
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Check [README.md](README.md#installation-on-helm-2)
### Added
- Implement alternate syntax (https://github.com/jkroepke/helm-secrets/pull/52)
- Remote values support (supporting http:// and helm downloader plugins) (https://github.com/jkroepke/helm-secrets/pull/54)
- Let downloader plugin supports remote files and all secrets drivers (https://github.com/jkroepke/helm-secrets/pull/55)

## [3.3.5] - 2020-10-16

Expand Down
10 changes: 9 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,15 @@ kind: Deployment
Helm supports [downloader plugin](https://helm.sh/docs/topics/plugins/#downloader-plugins) for value files, too.

```
helm upgrade . -f sops://<path to file>
helm upgrade . -f secrets://<uri to file>
helm upgrade . -f secret://<uri to file>
helm upgrade . -f sops://<uri to file>
```

Example:
```
helm upgrade . -f secrets://localfile.yaml
helm upgrade . -f secrets://git+https://github.com/jkroepke/helm-secrets@tests/assets/values/sops/secrets.yaml?ref=master
```

# Important Tips
Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ platformCommand:
command: "cmd /c $HELM_PLUGIN_DIR/scripts/wrapper/sh.cmd $HELM_PLUGIN_DIR/scripts/run.sh"

downloaders:
- command: "scripts/downloader.sh"
- command: "scripts/run.sh downloader"
protocols:
- "sops"
- "secret"
Expand Down
14 changes: 14 additions & 0 deletions scripts/commands/downloader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env sh

set -eu

# shellcheck source=scripts/commands/view.sh
. "${SCRIPT_DIR}/commands/view.sh"

downloader() {
# https://helm.sh/docs/topics/plugins/#downloader-plugins
# It's always the 4th parameter
file=$(printf '%s' "${4}" | sed -e 's!(sops|secrets?)://!!')

view_helper "${file}"
}
7 changes: 0 additions & 7 deletions scripts/downloader.sh

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ while true; do
clean "$2"
break
;;
downloader)
# shellcheck source=scripts/commands/downloader.sh
. "${SCRIPT_DIR}/commands/downloader.sh"

downloader "$2" "$3" "$4" "$5"
break
;;
--help | -h | help)
usage
break
Expand Down

0 comments on commit 4dfd707

Please sign in to comment.