secrets

package module
v0.0.0-...-39889fe Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 14 Imported by: 0

README

secrets

Access Google Secret Manager secrets.

Documentation

Overview

Package secrets give access to Google Secret Manager secrets easily and keeping the values updated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(ctx context.Context, name string) (string, error)

Read a secret and return its value. Multiple reads of the same secret will return a cached version.

func ReadBytes

func ReadBytes(ctx context.Context, name string) ([]byte, error)

ReadBytes reads a secret as a slice of bytes. Multiple reads of the same secret will return a cached version.

func ReadJSON

func ReadJSON(ctx context.Context, name string, dest interface{}) error

ReadJSON reads a secrets and fills a JSON structure with it. Multiple reads of the same secret will return a cached version.

Types

type ChangeHook

type ChangeHook func(val *Value)

type Value

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

Value is a secret accesor that will keep its own value updated in background. When accessed it will return the latest available version of the secret.

func NewValue

func NewValue(ctx context.Context, name string) (*Value, error)

NewValue creates a new secret accessor.

func (*Value) Bytes

func (val *Value) Bytes() []byte

String gets the current value of the secret as a slice of bytes.

func (*Value) JSON

func (val *Value) JSON(dest interface{}) error

String gets the current value of the secret and fills a JSON structure.

func (*Value) OnChange

func (val *Value) OnChange(hook ChangeHook)

OnChange registers a hook to be called when a value change is detected. In the hook you can update clients or other actions the application needs.

func (*Value) String

func (val *Value) String() string

String gets the current value of the secret as a string.

Jump to

Keyboard shortcuts

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