secrethub-go

module
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2019 License: Apache-2.0

README

SecretHub

Go Client

GoDoc CircleCI GolangCI Go Report Card Version Discord

secrethub-go provides a client for various SecretHub APIs.

SecretHub is a developer tool to help you keep database passwords, API tokens, and other secrets out of IT automation scripts.

Gopher

Getting started

Installation

Install secrethub-go with:

go get -u github.com/secrethub/secrethub-go

Or install a specific version with:

go get -u github.com/secrethub/secrethub-go@vX.Y.Z

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.

Examples

For details on all functionality of this library, see the GoDoc documentation.

Below are a few simple examples:

import (
	"github.com/secrethub/secrethub-go/pkg/randchar"
	"github.com/secrethub/secrethub-go/pkg/secrethub"
)

// Setup
credential, err := secrethub.NewCredential("<your credential>", "<passphrase>")
client := secrethub.NewClient(credential, nil)

// Write
secret, err := client.Secrets().Write("path/to/secret", []byte("password123"))

// Read
secret, err = client.Secrets().Versions().GetWithData("path/to/secret:latest")
fmt.Println(secret.Data) // prints password123

// Generate a slice of 32 alphanumeric characters.
data, err := randchar.NewGenerator(false).Generate(32)
secret, err = client.Secrets().Write("path/to/secret", data)

Note: 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.

Development

Pull requests from the community are welcome. If you'd like to contribute, please checkout the contributing guidelines.

Testing

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.

Getting help

Come chat with us on Discord or email us at support@secrethub.io

Attributions

"gopher.png" by Takuya Ueda is licensed under CC BY 3.0

Directories

Path Synopsis
internals
api
api/uuid
Package uuid is a utility package to standardize and abstract away how UUIDs are generated and used.
Package uuid is a utility package to standardize and abstract away how UUIDs are generated and used.
aws
errio
Package errio contains custom error types to easily transfer errors between applications and output them to the user in a consistent way.
Package errio contains custom error types to easily transfer errors between applications and output them to the user in a consistent way.
pkg
randchar
Package randchar helps to generate random sequences of characters from a configured character set, which can be useful for e.g.
Package randchar helps to generate random sequences of characters from a configured character set, which can be useful for e.g.
secrethub/configdir
Package configdir provides simple functions to manage the SecretHub configuration directory.
Package configdir provides simple functions to manage the SecretHub configuration directory.
secrethub/credentials
Package credentials provides utilities for managing SecretHub API credentials.
Package credentials provides utilities for managing SecretHub API credentials.
secretpath
Package secretpath implements utility functions for manipulating paths compatible with SecretHub, e.g.
Package secretpath implements utility functions for manipulating paths compatible with SecretHub, e.g.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL