infra

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package infra is responsible for infrastructure related concerns of the app like deploying and configuration

Index

Constants

This section is empty.

Variables

View Source
var DeployCmd = &cobra.Command{
	Use:   "deploy",
	Short: "deploy lambdas to aws",
	Args:  cobra.MinimumNArgs(1),
}
View Source
var EnvCmd = &cobra.Command{
	Use:   "env [FEATURE]",
	Short: "display environment variables for a lambda",
	Args:  cobra.MinimumNArgs(0),
}
View Source
var EnvExportCmd = &cobra.Command{
	Use:   "export",
	Short: "exports all env vars for this service",
	Args:  cobra.MinimumNArgs(0),
}
View Source
var PStoreCmd = &cobra.Command{
	Use:   "pstore [FEATURE]",
	Short: "display parameter store values for a lambda",
	Args:  cobra.MinimumNArgs(0),
}
View Source
var PStoreDeleteCmd = &cobra.Command{
	Use:   "delete <PARAM_NAME>",
	Short: "delete single param or all params from the micro-service",
	Args:  cobra.MaximumNArgs(1),
}
View Source
var PStoreExportCmd = &cobra.Command{
	Use:   "export",
	Short: "exports all params for this service",
	Args:  cobra.MinimumNArgs(0),
}
View Source
var PStoreImportCmd = &cobra.Command{
	Use:   "import",
	Short: "import params into parameter store",
}

Functions

func Bind

func Bind(c *cobra.Command, v *viper.Viper, config interface{}) error

func Process

func Process(cmd *cobra.Command, v *viper.Viper, spec interface{}, prefix ...string) error

func SetupCommands

func SetupCommands(i *Infra) error

func SetupDeployCmd

func SetupDeployCmd(in *Infra) error

func SetupEnvCmd

func SetupEnvCmd(in *Infra) error

func SetupInfraCmd

func SetupInfraCmd(i *Infra) error

func SetupParamStoreCmd

func SetupParamStoreCmd(in *Infra) error

Types

type CmdConfig

type CmdConfig struct {
	Verbose         bool   `conf:"          global-flag,                      cli:verbose,               cli-s:v,   cli-u:Show verbose output"`
	IsAll           bool   `conf:"          global-flag,                      cli:all,            cli-u: apply to the whole service"`
	SkipDefaults    bool   `conf:"          global-flag,                      cli:skip-defaults,  cli-u: skip default values"`
	WithTrigger     bool   `` /* 161-byte string literal not displayed */
	IsText          bool   `conf:"          global-flag, env:CLI_FORMAT_TEXT, cli:text,           cli-u:Use plain text instead of json'"`
	IsQualifiedName bool   `conf:"          global-flag, env:QUALIFIED_NAMES, cli:qualified-name, cli-u:Display names as fully qualified"`
	Env             string `conf:"required, global-flag, env:ENV,             cli:env, cli-s:e,   cli-u:Application env"`
}

func (CmdConfig) EnvName

func (c CmdConfig) EnvName() string

func (CmdConfig) IsFullyQualifiedName

func (c CmdConfig) IsFullyQualifiedName() bool

func (CmdConfig) NameIncludesTrigger

func (c CmdConfig) NameIncludesTrigger() bool

type DeployBind

type DeployBind struct {
	IsEnvOnly bool `conf:"cli:env-only, cli-u: Only update environment variables"`
}

type DeployConfig

type DeployConfig struct {
	DeployBind
	CmdConfig
}

type EnvBind

type EnvBind struct {
	NamesOnly bool `conf:"cli:names-only, cli-u: Only display the env var names for a given feature"`
}

type EnvConfig

type EnvConfig struct {
	CmdConfig
	EnvBind
}

type EnvExportBind

type EnvExportBind struct {
	File      Filepath `conf:"cli:file, cli-s:f, cli-u:Export to a json file"`
	StdOut    bool     `conf:"cli:stdout, cli-u: Importing values from env vars on you machine"`
	NamesOnly bool     `conf:"cli:names-only, cli-u: Only display the env var names for a given feature"`
}

type EnvExportConfig

type EnvExportConfig struct {
	CmdConfig
	EnvExportBind
}

type EnvIdentity

type EnvIdentity interface {
	EnvName() string
}

type EnvResult

type EnvResult struct {
	FeatureName string
	Items       map[string]string
	Names       []string
	Display     string
}

func EnvMap

func EnvMap(feature sls.Feature, config EnvConfig) (*EnvResult, error)

type Filepath

type Filepath struct {
	Path string
}

Filepath is used as a custom decoder which will take a configuration string and resolve a ~ to the absolute path of the home directory. If ~ is not present it treated as a normal path to a directory

func (*Filepath) Decode

func (d *Filepath) Decode(v string) error

func (*Filepath) IsEmpty

func (d *Filepath) IsEmpty() bool

func (*Filepath) String

func (d *Filepath) String() string

type Infra

type Infra struct {
	Stdout             io.ReadWriteCloser
	Stderr             io.ReadWriteCloser
	Viper              *viper.Viper
	PStoreAPI          ParamStorage
	LambdaAPI          LambdaDeployments
	Service            *sls.MicroService
	ServiceConstructor func(config EnvIdentity) (*sls.MicroService, error)
	ParentCmd          *cobra.Command
	Prefix             []string

	DeployCmd       *cobra.Command
	EnvCmd          *cobra.Command
	EnvExportCmd    *cobra.Command
	PStoreCmd       *cobra.Command
	PStoreImportCmd *cobra.Command
	PStoreDeleteCmd *cobra.Command
	PStoreExportCmd *cobra.Command
	InvokeCmd       *cobra.Command
}

func (*Infra) CheckFailure

func (i *Infra) CheckFailure(err error)

func (*Infra) DeleteAllFeatureParams

func (i *Infra) DeleteAllFeatureParams(ctx context.Context, appTitle string, feature sls.Feature) (map[string]string, error)

func (*Infra) DeleteAllServiceParams

func (i *Infra) DeleteAllServiceParams(ctx context.Context, appTitle string) (map[string]string, error)

func (*Infra) DeleteParam

func (i *Infra) DeleteParam(ctx context.Context, appTitle, key string) (map[string]string, error)

func (*Infra) DeployFeatureCode

func (i *Infra) DeployFeatureCode(ctx context.Context, feature sls.Feature, settings sls.BuildSettings, config DeployConfig) error

func (*Infra) DeployFeatureConfig

func (i *Infra) DeployFeatureConfig(ctx context.Context, appTitle string, feature sls.Feature, config DeployConfig) error

func (*Infra) Display

func (i *Infra) Display(data string)

func (*Infra) DisplayError

func (i *Infra) DisplayError(data string)

func (*Infra) DisplayErrorJson

func (i *Infra) DisplayErrorJson(d interface{})

func (*Infra) DisplayJson

func (i *Infra) DisplayJson(d interface{})

func (*Infra) FeatureEnvReport

func (i *Infra) FeatureEnvReport(config sls.Configurable, c CmdConfig, isNamesOnly ...bool) (map[string]string, error)

func (*Infra) FeatureParams

func (i *Infra) FeatureParams(ctx context.Context, appTitle string, feature sls.Feature) (map[string]string, error)

func (*Infra) LoadFeature

func (i *Infra) LoadFeature(config CmdConfig, name string) (*sls.MicroService, sls.Feature, error)

func (*Infra) LoadService

func (i *Infra) LoadService(config CmdConfig) (*sls.MicroService, error)

func (*Infra) Param

func (i *Infra) Param(ctx context.Context, appTitle, key string) (string, error)

func (*Infra) Process

func (i *Infra) Process(cmd *cobra.Command, c interface{}) error

func (*Infra) PutParam

func (i *Infra) PutParam(ctx context.Context, appTitle, key, value string, overwrite bool) (map[string]string, error)

func (*Infra) RunDeploy

func (i *Infra) RunDeploy(cmd *cobra.Command, args []string) error

func (*Infra) RunEnv

func (i *Infra) RunEnv(cmd *cobra.Command, args []string) error

func (*Infra) RunEnvExport

func (i *Infra) RunEnvExport(cmd *cobra.Command, args []string) error

func (*Infra) RunPStore

func (i *Infra) RunPStore(cmd *cobra.Command, args []string) error

RunPStore runs `<service> infra pstore` which will return parameter values for the service or feature `<service> infra pstore <FEATURE [-a --all]>` - will list all params for just that feature

func (*Infra) RunPStoreDelete

func (i *Infra) RunPStoreDelete(cmd *cobra.Command, args []string) error

RunPStoreDelete runs `<service> infra pstore delete` which will return parameter values for the service or feature `<service> infra pstore delete <[FEATURE] | [--all]>`

func (*Infra) RunPStoreExport

func (i *Infra) RunPStoreExport(cmd *cobra.Command, args []string) error

RunPStoreExport runs `<service> infra pstore export` which will return parameter values for the service or feature 1) `<service> infra pstore export` 2) `<service> infra pstore export [-f --file]` 3) `<service> infra pstore <FEATURE> [-f --file]` - export for that feature

func (*Infra) RunPStoreImport

func (i *Infra) RunPStoreImport(cmd *cobra.Command, _ []string) error

RunPStoreImport runs `<service> infra pstore import` which will import all parameters `<service> infra pstore import <[--file | --env]>`

func (*Infra) ServiceEnvReport

func (i *Infra) ServiceEnvReport(service *sls.MicroService, c CmdConfig, isNamesOnly ...bool) (map[string]string, map[string]map[string]string, error)

func (*Infra) ServiceParams

func (i *Infra) ServiceParams(ctx context.Context, appTitle string) (map[string]string, error)

func (*Infra) StripAppTitle

func (i *Infra) StripAppTitle(appTitle string, in map[string]string) map[string]string

func (*Infra) Validate

func (i *Infra) Validate() error

func (*Infra) WriteJson

func (i *Infra) WriteJson(p string, d interface{})

type LambdaDeployments

type LambdaDeployments interface {
	Compile(data sls.BuildSettings) (sls.BuildResult, error)
	UpdateCode(ctx context.Context, payload lambda.CodePayload) (*lambda.FeatureUpdateReport, error)
	UpdateConfig(ctx context.Context, in lambda.FeatureSettings) (*lambda.FeatureUpdateReport, error)
}

type PStoreBind

type PStoreBind struct {
	IsEncrypt bool `conf:"default:true, cli:encrypt, cli-u: use encryption for pstore"`
}

type PStoreConfig

type PStoreConfig struct {
	CmdConfig
	PStoreBind
}

type PStoreDeleteBind

type PStoreDeleteBind struct {
	IsAll     bool   `conf:"cli:all, cli-s: a, cli-u: delete all parameters for this micro-service"`
	IsEncrypt bool   `conf:"default:true, cli:encrypt, cli-u: use encryption for pstore"`
	Feature   string `conf:"cli:feature, cli-u: delete only params for the given feature"`
}

type PStoreDeleteConfig

type PStoreDeleteConfig struct {
	CmdConfig
	PStoreDeleteBind
}

type PStoreExportBind

type PStoreExportBind struct {
	File      Filepath `conf:"cli:file, cli-s:f, cli-u:Export to a json file"`
	IsEncrypt bool     `conf:"default:true, cli:encrypt, cli-u: use encryption for pstore"`
	StdOut    bool     `conf:"cli:stdout, cli-u: Importing values from env vars on you machine"`
}

type PStoreExportConfig

type PStoreExportConfig struct {
	CmdConfig
	PStoreExportBind
}

type PStoreImportBind

type PStoreImportBind struct {
	File          Filepath `conf:"cli:file, cli-s:f, cli-u:Importing values from a json file"`
	ImportFromEnv bool     `conf:"cli:env, cli-u: Importing values from env vars on you machine"`
	IsEncrypt     bool     `conf:"default:true, cli:encrypt, cli-u: use encryption for pstore"`
	Overwrite     bool     `conf:"cli:overwrite, cli-u: Used to replace values that already exist in parameter store"`
}

type PStoreImportConfig

type PStoreImportConfig struct {
	CmdConfig
	PStoreImportBind
}

type ParamStorage

type ParamStorage interface {
	Param(ctx context.Context, key string) (string, error)
	Path(ctx context.Context, path string, recursive ...bool) (map[string]string, error)
	Collect(ctx context.Context, key ...string) (map[string]string, []string, error)
	Delete(ctx context.Context, key string) (string, error)
	Put(ctx context.Context, key, value string, overwrite ...bool) (string, error)
	EnsurePathPrefix(path string) string
}

Jump to

Keyboard shortcuts

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