knock

package module
v0.0.0-...-7a92ad4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: MIT Imports: 7 Imported by: 0

README

knock

Demonstration of interacting with the Google Secrets Manager API using Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessSecretVersion

func AccessSecretVersion(version string) ([]byte, error)

AccessSecretVersion returns the payload for the given secret version if one exists. The `version` is the full path to the secret version, and can be a version number as a string (e.g. "5") or an alias (e.g. "latest"), i.e.

"projects/projectID/secrets/secretID/versions/latest"
"projects/projectID/secrets/secretID/versions/5"

func AddSecretVersion

func AddSecretVersion(path string, payload []byte) (string, error)

AddSecretVersion adds a new secret version to the given secret path with the provided payload. The path should be the full path to the secret, e.g.

"projects/projectID/secrets/secretID"

Returns the path to the secret version, e.g.:

"projects/projectID/secrets/secretID/versions/1"

and an error if one occurs.

func CreateSecret

func CreateSecret(parent string, secretID string, expiration int64) (string, error)

CreateSecret creates a new secret in the Google Cloud Manager top- level directory, specified as `parent`, using the `secretID` provided as the name, to expire after `expiration` seconds. The parent should be a path, e.g.

"projects/project-name"

This function returns a string representation of the path where the new secret is stored, e.g.

"projects/projectID/secrets/secretID"

and an error if any occurs. Note: A secret is a logical wrapper around a collection of secret versions. Secret versions hold the actual secret material.

func DeleteSecret

func DeleteSecret(name string) error

DeleteSecret deletes the secret with the given `name`, and all of its versions. `name` should be the root path to the secret, e.g.:

"projects/projectID/secrets/secretID"

This is an irreversible operation. Any service or workload that attempts to access a deleted secret receives a Not Found error.

func Knock

func Knock(parent string) error

Knock checks to make sure we can create a new client. This validates IAM permissions to some extent.

func ListSecrets

func ListSecrets(parent string) (secrets []string, errors []error)

ListSecrets retrieves the names of all secrets in the project, given the `parent`, e.g.:

"projects/my-project"

It returns a slice of strings representing the paths to the retrieved secrets, and a matching slice of errors for each failed retrieval.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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