Documentation
¶
Overview ¶
Package gcp provides GCP helpers.
Index ¶
- func GenHTTPHeader(ctx context.Context, scopes ...string) (string, error)
- func GetAccessToken(ctx context.Context, scopes ...string) (string, error)
- func GetSecretByName(name string) (string, error)
- func GetTokenStruct(ctx context.Context, scopes ...string) (*oauth2.Token, error)
- type SecretClient
- type SecretVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenHTTPHeader ¶ added in v0.4.0
func GetAccessToken ¶ added in v0.4.0
func GetSecretByName ¶
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
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>