secretmanager

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package secretmanager loads configuration from GCP Secret Manager.

It requires following roles on the target project:

  • roles/secretmanager.viewer

Change notification

By default, it periodically polls the configuration only. It also listens to change events by register it to PubSub notifier with Set up notifications on a secret.

Only following events trigger polling the configuration and other type of events are ignored:

  • SECRET_VERSION_ADD
  • SECRET_VERSION_ENABLE
  • SECRET_VERSION_DISABLE
  • SECRET_VERSION_DESTROY

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option = option.ClientOption

func WithFilter

func WithFilter(filter string) Option

WithFilter provides [filter] that will be used to select a set of secrets.

[filter]: // https://cloud.google.com/secret-manager/docs/filtering

func WithNameSplitter

func WithNameSplitter(splitter func(string) []string) Option

WithNameSplitter provides the function used to split secret names into nested keys. If it returns an nil/[]string{}/[]string{""}, the secret will be ignored.

For example, with the default splitter, an secret name like "PARENT-CHILD-KEY" would be split into "PARENT", "CHILD", and "KEY".

func WithPollInterval

func WithPollInterval(interval time.Duration) Option

WithPollInterval provides the interval for polling the configuration.

The default interval is 1 minute.

func WithProject

func WithProject(project string) Option

WithProject provides GCP project ID.

By default, it fetches project ID from metadata server.

type SecretManager

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

SecretManager is a Provider that loads configuration from GCP Secret Manager.

To create a new SecretManager, call New.

func New

func New(opts ...Option) *SecretManager

New creates a SecretManager with the given endpoint and Option(s).

func (*SecretManager) Load

func (m *SecretManager) Load() (map[string]any, error)

func (*SecretManager) OnEvent added in v1.1.0

func (m *SecretManager) OnEvent(attributes map[string]string) error

func (*SecretManager) Status added in v0.8.0

func (m *SecretManager) Status(onStatus func(bool, error))

func (*SecretManager) String

func (m *SecretManager) String() string

func (*SecretManager) Watch

func (m *SecretManager) Watch(ctx context.Context, onChange func(map[string]any)) error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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