config_generic

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSchemaV1 added in v0.2.0

func IsSchemaV1(version int) bool

Types

type Config

type Config struct {

	// Name describes the name of the config entry
	Name string

	// Value hold the encodedValue in base64 of the secret
	Value string

	// OriginContext references the configured context to decode the secret
	OriginContext *Context
}

type ConfigMap

type ConfigMap map[string]string

type Context

type Context struct {
	Name             string
	SecretResolver   encryption.SecretResolver
	Encryption       encryption.Engine
	EncryptedSecrets map[string]string
	Configs          map[string]string
}

func (*Context) DecodeValue

func (c *Context) DecodeValue(encodedValue string) (decodedValue string, err error)

DecodeValue takes the value and decodes it encodeValue must be base64

func (*Context) EncodeValue

func (c *Context) EncodeValue(plainValue string) (encodedValue string, err error)

EncodeValue encodes the given value and returns it as a base64 string

type FileToRender

type FileToRender struct {
	FileIn  string
	FileOut string
}

type RenderTarget

type RenderTarget struct {
	Name          string
	FilesToRender []*FileToRender
}

func NewRenderTarget

func NewRenderTarget(name string) *RenderTarget

func (*RenderTarget) AddFileToRender

func (c *RenderTarget) AddFileToRender(fileIn string, fileOut string) error

AddFileToRender adds a file to render which is later used by the rendering engine

type Repository

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

func NewRepository

func NewRepository(configVersion int, configFileUsed string, configWriter writer.ConfigWriter) *Repository

NewRepository creates a new generic repository

func ParseRepository added in v0.2.0

func ParseRepository(fileSystem afero.Fs, fileName string, globalConfig *global_config.GlobalConfigProvider, overwrittenSecrets map[string]string) (*Repository, error)

func ParseSchemaV1 added in v0.2.0

func ParseSchemaV1(jsonInput []byte, configFileUsed string, globalConfig *global_config.GlobalConfigProvider, overwrittenSecrets map[string]string) (*Repository, error)

func (*Repository) AddConfig

func (c *Repository) AddConfig(Config *Config) error

AddConfig adds a Config to the repository also does some validations

func (*Repository) AddContext

func (c *Repository) AddContext(context *Context) error

AddContext adds a context and does some validations

func (*Repository) AddRenderTarget

func (c *Repository) AddRenderTarget(target *RenderTarget) error

func (*Repository) AddSecret

func (c *Repository) AddSecret(secret *Secret) error

AddSecret adds a secret to the repository also does some validations

func (*Repository) GetConfigMap

func (c *Repository) GetConfigMap() ConfigMap

func (*Repository) GetConfigVersion

func (c *Repository) GetConfigVersion() int

GetConfigVersion returns the config version this repository is built from

func (*Repository) GetConfigWriter

func (c *Repository) GetConfigWriter() writer.ConfigWriter

GetConfigWriter returns the current config writer

func (*Repository) GetConfigsByContext

func (c *Repository) GetConfigsByContext(contextName string) (res []*Config)

GetConfigsByContext returns all the Configs related to the current context

func (*Repository) GetContext

func (c *Repository) GetContext(contextName string) *Context

GetContext returns the context by name

func (*Repository) GetContexts

func (c *Repository) GetContexts() []*Context

func (*Repository) GetCurrent

func (c *Repository) GetCurrent() *Context

GetCurrent returns the current context

func (*Repository) GetCurrentConfig

func (c *Repository) GetCurrentConfig(ConfigName string) *Config

GetCurrentConfig takes the merged Configs from GetCurrentConfigs and returns the needed one

func (*Repository) GetCurrentConfigs

func (c *Repository) GetCurrentConfigs() (res []*Config)

GetCurrentConfigs merges the default Configs with the context Configs the default Configs are overwritten by the context Configs

func (*Repository) GetCurrentSecret

func (c *Repository) GetCurrentSecret(secretName string) *Secret

GetCurrentSecret takes the merged secrets from GetCurrentSecrets and returns the needed one

func (*Repository) GetCurrentSecrets

func (c *Repository) GetCurrentSecrets() (res []*Secret)

GetCurrentSecrets merges the default secrets with the context secrets the default secrets are overwritten by the context secrets

func (*Repository) GetDefault

func (c *Repository) GetDefault() *Context

GetDefault returns the default context

func (*Repository) GetRenderTarget

func (c *Repository) GetRenderTarget(targetName string) *RenderTarget

func (*Repository) GetSecretsByContext

func (c *Repository) GetSecretsByContext(contextName string) (res []*Secret)

GetSecretsByContext returns all the secrets related to the current context

func (*Repository) GetSecretsMapDecoded added in v0.2.0

func (c *Repository) GetSecretsMapDecoded() (SecretsMap, error)

GetSecretsMapDecoded decodes the secrets of the current context and puts them into a map[string]string

func (*Repository) HasRenderTarget

func (c *Repository) HasRenderTarget(targetName string) bool

func (*Repository) IsDefault

func (c *Repository) IsDefault() bool

IsDefault returns if the default context is used

func (*Repository) RenderTargetNames

func (c *Repository) RenderTargetNames() (names []string)

func (*Repository) SetSelectedContext

func (c *Repository) SetSelectedContext(contextName string) (*Context, error)

SetSelectedContext sets the current selected context

type Secret

type Secret struct {

	// Name describes the name of the secret
	Name string

	// EncodedValue hold the encodedValue in base64 of the secret
	EncodedValue string

	// OriginContext references the configured context to decode the secret
	OriginContext *Context
}

func (*Secret) Decode

func (s *Secret) Decode() (string, error)

type SecretsMap

type SecretsMap map[string]string

type V1Context added in v0.2.0

type V1Context map[string]*V1ContextAwareSecrets

type V1ContextAwareSecrets added in v0.2.0

type V1ContextAwareSecrets struct {
	DecryptSecret *V1DecryptSecret  `json:"decryptSecret,omitempty"`
	Secrets       map[string]string `json:"secrets,omitempty"`
	Configs       map[string]string `json:"configs,omitempty"`
}

type V1DecryptSecret added in v0.2.0

type V1DecryptSecret struct {
	FromName string `json:"fromName,omitempty"`
	FromEnv  string `json:"fromEnv,omitempty"`
}

type V1RenderTarget added in v0.2.0

type V1RenderTarget struct {
	Files []*V1RenderTargetFileEntry `json:"files"`
}

type V1RenderTargetFileEntry added in v0.2.0

type V1RenderTargetFileEntry struct {
	FileIn  string `json:"fileIn"`
	FileOut string `json:"fileOut"`
}

type V1Schema added in v0.2.0

type V1Schema struct {
	Schema      string                     `json:"$schema,omitempty"`
	Version     int                        `json:"version"`
	Context     V1Context                  `json:"context"`
	RenderFiles map[string]*V1RenderTarget `json:"renderFiles,omitempty"`
}

type V1Writer added in v0.2.0

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

func NewV1Writer added in v0.2.0

func NewV1Writer(fs afero.Fs, schema V1Schema, configPath string) *V1Writer

func (*V1Writer) AddContext added in v0.2.0

func (v *V1Writer) AddContext(contextName string) error

func (*V1Writer) AddFileToRender added in v0.2.0

func (v *V1Writer) AddFileToRender(targetName string, fileIn string, fileOut string) error

func (*V1Writer) SetConfig added in v0.2.0

func (v *V1Writer) SetConfig(contextName string, configName string, configValue string, force bool) error

func (*V1Writer) SetSecret added in v0.2.0

func (v *V1Writer) SetSecret(contextName string, secretName string, secretEncodedValue string, force bool) error

func (*V1Writer) WriteConfig added in v0.2.0

func (v *V1Writer) WriteConfig() error

type VersionFixType added in v0.2.0

type VersionFixType struct {
	Version int `json:"version"`
}

Jump to

Keyboard shortcuts

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