Documentation
¶
Index ¶
- Variables
- func AddSecretVersion(ctx context.Context, name string, value []byte) (*secretmanagerpb.SecretVersion, error)
- func CreateSecret(ctx context.Context, name string) (*secretmanagerpb.Secret, error)
- func CreateSecretWithValue(ctx context.Context, name string, value []byte) error
- func DestroyAllButLatestVersion(ctx context.Context, name string) error
- func DestroyAllPreviousVersions(ctx context.Context, name string, version int) error
- func DestroySecretVersion(ctx context.Context, name string, version int) error
- func DisableSecretVersion(ctx context.Context, name string, version int) error
- func EnableSecretVersion(ctx context.Context, name string, version int) error
- func GetSecretValue(ctx context.Context, name string) ([]byte, error)
- func GetSecretValueAsString(ctx context.Context, name string) string
- func RemoveSecret(ctx context.Context, name string) error
- func ReplaceSecretWithNewVersion(ctx context.Context, name string, value []byte) error
- func UpdateSecretWithNewVersion(ctx context.Context, name string, value []byte) error
- type Iterable
- type NewPathVersionOption
- type Path
- type SecretIterable
- type SecretVersionIterable
Constants ¶
This section is empty.
Variables ¶
var ValueOutOfRange = errorx.RegisterTrait("value out of range")
Functions ¶
func AddSecretVersion ¶
func AddSecretVersion(ctx context.Context, name string, value []byte) (*secretmanagerpb.SecretVersion, error)
AddSecretVersion adds a new secret version to the given secret with the provided payload.
func CreateSecret ¶
CreateSecret creates a new secret.
func CreateSecretWithValue ¶
CreateSecretWithValue creates a secret with a value and enables it.
func DestroyAllButLatestVersion ¶
DestroyAllButLatestVersion destroys all versions of a secret except the latest.
func DestroyAllPreviousVersions ¶
DestroyAllPreviousVersions destroys all versions of a secret except the specified version. If the version is 0, it will destroy all versions except the latest. If the version is > 0, it will destroy all versions less than the specified version.
func DestroySecretVersion ¶
DestroySecretVersion destroys a specific version of a secret.
func DisableSecretVersion ¶
DisableSecretVersion disables a specific version of a secret.
func EnableSecretVersion ¶
EnableSecretVersion enables a specific version of a secret.
func GetSecretValue ¶
GetSecretValue accesses the payload for the given secret version if one exists. The version can be a version number as a string (e.g. "5") or an alias (e.g. "latest").
func GetSecretValueAsString ¶
GetSecretValueAsString gets the secret value as a string.
func RemoveSecret ¶
RemoveSecret removes a secret.
func ReplaceSecretWithNewVersion ¶
ReplaceSecretWithNewVersion replaces a secret with a new version and destroys the previous version.
Types ¶
type Iterable ¶
type Iterable[I secretmanagerpb.SecretVersion | secretmanagerpb.Secret] interface { Next() (*I, error) }
Iterable is an interface for iterating over secret versions or secrets.
type NewPathVersionOption ¶
type NewPathVersionOption func(path *Path)
func WithLatestVersion ¶
func WithLatestVersion() NewPathVersionOption
func WithVersion ¶
func WithVersion(version int) NewPathVersionOption
func WithoutVersion ¶
func WithoutVersion() NewPathVersionOption
type Path ¶
Path represents a path to a secret in Secret Manager.
A path can be represented in three different ways: - Without a version: projects/{project_number}/secrets/{secret_name} - With a version: projects/{project_number}/secrets/{secret_name}/versions/{version_number} - With the latest version: projects/{project_number}/secrets/{secret_name}/versions/latest
func NewPath ¶
func NewPath(name string, version NewPathVersionOption) Path
func (Path) LatestVersion ¶
LatestVersion returns the path to the latest version of the secret. Example: projects/1234567890/secrets/my-secret/versions/latest
func (Path) String ¶
String returns the string representation of the path. If the version is 0, it returns the latest version. If the version is negative, it returns the path without a version. Otherwise, it returns the path with the version.
func (Path) WithVersion ¶
WithVersion returns the path to the secret with a specific version. Example: projects/1234567890/secrets/my-secret/versions/1
func (Path) WithoutVersion ¶
WithoutVersion returns the path to the secret without a version. Example: projects/1234567890/secrets/my-secret
type SecretIterable ¶
type SecretIterable struct{}
func (SecretIterable) Next ¶
func (si SecretIterable) Next() (*secretmanagerpb.Secret, error)
type SecretVersionIterable ¶
type SecretVersionIterable struct{}
func (SecretVersionIterable) Next ¶
func (svi SecretVersionIterable) Next() (*secretmanagerpb.SecretVersion, error)