secrets

package
v0.0.0-...-16b3867 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func CreateSecret(ctx context.Context, name string) (*secretmanagerpb.Secret, error)

CreateSecret creates a new secret.

func CreateSecretWithValue

func CreateSecretWithValue(ctx context.Context, name string, value []byte) error

CreateSecretWithValue creates a secret with a value and enables it.

func DestroyAllButLatestVersion

func DestroyAllButLatestVersion(ctx context.Context, name string) error

DestroyAllButLatestVersion destroys all versions of a secret except the latest.

func DestroyAllPreviousVersions

func DestroyAllPreviousVersions(ctx context.Context, name string, version int) error

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

func DestroySecretVersion(ctx context.Context, name string, version int) error

DestroySecretVersion destroys a specific version of a secret.

func DisableSecretVersion

func DisableSecretVersion(ctx context.Context, name string, version int) error

DisableSecretVersion disables a specific version of a secret.

func EnableSecretVersion

func EnableSecretVersion(ctx context.Context, name string, version int) error

EnableSecretVersion enables a specific version of a secret.

func GetSecretValue

func GetSecretValue(ctx context.Context, name string) ([]byte, error)

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

func GetSecretValueAsString(ctx context.Context, name string) string

GetSecretValueAsString gets the secret value as a string.

func RemoveSecret

func RemoveSecret(ctx context.Context, name string) error

RemoveSecret removes a secret.

func ReplaceSecretWithNewVersion

func ReplaceSecretWithNewVersion(ctx context.Context, name string, value []byte) error

ReplaceSecretWithNewVersion replaces a secret with a new version and destroys the previous version.

func UpdateSecretWithNewVersion

func UpdateSecretWithNewVersion(ctx context.Context, name string, value []byte) error

UpdateSecretWithNewVersion updates a secret with a new version and enables it.

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

type Path struct {
	ProjectNumber int
	Name          string
	Version       int
}

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

func (p Path) LatestVersion() string

LatestVersion returns the path to the latest version of the secret. Example: projects/1234567890/secrets/my-secret/versions/latest

func (Path) String

func (p Path) String() 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

func (p Path) WithVersion() string

WithVersion returns the path to the secret with a specific version. Example: projects/1234567890/secrets/my-secret/versions/1

func (Path) WithoutVersion

func (p Path) WithoutVersion() string

WithoutVersion returns the path to the secret without a version. Example: projects/1234567890/secrets/my-secret

type SecretIterable

type SecretIterable struct{}

func (SecretIterable) Next

type SecretVersionIterable

type SecretVersionIterable struct{}

func (SecretVersionIterable) Next

Jump to

Keyboard shortcuts

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