gcp

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gcp provides GCP helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenHTTPHeader added in v0.4.0

func GenHTTPHeader(ctx context.Context, scopes ...string) (string, error)

func GetAccessToken added in v0.4.0

func GetAccessToken(ctx context.Context, scopes ...string) (string, error)

func GetSecretByName

func GetSecretByName(name string) (string, error)

GetSecretByName gets a secret from gcp by its name The expected format is [projects/*/secrets/*/versions/*] for versions, you can use "latest" to grab the latest version

func GetTokenStruct added in v0.4.0

func GetTokenStruct(ctx context.Context, scopes ...string) (*oauth2.Token, error)

Types

type SecretClient

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

SecretClient is a wrapper around GCP Secret Service. It provides useful helpers to for getting and creating secrets.

func NewSecretClient

func NewSecretClient(opts ...option.ClientOption) (*SecretClient, error)

NewSecretClient creates a new gcp secret manager service. If no option is provided it will use the Google Cloud ADC to initialize the client.

The returned client must be Closed when it is done being used to clean up its underlying connections by calling the `func Close()`

func (*SecretClient) Close

func (c *SecretClient) Close() error

Close closes the connection to the GCP Secret Service. The user should invoke this when the client is no longer required.

func (*SecretClient) CreateSecret

func (c *SecretClient) CreateSecret(name, value string) error

CreateSecret creates a secret in GCP Secret Service. The expected name format is: - projects/<project>/secrets/<name>

func (*SecretClient) DeleteSecret

func (c *SecretClient) DeleteSecret(name string) error

DeleteSecret deletes a secret. - projects/<project>/secrets/<name>

func (*SecretClient) GetSecret

func (c *SecretClient) GetSecret(name string) (string, error)

GetSecret fetches the secret from GCP Secret Manager and return it as a string.

The expected formats are: - projects/<project>/secrets/<name>/versions/<version> - projects/<project>/secrets/<name>/versions/latest

type SecretVersion added in v0.3.0

type SecretVersion struct {
	Path  string
	State secretmanagerpb.SecretVersion_State
}

func ListSecretVersions added in v0.3.0

func ListSecretVersions(name string) ([]SecretVersion, error)

ListSecretVersions Get all the secret versions and their status Expected format is - projects/<project id or project name>/secrets/secret-name - projects/<project id or project name>/secrets/secret-name/versions/<int>

Jump to

Keyboard shortcuts

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