secrets

package
v0.0.0-...-ba25954 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

sg-common/secrets/secrets.go

Secrets, also called secret keys, are crucial components in this application.
During development, we will store and fetch secrets from environment variables.
In production, we need to use a secret management service such as GCP Secret
Manager.

The secrets package makes fetching secrets an abstract operation, independent
of whether the secretscome from environment variables or Secret Manager. This
allows us to  easily switch from using environment variables during local
development to using Secret Manager in the production environment.

Implementation: Secrets is implemented as a shared library that can be used by
any microservice that needs it. Implementation involves 3 steps: Develop a
Secret Fetching Interface; Implement the Interface for Both Methods (fetching
secrets from environment variables, and fetching secrets from Secret manager);
Decide on the Method at Runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvVarSecretFetcher

type EnvVarSecretFetcher struct{}

func (*EnvVarSecretFetcher) GetSecret

func (f *EnvVarSecretFetcher) GetSecret(key string) (string, error)

type GcpSecretManagerFetcher

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

func NewGcpSecretManagerFetcher

func NewGcpSecretManagerFetcher(projectID string, credentialsFile string) (*GcpSecretManagerFetcher, error)

func (*GcpSecretManagerFetcher) GetSecret

func (f *GcpSecretManagerFetcher) GetSecret(secretID string) (string, error)

type SecretFetcher

type SecretFetcher interface {
	GetSecret(key string) (string, error)
}

func GetFetcher

func GetFetcher() SecretFetcher

Jump to

Keyboard shortcuts

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