Documentation
¶
Index ¶
- Constants
- Variables
- type APIClient
- type APIClientImpl
- type Client
- func CreateClient(token, vaultAddress string, retries int) (*Client, error)
- func CreateClientTLS(token, vaultAddress string, retries int, cacert, cert, key string) (*Client, error)
- func CreateClientWithAPIClient(apiClient APIClient) *Client
- func CreateClientWithConfig(config *vaultapi.Config, token string) (*Client, error)
- func (c *Client) Checker(ctx context.Context, state *health.CheckState) error
- func (c *Client) Healthcheck() (string, error)
- func (c *Client) Read(path string) (map[string]interface{}, error)
- func (c *Client) ReadKey(path, key string) (string, error)
- func (c *Client) VRead(path string) (map[string]interface{}, int64, error)
- func (c *Client) VReadKey(path, key string) (string, int64, error)
- func (c *Client) VWriteKey(path, key, value string) error
- func (c *Client) Write(path string, data map[string]interface{}) error
- func (c *Client) WriteKey(path, key, value string) error
Constants ¶
const MsgHealthy = "vault is healthy"
MsgHealthy Check message returned when vault is healthy
const ServiceName = "vault"
ServiceName vault
Variables ¶
var ( ErrKeyNotFound = errors.New("key not found") ErrVersionNotFound = errors.New("version not found") ErrMetadataNotFound = errors.New("metadata not found") ErrDataNotFound = errors.New("data not found") ErrVersionInvalid = errors.New("version failed to convert to number") )
Error definitions
var (
ErrNotInitialised = errors.New("vault not initialised")
)
Error definitions
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient interface { SetToken(v string) Read(path string) (*vaultapi.Secret, error) Write(path string, data map[string]interface{}) (*vaultapi.Secret, error) Health() (*vaultapi.HealthResponse, error) }
APIClient is an interface to wrap Vault API Client, which is used by the dp-vault Client in order to interact with Vault, and can be easily mocked for testing
type APIClientImpl ¶
type APIClientImpl struct {
// contains filtered or unexported fields
}
APIClientImpl implements the APIClient interface wrapping the real vault API client calls to nested clients (e.g Logical or Sys)
func (*APIClientImpl) Health ¶
func (api *APIClientImpl) Health() (*vaultapi.HealthResponse, error)
Health calls Health() from the Sys client in vault API client
func (*APIClientImpl) Read ¶
func (api *APIClientImpl) Read(path string) (*vaultapi.Secret, error)
Read calls Read(path) from the Logical client in vault API client
func (*APIClientImpl) SetToken ¶
func (api *APIClientImpl) SetToken(v string)
SetToken calls SetToken directly to vault API client
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client Used to read and write secrets from vault using a vault API client wrapper.
func CreateClient ¶
CreateClient by providing an auth token, vault address and the maximum number of retries for a request
func CreateClientTLS ¶
func CreateClientTLS(token, vaultAddress string, retries int, cacert, cert, key string) (*Client, error)
CreateClientTLS is like the CreateClient function but wraps the HTTP client with TLS
func CreateClientWithAPIClient ¶
CreateClientWithAPIClient creates a Client with a provided Vault API client as input
func CreateClientWithConfig ¶
CreateClientWithConfig creates a Client with provided config and token as inputs
func (*Client) Checker ¶
Checker performs a check health of Vault and updates the provided CheckState accordingly
func (*Client) Healthcheck ¶
Healthcheck determines the state of vault
func (*Client) Read ¶
Read reads a secret from vault. If the token does not have the correct policy this returns an error; if the vault server is not reachable, return all the information stored about the secret.
func (*Client) ReadKey ¶
ReadKey from vault. Like read but only return a single value from the secret
func (*Client) VRead ¶
VRead reads a versioned secret from vault - cf Read, above - returns the secret (map) and the version
func (*Client) VReadKey ¶
VReadKey - cf Read but for versioned secret - return the value of the key and the version
func (*Client) VWriteKey ¶
VWriteKey creates a data map, with a data field containing the key-value, and writes it to vault