vault

package module
v0.0.0-...-6788ec8 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2018 License: Apache-2.0 Imports: 7 Imported by: 5

README

Vault Client

This is a striaght forward vault client for golang, it expects envirnoment variables:

  • VAULT_ADDR the URL to the vault server (e.g., https://vault.example.com)
  • VAULT_TOKEN The token to use for vault.
  • VAULT_ROLEID and VAULT_SECRETID if VAULT_TOKEN is not set as an alternative to tokens.

Install

go get https://github.com/akkeris/vault-client

Usage

vault.GetField(path string, field string) string

vault.GetSecret(path string) VaultSecret

vault.GetFieldFromVaultSecret(secret VaultSecret, field string) string

type VaultField struct {
	Key   string
	Value string
}

type VaultSecret struct {
	Fields []VaultField
}

Example

package main

import (
   vault "github.com/akkeris/vault-client"
   "fmt"
)
  
func main() {
    username := vault.GetField("secret/dev/db/somefield", "username")
    fmt.Println(username)
    secret := vault.GetSecret("secret/dev/db/somefield")
    for _, element := range secret.Fields {
       fmt.Println(element.Key+"="+element.Value)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetField

func GetField(path string, field string) string

func GetFieldFromVaultSecret

func GetFieldFromVaultSecret(secret VaultSecret, field string) string

func ListSecrets

func ListSecrets(path string) ([]string, error)

func WriteField

func WriteField(path string, key string, content string) (e error)

Types

type GenericSecret

type GenericSecret struct {
	X map[string]interface{}
}

type VaultField

type VaultField struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type VaultList

type VaultList struct {
	LeaseID       string `json:"lease_id"`
	Renewable     bool   `json:"renewable"`
	LeaseDuration int    `json:"lease_duration"`
	Data          struct {
		Keys []string `json:"keys"`
	} `json:"data"`
	Warnings interface{} `json:"warnings"`
	Auth     interface{} `json:"auth"`
}

type VaultSecret

type VaultSecret struct {
	Fields []VaultField
}

func GetSecret

func GetSecret(path string) VaultSecret

Jump to

Keyboard shortcuts

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