libvault

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

lib-vault

This lib provides some methods to deal with vault's (kv v1 or v2) golang client

How it works

Create new client, the creation depends on existing of either VAULT_TOKEN environment variable or .vault-token file in your home directory

client, err := CreateClient()

Read secret (kv v1), returns the secret value

client.ReadSecret("path", "field")

Get secret (kv v1), returns the secret (map[string]interface{})

client.GetSecret("path")

List secret paths (kv v1), returns absolute secret path from base path.

client.ListSecretPath("basepath")

example:

client.ListSecretPath("secret/foo/bar")

 secret/foo/bar/foo1
 secret/foo/bar/foo2
 secret/foo/bar/foo3
 secret/foo/bar/foo4
 secret/foo/bar/foo5
 ...

Read secret (kv v2), returns the secret value

client.ReadSecretKvV2("path", "field")

Get secret (kv v2), returns the secret (map[string]interface{})

client.GetSecretKvV2("path")

List secret paths (kv v2), returns absolute secret path from base path.

client.ListSecretPathKvV2("basepath")

example:

client.ListSecretPathKvV2("secret/foo/bar")

 secret/foo/bar/foo1
 secret/foo/bar/foo2
 secret/foo/bar/foo3
 secret/foo/bar/foo4
 secret/foo/bar/foo5
 ...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type VaultClient

type VaultClient struct {
	// contains filtered or unexported fields
}

func CreateClient

func CreateClient() (*VaultClient, error)

func (*VaultClient) GetSecret added in v1.1.0

func (vc *VaultClient) GetSecret(path string) (map[string]interface{}, error)

func (*VaultClient) GetSecretKvV2 added in v1.1.0

func (vc *VaultClient) GetSecretKvV2(path string) (map[string]interface{}, error)

func (*VaultClient) ListSecretPath added in v1.0.0

func (vc *VaultClient) ListSecretPath(path string) ([]string, error)

func (*VaultClient) ListSecretPathKvV2 added in v1.0.0

func (vc *VaultClient) ListSecretPathKvV2(path string) ([]string, error)

func (*VaultClient) ReadSecret

func (vc *VaultClient) ReadSecret(path string, field string) (string, error)

func (*VaultClient) ReadSecretKvV2 added in v1.0.0

func (vc *VaultClient) ReadSecretKvV2(path string, field string) (string, error)

Jump to

Keyboard shortcuts

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