gcp

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Endpoint is the GCP SecretManager endpoint.
	Endpoint string

	// ProjectID is the ID of the GCP project.
	ProjectID string

	// Credentials are the GCP credentials to
	// access the SecretManager.
	Credentials Credentials

	// Scopes are GCP OAuth2 scopes for accessing GCP APIs.
	// If not set, defaults to the GCP default scopes.
	//
	// Ref: https://developers.google.com/identity/protocols/oauth2/scopes
	Scopes []string

	// ErrorLog is an optional logger for errors
	// that may occur when interacting with GCP
	// SecretManager.
	ErrorLog *log.Logger
	// contains filtered or unexported fields
}

Config is a structure containing configuration options for connecting to a KeySecure server.

func (*Config) Clone

func (c *Config) Clone() *Config

Clone returns a shallow clone of c or nil if c is nil. It is safe to clone a Config that is being used concurrently.

type Credentials

type Credentials struct {

	// ClientID is the client ID of the GCP service account.
	ClientID string

	// Client is the client email of the GCP service account.
	Client string

	// Key is the private key ID of the GCP service account.
	KeyID string

	// Key is the encoded private key of the GCP service account.
	Key string
	// contains filtered or unexported fields
}

Credentials represent GCP service account credentials.

func (Credentials) MarshalJSON

func (c Credentials) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON representation of the GCP credentials.

The returned JSON contains extra fields to match the JSON credentials returned by GCP. Those additional fields are set to default values.

type Store added in v0.23.0

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

Store is a GCP SecretManager secret store.

func Connect

func Connect(ctx context.Context, c *Config) (*Store, error)

Connect connects and authenticates to a GCP SecretManager server.

func (*Store) Close added in v0.23.0

func (s *Store) Close() error

Close closes the Store.

func (*Store) Create added in v0.23.0

func (s *Store) Create(ctx context.Context, name string, value []byte) error

Create stores the given key-value pair at GCP secret manager if and only if it doesn't exists. If such an entry already exists it returns kes.ErrKeyExists.

Creating a secret at the GCP SecretManager requires first creating secret itself and then adding a secret version with some payload data. The payload data contains the actual value.

func (*Store) Delete added in v0.23.0

func (s *Store) Delete(ctx context.Context, name string) error

Delete remove the key-value pair from GCP SecretManager.

Delete will remove all versions of the GCP secret. Even though CreateKey will create only one version and fails if the secret already exists a user may create more secrets versions through e.g. the GCP CLI. However, KES does not support multiple secret versions and expects a different mechanism for "key-rotation".

func (*Store) Get added in v0.23.0

func (s *Store) Get(ctx context.Context, name string) ([]byte, error)

Get returns the value associated with the given key.

func (*Store) List added in v0.23.0

func (s *Store) List(ctx context.Context, prefix string, n int) ([]string, string, error)

List returns a new Iterator over the names of all stored keys. List returns the first n key names, that start with the given prefix, and the next prefix from which the listing should continue.

It returns all keys with the prefix if n < 0 and less than n names if n is greater than the number of keys with the prefix.

An empty prefix matches any key name. At the end of the listing or when there are no (more) keys starting with the prefix, the returned prefix is empty.

func (*Store) Set added in v0.23.0

func (s *Store) Set(ctx context.Context, name string, value []byte) error

Set stores the given key-value pair at GCP secret manager if and only if it doesn't exists. If such an entry already exists it returns kes.ErrKeyExists.

Creating a secret at the GCP SecretManager requires first creating secret itself and then adding a secret version with some payload data. The payload data contains the actual value.

func (*Store) Status added in v0.23.0

func (s *Store) Status(ctx context.Context) (kes.KeyStoreState, error)

Status returns the current state of the GCP SecretManager instance. In particular, whether it is reachable and the network latency.

func (*Store) String added in v0.23.0

func (s *Store) String() string

Jump to

Keyboard shortcuts

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