generator

package
v1.21.3 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 27 Imported by: 5

Documentation

Overview

*

  • Azure App Config implementation

*

*

  • Azure KeyVault implementation

*

*

  • Azure TableStore implementation

*

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyResponse     = errors.New("value retrieved but empty for token")
	ErrServiceCallFailed = errors.New("failed to complete the service call")
)
View Source
var (
	ErrRetrieveFailed       = errors.New("failed to retrieve config item")
	ErrClientInitialization = errors.New("failed to initialize the client")
)
View Source
var ErrIncorrectlyStructuredToken = errors.New("incorrectly structured token")
View Source
var (
	// default varPrefix used by the replacer function
	// any token must beging with one of these else
	// it will be skipped as not a replaceable token
	VarPrefix = map[ImplementationPrefix]bool{
		SecretMgrPrefix: true, ParamStorePrefix: true, AzKeyVaultSecretsPrefix: true,
		GcpSecretsPrefix: true, HashicorpVaultPrefix: true, AzTableStorePrefix: true,
		AzAppConfigPrefix: true,
	}
)

Functions

func ParseMetadata added in v1.21.0

func ParseMetadata[T comparable](token string, typ T) string

ParseMetadata parses the metadata of each token into the provided pointer. All data inside the `[` `]` is considered metadata about the token.

returns the token without the metadata `[` `]`

Further processing down the line will remove other elements of the token.

Types

type AzAppConf added in v1.21.0

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

func NewAzAppConf added in v1.21.0

func NewAzAppConf(ctx context.Context, token string, conf GenVarsConfig) (*AzAppConf, error)

NewAzAppConf

type AzAppConfConfig added in v1.21.0

type AzAppConfConfig struct {
	Label          string       `json:"label"`
	Etag           *azcore.ETag `json:"etag"`
	AcceptDateTime *time.Time   `json:"acceptedDateTime"`
}

AzAppConfConfig is the azure conf service specific config and it is parsed from the token metadata

type AzKvConfig added in v1.21.0

type AzKvConfig struct {
	Version string `json:"version"`
}

AzKvConfig takes any metadata from the token Version is the only

type AzTableStore added in v1.20.0

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

func NewAzTableStore added in v1.20.0

func NewAzTableStore(ctx context.Context, token string, conf GenVarsConfig) (*AzTableStore, error)

NewAzTableStore

type AzTableStrgConfig added in v1.21.0

type AzTableStrgConfig struct {
	Format string `json:"format"`
}

type DefaultStrategy

type DefaultStrategy struct {
}

func NewDefatultStrategy

func NewDefatultStrategy() *DefaultStrategy

type GcpSecrets added in v1.15.0

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

func NewGcpSecrets added in v1.15.0

func NewGcpSecrets(ctx context.Context) (*GcpSecrets, error)

type GcpSecretsConfig added in v1.21.0

type GcpSecretsConfig struct {
	Version string `json:"version"`
}

type GenVars

type GenVars struct {
	Generatoriface
	// contains filtered or unexported fields
}

GenVars is the main struct holding the strategy patterns iface any initialised config if overridded with withers as well as the final outString and the initial rawMap which wil be passed in a loop into a goroutine to perform the relevant strategy network calls to the config store implementations

func NewGenerator

func NewGenerator() *GenVars

NewGenerator returns a new instance of Generator with a default strategy pattern wil be overwritten during the first run of a found tokens map

func (*GenVars) AddRawMap added in v1.17.2

func (c *GenVars) AddRawMap(key, val string)

func (*GenVars) Config added in v1.3.0

func (c *GenVars) Config() *GenVarsConfig

Config gets Config on the GenVars

func (*GenVars) ConvertToExportVar

func (c *GenVars) ConvertToExportVar() []string

ConvertToExportVar assigns the k/v out as unix style export key=val pairs separated by `\n`

func (*GenVars) FlushToFile

func (c *GenVars) FlushToFile(w io.Writer, out []string) error

FlushToFile saves contents to file provided in the config input into the generator default location is ./app.env

func (*GenVars) Generate

func (c *GenVars) Generate(tokens []string) (ParsedMap, error)

Generate generates a k/v map of the tokens with their corresponding secret/paramstore values the standard pattern of a token should follow a path like

func (*GenVars) RawMap added in v1.17.2

func (c *GenVars) RawMap() ParsedMap

func (*GenVars) StrToFile added in v1.3.0

func (c *GenVars) StrToFile(w io.Writer, str string) error

StrToFile writes a provided string to the writer

func (*GenVars) WithConfig

func (c *GenVars) WithConfig(cfg *GenVarsConfig) *GenVars

WithConfig uses custom config

func (*GenVars) WithContext added in v1.10.0

func (c *GenVars) WithContext(ctx context.Context) *GenVars

WithContext uses caller passed context

type GenVarsConfig

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

GenVarsConfig defines the input config object to be passed

func NewConfig

func NewConfig() *GenVarsConfig

NewConfig

func (*GenVarsConfig) KeySeparator added in v1.18.0

func (c *GenVarsConfig) KeySeparator() string

KeySeparator returns the keySeparator set in the config

func (*GenVarsConfig) OutputPath added in v1.18.0

func (c *GenVarsConfig) OutputPath() string

OutputPath returns the outpath set in the config

func (*GenVarsConfig) TokenSeparator added in v1.18.0

func (c *GenVarsConfig) TokenSeparator() string

TokenSeparator returns the tokenSeparator set in the config

func (*GenVarsConfig) WithKeySeparator

func (c *GenVarsConfig) WithKeySeparator(keySeparator string) *GenVarsConfig

WithKeySeparator adds a custom key separotor

func (*GenVarsConfig) WithOutputPath

func (c *GenVarsConfig) WithOutputPath(out string) *GenVarsConfig

WithOutputPath

func (*GenVarsConfig) WithTokenSeparator

func (c *GenVarsConfig) WithTokenSeparator(tokenSeparator string) *GenVarsConfig

WithTokenSeparator adds a custom token separator token is the actual value of the parameter/secret in the provider store

type GenVarsiface added in v1.6.0

type GenVarsiface interface {
	Generatoriface
	Config() *GenVarsConfig
}

GenVarsiface stores strategy and GenVars implementation behaviour

type Generatoriface

type Generatoriface interface {
	Generate(tokens []string) (ParsedMap, error)
	ConvertToExportVar() []string
	FlushToFile(w io.Writer, outString []string) error
	StrToFile(w io.Writer, str string) error
}

Generatoriface describes the exported methods on the GenVars struct.

type ImplementationPrefix added in v1.14.0

type ImplementationPrefix string
const (
	// AWS SecretsManager prefix
	SecretMgrPrefix ImplementationPrefix = "AWSSECRETS"
	// AWS Parameter Store prefix
	ParamStorePrefix ImplementationPrefix = "AWSPARAMSTR"
	// Azure Key Vault Secrets prefix
	AzKeyVaultSecretsPrefix ImplementationPrefix = "AZKVSECRET"
	// Azure Key Vault Secrets prefix
	AzTableStorePrefix ImplementationPrefix = "AZTABLESTORE"
	// Azure App Config prefix
	AzAppConfigPrefix ImplementationPrefix = "AZAPPCONF"
	// Hashicorp Vault prefix
	HashicorpVaultPrefix ImplementationPrefix = "VAULT"
	// GcpSecrets
	GcpSecretsPrefix ImplementationPrefix = "GCPSECRETS"
)

type KvScrtStore added in v1.2.0

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

func NewKvScrtStore added in v1.2.0

func NewKvScrtStore(ctx context.Context, token string, conf GenVarsConfig) (*KvScrtStore, error)

NewKvScrtStore returns a KvScrtStore requires `AZURE_SUBSCRIPTION_ID` environment variable to be present to successfully work

type ParamStore

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

func NewParamStore

func NewParamStore(ctx context.Context) (*ParamStore, error)

type ParamStrConfig added in v1.21.0

type ParamStrConfig struct {
}

type ParsedMap

type ParsedMap map[string]any

ParsedMap is the internal working object definition and the return type if results are not flushed to file

type SecretsMgr

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

func NewSecretsMgr

func NewSecretsMgr(ctx context.Context) (*SecretsMgr, error)

type SecretsMgrConfig added in v1.21.0

type SecretsMgrConfig struct {
	Version string `json:"version"`
}

type TokenConfigVars added in v1.18.9

type TokenConfigVars struct {
	Token string
	// AWS IAM Role for Vault AWS IAM Auth
	Role string
	// where supported a version of the secret can be specified
	//
	// e.g. HashiVault or AWS SecretsManager or AzAppConfig Label
	//
	Version string
}

TokenConfigVars

type VaultConfig added in v1.21.0

type VaultConfig struct {
	Version string `json:"version"`
	Role    string `json:"iam_role"`
}

VaultConfig holds the parseable metadata struct

type VaultStore added in v1.14.0

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

func NewVaultStore added in v1.14.0

func NewVaultStore(ctx context.Context, token string, conf GenVarsConfig) (*VaultStore, error)

Jump to

Keyboard shortcuts

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