secrets

package
v1.186.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 15 Imported by: 2

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)

ChangeHook is a function called when a secret changes.

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 read it will return the latest available version of the secret.

func NewStaticValue added in v1.97.0

func NewStaticValue(value string) *Value

NewStaticValue creates a value from a static string that never updates.

func NewStaticValueBytes added in v1.97.0

func NewStaticValueBytes(value []byte) *Value

NewStaticValue creates a value from a static byte slice that never updates.

func NewStaticValueJSON added in v1.97.0

func NewStaticValueJSON(src interface{}) (*Value, error)

NewStaticValue creates a value from a static JSON serialized struct that never updates.

func NewValue

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

NewValue creates a new secret accessor that auto-updates in the background.

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