Documentation ¶
Index ¶
- func NewSecretsResolver(logger Logger, secretsTracker SecretStateTracker, rotatedSecrets func(string), ...) resolver.Resolver
- func NewStateOps(rw UnitStateReadWriter) *stateOps
- type Logger
- type SecretStateTracker
- type Secrets
- func (s *Secrets) CommitHook(hi hook.Info) error
- func (s *Secrets) ConsumedSecretRevision(uri string) int
- func (s *Secrets) PrepareHook(hi hook.Info) error
- func (s *Secrets) Report() map[string]interface{}
- func (s *Secrets) SecretObsoleteRevisions(uri string) []int
- func (s *Secrets) SecretsRemoved(uris []string) error
- type SecretsClient
- type State
- type UnitStateReadWriter
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 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 ¶
CommitHook implements SecretStateTracker.
func (*Secrets) ConsumedSecretRevision ¶
ConsumedSecretRevision implements SecretStateTracker.
func (*Secrets) PrepareHook ¶
PrepareHook implements SecretStateTracker.
func (*Secrets) SecretObsoleteRevisions ¶
SecretObsoleteRevisions implements SecretStateTracker.
func (*Secrets) SecretsRemoved ¶
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 (*State) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
func (*State) UpdateStateForHook ¶
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.