secrets

package
v0.0.0-...-6dcaeb9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSecretsResolver

func NewSecretsResolver(logger Logger, secretsTracker SecretStateTracker,
	rotatedSecrets func(string), expiredRevisions func(string), deletedSecrets func([]string),
) resolver.Resolver

NewSecretsResolver returns a new Resolver that returns operations to rotate, expire, or run other secret related hooks.

func NewStateOps

func NewStateOps(rw UnitStateReadWriter) *stateOps

NewStateOps returns a new StateOps.

Types

type Logger

type Logger interface {
	Warningf(string, ...interface{})
	Debugf(string, ...interface{})
}

Logger represents the logging methods used in this package.

type SecretStateTracker

type SecretStateTracker interface {
	// PrepareHook returns an error if the hook is unknown
	// or invalid given current state.
	PrepareHook(hook.Info) error

	// CommitHook persists the state change encoded in the supplied secret
	// hook, or returns an error if the hook is unknown or invalid given
	// current secret state.
	CommitHook(info hook.Info) error

	// ConsumedSecretRevision returns the revision that
	// is currently tracked for the given secret.
	ConsumedSecretRevision(uri string) int

	// SecretObsoleteRevisions returns the obsolete
	// revisions that have been reported already for
	// the given secret.
	SecretObsoleteRevisions(uri string) []int

	// SecretsRemoved updates the unit secrets state
	// when secrets are removed.
	SecretsRemoved(uris []string) error

	// Report provides information for the engine report.
	Report() map[string]interface{}
}

SecretStateTracker provides access to the unit agent's state for secrets.

func NewSecrets

func NewSecrets(
	client SecretsClient,
	tag names.UnitTag,
	rw UnitStateReadWriter,
	logger Logger,
) (SecretStateTracker, error)

NewSecrets returns a new secrets tracker.

type Secrets

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

Secrets generates storage hooks in response to changes to storage Secrets, and provides access to information about storage Secrets to hooks.

func (*Secrets) CommitHook

func (s *Secrets) CommitHook(hi hook.Info) error

CommitHook implements SecretStateTracker.

func (*Secrets) ConsumedSecretRevision

func (s *Secrets) ConsumedSecretRevision(uri string) int

ConsumedSecretRevision implements SecretStateTracker.

func (*Secrets) PrepareHook

func (s *Secrets) PrepareHook(hi hook.Info) error

PrepareHook implements SecretStateTracker.

func (*Secrets) Report

func (s *Secrets) Report() map[string]interface{}

Report provides information for the engine report.

func (*Secrets) SecretObsoleteRevisions

func (s *Secrets) SecretObsoleteRevisions(uri string) []int

SecretObsoleteRevisions implements SecretStateTracker.

func (*Secrets) SecretsRemoved

func (s *Secrets) SecretsRemoved(uris []string) error

SecretsRemoved implements SecretStateTracker.

type SecretsClient

type SecretsClient interface {
	remotestate.SecretsClient
	SecretMetadata() ([]coresecrets.SecretOwnerMetadata, error)
}

SecretsClient is used by the secrets tracker to access the Juju model.

type State

type State struct {
	// ConsumedSecretInfo stores the last seen revision for each secret - it's
	// used to determine if we need to run secret-changed.
	ConsumedSecretInfo map[string]int `yaml:"secret-revisions,omitempty"`

	// SecretObsoleteRevisions stores the revisions for which the secret-remove
	// hook has already been run for a given secret.
	SecretObsoleteRevisions map[string][]int `yaml:"secret-obsolete-revisions,omitempty"`
}

State describes the state relating to secrets.

func NewState

func NewState() *State

NewState returns an initial State.

func (*State) UnmarshalYAML

func (s *State) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

func (*State) UpdateStateForHook

func (s *State) UpdateStateForHook(info hook.Info)

UpdateStateForHook updates the current secrets state with changes in hi. It must be called after the respective hook was executed successfully. UpdateStateForHook doesn't validate hi but guarantees that successive changes of the same hi are idempotent.

type UnitStateReadWriter

type UnitStateReadWriter interface {
	State() (params.UnitStateResult, error)
	SetState(unitState params.SetUnitStateArg) error
}

UnitStateReadWriter encapsulates the methods from a state.Unit required to set and get unit state.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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