Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Latest commit

 

History

History
38 lines (29 loc) · 1.71 KB

README.md

File metadata and controls

38 lines (29 loc) · 1.71 KB

vaultapi

A Go vault client for the rest of us.

Go Report Card Build Status GoDoc License

About

vaultapi is a vault client library for Go programs, targeted at the "99% use case". What this means is that while an official Go client provided by Hashicorp exists and exposes the complete functionality of vault, it is often difficult to use and is extremely inconvenient to work with in test cases. This vault library for Go aims to be easily mockable while providing interfaces that are easy to work with.

Install

Like any Go library, just use go get to install. If the Go team ever officially blesses a package manager, this library will incorporate that.

go get github.com/shoenig/vaultapi

Usage

Creating a vault Client is very simple, just call New with the desired ClientOptions.

tracer := log.New(os.Stdout, "vaultapi-", log.LstdFlags)
options := vaultapi.ClientOptions{
    Servers: []string{"https://localhost:8200"},
    HTTPTimeout: 10 * time.Second, // default
    SkipTLSVerification: false, // default
    Logger: tracer,
}

tokener := vaultapi.NewStaticToken("abcdefgh-abcd-abcd-abcdefgh")
client, err := vaultapi.New(options, tokener)
// client implements the vaultapi.Client interface

leader, err := client.Leader()
// etc ...