Documentation
¶
Index ¶
- func CreateCredential(ctx context.Context, tx *sqlair.TX, credentialUUID string, ...) error
- func GetCloudCredential(ctx context.Context, st domain.Preparer, tx *sqlair.TX, id corecredential.UUID) (credential.CloudCredentialResult, error)
- type Credential
- type CredentialAttribute
- type Credentials
- type State
- func (st *State) AllCloudCredentialsForOwner(ctx context.Context, owner user.Name) (map[corecredential.Key]credential.CloudCredentialResult, error)
- func (st *State) CloudCredential(ctx context.Context, key corecredential.Key) (credential.CloudCredentialResult, error)
- func (st *State) CloudCredentialsForOwner(ctx context.Context, owner user.Name, cloudName string) (map[string]credential.CloudCredentialResult, error)
- func (st *State) CredentialUUIDForKey(ctx context.Context, key corecredential.Key) (corecredential.UUID, error)
- func (st *State) GetCloudCredential(ctx context.Context, id corecredential.UUID) (credential.CloudCredentialResult, error)
- func (st *State) InvalidateCloudCredential(ctx context.Context, key corecredential.Key, reason string) error
- func (st *State) ModelsUsingCloudCredential(ctx context.Context, key corecredential.Key) (map[coremodel.UUID]string, error)
- func (st *State) RemoveCloudCredential(ctx context.Context, key corecredential.Key) error
- func (st *State) UpsertCloudCredential(ctx context.Context, key corecredential.Key, ...) (*bool, error)
- func (st *State) WatchCredential(ctx context.Context, ...) (watcher.NotifyWatcher, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCredential ¶
func CreateCredential(ctx context.Context, tx *sqlair.TX, credentialUUID string, key corecredential.Key, credential credential.CloudCredentialInfo) error
CreateCredential saves the specified credential. Exported for use in the related credential bootstrap package.
func GetCloudCredential ¶
func GetCloudCredential( ctx context.Context, st domain.Preparer, tx *sqlair.TX, id corecredential.UUID, ) (credential.CloudCredentialResult, error)
GetCloudCredential is responsible for returning a cloud credential identified by id. If no cloud credential exists for the given id then a credentialerrors.NotFound error will be returned.
Types ¶
type Credential ¶
type Credential struct { // ID holds the cloud credential document key. ID string `db:"uuid"` // CloudUUID holds the cloud reference. CloudUUID string `db:"cloud_uuid"` // AuthTypeID holds the auth type reference. AuthTypeID int `db:"auth_type_id"` // Name is the name of the credential. Name string `db:"name"` // Owner is the user who owns the credential. // TODO(wallyworld) - this will be a user reference when users are added. OwnerUUID string `db:"owner_uuid"` // Revoked is true if the credential has been revoked. Revoked bool `db:"revoked"` // Invalid stores flag that indicates if a credential is invalid. // Note that the credential is valid: // * if the flag is explicitly set to 'false'; or // * if the flag is not set at all, as will be the case for // new inserts or credentials created with previous Juju versions. In // this case, we'd still read it as 'false' and the credential validity // will be interpreted correctly. // This flag will need to be explicitly set to 'true' for a credential // to be considered invalid. Invalid bool `db:"invalid"` // InvalidReason contains the reason why the credential was marked as invalid. // This can range from cloud messages such as an expired credential to // commercial reasons set via CLI or api calls. InvalidReason string `db:"invalid_reason"` }
type CredentialAttribute ¶
type CredentialAttribute struct { // CredentialUUID holds the parent cloud credential document key. CredentialUUID string `db:"cloud_credential_uuid"` // Key is the attribute key. Key string `db:"key"` // Value is the attribute value. Value string `db:"value"` }
CredentialAttribute represents the persistent credential attributes schema in the database.
type Credentials ¶
type Credentials []Credential
func (Credentials) ToCloudCredentials ¶
func (rows Credentials) ToCloudCredentials(cloudName string, authTypes []authType, keyValues []CredentialAttribute) ([]credential.CloudCredentialResult, error)
ToCloudCredentials converts the given credentials to a slice of cloud credentials.
type State ¶
State is used to access the database.
func NewState ¶
func NewState(factory coredatabase.TxnRunnerFactory) *State
NewState creates a state to access the database.
func (*State) AllCloudCredentialsForOwner ¶
func (st *State) AllCloudCredentialsForOwner(ctx context.Context, owner user.Name) (map[corecredential.Key]credential.CloudCredentialResult, error)
AllCloudCredentialsForOwner returns all cloud credentials stored on the controller for a given owner.
func (*State) CloudCredential ¶
func (st *State) CloudCredential(ctx context.Context, key corecredential.Key) (credential.CloudCredentialResult, error)
CloudCredential returns the cloud credential for the given details.
func (*State) CloudCredentialsForOwner ¶
func (st *State) CloudCredentialsForOwner(ctx context.Context, owner user.Name, cloudName string) (map[string]credential.CloudCredentialResult, error)
CloudCredentialsForOwner returns the owner's cloud credentials for a given cloud, keyed by credential name.
func (*State) CredentialUUIDForKey ¶
func (st *State) CredentialUUIDForKey(ctx context.Context, key corecredential.Key) (corecredential.UUID, error)
CredentialUUIDForKey finds and returns the uuid for the cloud credential identified by key. If no credential is found then an error of credentialerrors.NotFound is returned.
func (*State) GetCloudCredential ¶
func (st *State) GetCloudCredential( ctx context.Context, id corecredential.UUID, ) (credential.CloudCredentialResult, error)
GetCloudCredential is responsible for returning a cloud credential identified by id. If no cloud credential exists for the given id then a credentialerrors.NotFound error will be returned.
func (*State) InvalidateCloudCredential ¶
func (st *State) InvalidateCloudCredential(ctx context.Context, key corecredential.Key, reason string) error
InvalidateCloudCredential marks a cloud credential with the given name, cloud and owner. as invalid.
func (*State) ModelsUsingCloudCredential ¶
func (st *State) ModelsUsingCloudCredential(ctx context.Context, key corecredential.Key) (map[coremodel.UUID]string, error)
ModelsUsingCloudCredential returns a map of uuid->name for models which use the credential.
func (*State) RemoveCloudCredential ¶
RemoveCloudCredential removes a cloud credential with the given name, cloud and owner..
func (*State) UpsertCloudCredential ¶
func (st *State) UpsertCloudCredential(ctx context.Context, key corecredential.Key, credential credential.CloudCredentialInfo) (*bool, error)
UpsertCloudCredential adds or updates a cloud credential with the given name, cloud and owner. If the credential exists already, the existing credential's Invalid value is returned.
If the owner of the credential can't be found then an error satisfying [usererrors.NotFound] will be returned.
func (*State) WatchCredential ¶
func (st *State) WatchCredential( ctx context.Context, getWatcher func(string, string, changestream.ChangeType) (watcher.NotifyWatcher, error), key corecredential.Key, ) (watcher.NotifyWatcher, error)
WatchCredential returns a new NotifyWatcher watching for changes to the specified credential.