Quick recap for those joining late. Spelunk started as
a Go library to fetch secrets from any Source using a URI-like Coordinates system (intro). Then I added support for various cloud Secret Managers and a heap of Modifiers (v1.2.0 + v1.3.0). And after that I tore the repo apart into isolated modules/plugins, so you would only compile the third-party SDKs you actually needed (v2.0.0).
And now, time to tick another box!
Spelunk is a CLI now 💲
I ended the very first post with a little TODO list, and one of the points was: “Build a spelunk binary, so to embed it in shell scripts”. That’s
what v2.2.* is about:
| |
But what it is really made for, is embedding it into your scripts:
| |
The secrets are printed to STDOUT. And if you need to, increase log verbosity with one or more -v (STDERR).
Pipe | it wherever you need: I purposely made it as POSIX friendly as I could.
Features 🤩
It bundles almost every Source that Spelunk offers (aws://, az://, gcp://, vault://, k8s://, op://, kp://, plus the built-ins) and every Modifier (?jp=, ?yp=, ?tp=, ?xp=, ?b64*).
It auto-discovers credentials, by looking up idiomatic environment variables and the configuration files that providers usually expect. And if you need to set them explicitly:
| |
It automagically adapts to the credentials it detects: the rest is politely ignored. But if you need to know what credentials it found:
| |
Check out the CLI README, or go straight for spelunk --help. It is built on the superb alecthomas/kong, and so the usage instructions are extra nice.
Wait, why “almost” every Source? 🤨
Well, this is embarrassing.
You might have noticed that I apparently jumped from v2.0.x, to v2.2.x. I didn’t. I actually released v2.1.x, but I had not realised that it wouldn’t run on Windows. The binary required CGO to be built, because of the dependency on bitwarden/sdk-go for the bw:// Source. This caused me 2 issues:
- It required running 3 different
goreleaserGitHub Workflows: a different runner per-OS, and a convoluted process to converge into a single release 😒 - It (somehow) has a runtime dependency on a Bitwarden platform-specific native library on Windows, so it didn’t actually run there 🧨
So, I decided that for now Spelunk CLI was good enough without Bitwarden. This allowed me to compile it without CGO, simplify the goreleaser process, and ship a fixed v2.2.x.
The Bitwarden plugin is still fully supported if you use Spelunk as a library. It just doesn’t get to ride in the CLI. Yet.
Installation, 4 ways 🖖
I provide statically linked binaries for OS=linux|darwin|windows and ARCH=amd64|arm64. They can be installed via:
- From my Homebrew Tap (
brew install detro/tap/spelunk) - Downloading the right pre-compiled binaries for your system
- Compiled via
go install github.com/detro/spelunk/cmd/spelunk@latest - Or by compiling a
git clone https://github.com/detro/spelunk.git
Just head over here to get started.
And it comes with improvements too 🛠
- JSONPath support is now built on
ohler55/ojg, replacing an unmaintained dependency - Every module
go.modhas been improved by declaring the lowest Go version it actually needs to be built, so nobody is forced to upgrade their toolchain because of me - Additional tests around the
jp,ypandtpextractors
Everything is in the CHANGELOG (of course!). And the very latest release is currently v2.2.1.
Time to grab your pickaxe again, brew install, and go dig up some secrets from your terminal!