Giter VIP home page Giter VIP logo

secrethub-go's Introduction


1Password SecretHub has joined 1Password! Find out more on the SecretHub blog. ๐ŸŽ‰


SecretHub

Go Client

GoDoc CircleCI Go Report Card Version Discord

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.

Gopher

Usage

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.

Examples

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

Below are a few simple examples:

Read Secrets

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$
}

Write Secrets

package main

import (
    "fmt"

    "github.com/secrethub/secrethub-go/pkg/secrethub"
)

func main() {
    client, _ := secrethub.NewClient()
    _, _ = client.Secrets().Write("path/to/secret", []byte("password123"))
}

Generate Secrets

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)
}

Credential

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.

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

If you get stuck or just want advice, come chat with the engineers on Discord or send an email to [email protected]

Attributions

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

secrethub-go's People

Contributors

bender-sh avatar edif2008 avatar florisvdg avatar hculea avatar jpcoenen avatar mackenbach avatar marczwalua avatar marton6 avatar simonbarendse avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.