SecretHub has joined 1Password! Find out more on the SecretHub blog. 🎉
secrethub-go
provides a client for various SecretHub APIs.
SecretHub is a secrets management tool that works for every engineer. Securely provision passwords and keys throughout your entire stack with just a few lines of code.
You can install secrethub-go with:
go get github.com/secrethub/secrethub-go
Or install a specific version with:
go get github.com/secrethub/[email protected]
Then, import it using:
import (
"github.com/secrethub/secrethub-go/pkg/secrethub"
)
Note: only packages inside the
/pkg
directory should be considered library code that you can use in your projects. All other code is not guaranteed to be backwards compatible and may change in the future.
For details on all functionality of this library, see the GoDoc documentation.
Below are a few simple examples:
package main
import (
"fmt"
"github.com/secrethub/secrethub-go/pkg/secrethub"
)
func main() {
client, _ := secrethub.NewClient()
secret, _ := client.Secrets().ReadString("path/to/db/pass")
fmt.Println(secret)
// Output: wFc16W#96N1$
}
package main
import (
"fmt"
"github.com/secrethub/secrethub-go/pkg/secrethub"
)
func main() {
client, _ := secrethub.NewClient()
_, _ = client.Secrets().Write("path/to/secret", []byte("password123"))
}
package main
import (
"fmt"
"github.com/secrethub/secrethub-go/pkg/randchar"
"github.com/secrethub/secrethub-go/pkg/secrethub"
)
func main() {
client, _ := secrethub.NewClient()
data, _ := randchar.Generate(30)
_, _ = client.Secrets().Write("path/to/secret", data)
}
To use the SecretHub Go client, you need to provide a credential for your SecretHub account. You can create a free developer account by signing up through the CLI.
After signup, the credential is located at $HOME/.secrethub/credential
by default.
secrethub.NewClient()
automatically uses this credential.
Pull requests from the community are welcome. If you'd like to contribute, please checkout the contributing guidelines.
Run all tests:
make test
Run tests for one package:
go test ./pkg/secrethub
Run a single test:
go test ./pkg/secrethub -run TestSignup
For any requests, bug or comments, please open an issue or submit a pull request.
If you get stuck or just want advice, come chat with the engineers on Discord or send an email to [email protected]
"gopher.png" by Takuya Ueda is licensed under CC BY 3.0