Documentation ¶
Index ¶
- Constants
- Variables
- func AddQuotes(s string) string
- func AdjustAwsString(s string) string
- func BuildFromTemplate(templateString, buildFolder, fileName string, config any) (err error)
- func CollectCraftNames(path string, names map[string]bool) (err error)
- func DeleteFiles(folder, wildcard string) (err error)
- func ExpandEnvInFileNames(files []string)
- func FileExists(path string) bool
- func GetAbsoluteCraftPath(path string) (string, error)
- func GetBuildFolder(craftName string) (buildFolder string, err error)
- func GetCraftPath(args []string) (path string, err error)
- func GetEnvMapFromFiles(files []string) (envMap map[string]string, err error)
- func GetTerraformOutputs(folder string, outputs map[string]string) (err error)
- func HashOfFolder(folder string) (string, error)
- func ListServices(craftPath string) error
- func NameOnly(path string) string
- func QuotedArray(arr []string) string
- func ReadEnvFile(name string, envMap map[string]string) error
- func RemoveFileExtension(fileName string) string
- func RemoveQuotes(s string) (string, bool)
- func RunTerraformCommand(folder string, command []string) error
- func SetBackend(backendS string) error
- func SetDefaultRootFolder()
- func SetOsEnvsFromCraft(craftPath string) (err error)
- func SetRootFolder(args []string)
- func StringFromTemplate(templateString string, config any) (s string, err error)
- func TerraformDeploy(buildFolder, craftName string) (err error)
- func ToAbsPathBasedOn(base, path string) string
- func TrimAndRemoveQuotes(s string) string
- func WriteFargateFile(buildFolder, file, content string) (err error)
- func WriteStringToFile(path, content string) (err error)
- type BackendConfig
- type Config
- func (cfg *Config) BuildEcs() (err error)
- func (cfg *Config) BuildFromRecipeTemplate(templateString, fileName string) (err error)
- func (cfg *Config) BuildFromServiceTemplate(templateString, fileName string, services Services) (err error)
- func (cfg *Config) BuildFromTemplate(templateString, fileName string, config any) (err error)
- func (cfg *Config) BuildLambda() (err error)
- func (cfg *Config) BuildNetwork() (err error)
- func (cfg *Config) BuildSliceFromTemplate(templateString, fileName string, slice []any) (err error)
- func (cfg *Config) GetEcsRecipe() *EcsRecipe
- func (cfg *Config) GetLambdaRecipe() *LambdaRecipe
- func (config *Config) GetMqs(services Services) (mqsMap map[string]Mq, servs Services, err error)
- func (cfg *Config) GetNetworkRecipe() *NetworkRecipe
- func (cfg *Config) GetPortsFor(name string) (ports map[int]bool)
- func (config *Config) GetRds(services Services) (rdsMap map[string]Rdb, servs Services, err error)
- func (config *Config) ProcessAllServices() (fargate Services, rdsMap map[string]Rdb, mqsMap map[string]Mq, err error)
- type Craft
- type CraftSection
- type Creds
- type DataBaseTemplate
- type DbItems
- type EcsRecipe
- type EcsService
- type External
- type HealthCheck
- type LambdaRecipe
- type LambdaTriggers
- type Mq
- type MqItems
- type Network
- type NetworkRecipe
- type Ports
- type Rdb
- type RecipeServiceItems
- type Service
- func (serv *Service) ComputeDependsOn(nameToService map[string]*Service, rdsMap map[string]Rdb, mqsMap map[string]Mq) error
- func (srv *Service) CreateEnvsString()
- func (serv *Service) ProcessImage() error
- func (srv *Service) ReadEnvFile(name string) error
- func (svc *Service) UpdateFromRecipe(cfg *Config) error
- type Services
- type SimpleEcs
- type SimpleLambda
- type SimpleMqs
- type SimpleRds
- type StringPair
Constants ¶
Variables ¶
var ForceRebuild bool
ForceRebuild is a flag to force the rebuild of the docker images even if no code change is detected
var RootFolder = "."
RootFolder is the absolute path of the root folder of the Infractl tree
var RootParent = ""
Functions ¶
func AdjustAwsString ¶
func BuildFromTemplate ¶
func DeleteFiles ¶
func ExpandEnvInFileNames ¶
func ExpandEnvInFileNames(files []string)
func GetAbsoluteCraftPath ¶
func GetBuildFolder ¶
func GetCraftPath ¶
GetCraftPath returns the craft absolute path from the command line arguments and sets the root folder
func GetEnvMapFromFiles ¶
GetEnvMapFromFiles assumes that relative names refer to root parent
func GetTerraformOutputs ¶
func HashOfFolder ¶
HashOfFolder computes a hash of files in the folder, 16 hex characters This is used to determine if the folder has changed
func ListServices ¶
func QuotedArray ¶
func ReadEnvFile ¶
ReadEnvFile reads a file of format name=value and adds to envMap
func RemoveFileExtension ¶
func RemoveQuotes ¶
RemoveQuotes removes quotes from a string if present and returns the string and true if quotes were removed
func RunTerraformCommand ¶
RunTerraformCommand runs a terraform command in a folder
func SetBackend ¶
func SetDefaultRootFolder ¶
func SetDefaultRootFolder()
func SetOsEnvsFromCraft ¶
func SetRootFolder ¶
func SetRootFolder(args []string)
func StringFromTemplate ¶
func TerraformDeploy ¶
func ToAbsPathBasedOn ¶
func TrimAndRemoveQuotes ¶
func WriteFargateFile ¶
func WriteStringToFile ¶
Types ¶
type BackendConfig ¶
var Backend *BackendConfig
type Config ¶
type Config struct { Compose *types.Project // From compose file Recipe any // ECSRecipe or NetworkRecipe NameToService map[string]*Service BuildFolder string // The Terraform outputs to be used as environment variables in other crafts // The first key is the craft name, the second key is the output name OutputsMap map[string]map[string]string }
Config is top level collection of configuration info
func (*Config) BuildEcs ¶
BuildEcs creates the Terraform files from the Fargate templates configPath is the Infragraph configuration
func (*Config) BuildFromRecipeTemplate ¶
func (*Config) BuildFromServiceTemplate ¶
func (*Config) BuildFromTemplate ¶
func (*Config) BuildLambda ¶
func (*Config) BuildNetwork ¶
func (*Config) BuildSliceFromTemplate ¶
func (*Config) GetEcsRecipe ¶
func (*Config) GetLambdaRecipe ¶
func (cfg *Config) GetLambdaRecipe() *LambdaRecipe
func (*Config) GetMqs ¶
GetMqs returns the message queues defined in the simple_mqs section of the recipe and removes them from the services
func (*Config) GetNetworkRecipe ¶
func (cfg *Config) GetNetworkRecipe() *NetworkRecipe
type Craft ¶
type Craft interface { GetCraftSection() *CraftSection GetCreds() *Creds }
type CraftSection ¶
type CraftSection struct { RecipeVersion string `yaml:"recipe_version"` Type string `yaml:"type"` // ecs, network, lambda InfraEnvFile string `yaml:"infra_env_file"` DockerComposeFiles []string `yaml:"docker_compose_files"` NetworkCraftFile string `yaml:"network_craft_file"` Name string // The name of the craft file BackendConfig BackendConfig // optional }
func (*CraftSection) ExpandEnvsInFileNames ¶
func (cs *CraftSection) ExpandEnvsInFileNames()
type Creds ¶
type DataBaseTemplate ¶
type EcsRecipe ¶
type EcsRecipe struct { CraftSection `yaml:"craft"` SimpleEcs SimpleEcs `yaml:"simple_ecs"` SimpleRds SimpleRds `yaml:"simple_rds"` SimpleMqs SimpleMqs `yaml:"simple_mqs"` Externals []External `yaml:"externals"` Creds `yaml:"credentials"` Network Network // Not in craft file }
func NewEcsCraft ¶
func (*EcsRecipe) BuildAndDeploy ¶
func (ecs *EcsRecipe) BuildAndDeploy(craftPath, externalName string, outputs map[string]map[string]string) error
BuildAndDeploy builds the Terraform files, deploys them and collects outputs into the outputs map
func (*EcsRecipe) GetCraftSection ¶
func (ecs *EcsRecipe) GetCraftSection() *CraftSection
type EcsService ¶
type LambdaRecipe ¶
type LambdaRecipe struct { CraftSection `yaml:"craft"` Network Network `yaml:"network"` SimpleLambda SimpleLambda `yaml:"simple_lambda"` Creds `yaml:"credentials"` }
func (*LambdaRecipe) BuildAndDeploy ¶
func (lam *LambdaRecipe) BuildAndDeploy(craftPath string, outputs map[string]map[string]string) error
BuildAndDeploy builds the Terraform files, deploys them and collects outputs into the outputs map
func (*LambdaRecipe) GetCraftSection ¶
func (lam *LambdaRecipe) GetCraftSection() *CraftSection
func (*LambdaRecipe) GetCreds ¶
func (lam *LambdaRecipe) GetCreds() *Creds
type LambdaTriggers ¶
type Mq ¶
type Mq struct { Name string // From service name in compose file Engine string // from craft file Public bool // from craft file UserName string // from envs Password string // from envs }
Mq is a managed message queue
type NetworkRecipe ¶
type NetworkRecipe struct { CraftSection `yaml:"craft"` Network Network `yaml:"network"` Creds `yaml:"credentials"` }
func NewNetworkCraft ¶
func NewNetworkCraft(path string) (*NetworkRecipe, error)
func (*NetworkRecipe) BuildAndDeploy ¶
func (net *NetworkRecipe) BuildAndDeploy(craftPath string, outputs map[string]map[string]string) error
BuildAndDeploy builds the Terraform files, deploys them and collects outputs into the outputs map
func (*NetworkRecipe) GetCraftSection ¶
func (net *NetworkRecipe) GetCraftSection() *CraftSection
func (*NetworkRecipe) GetCreds ¶
func (net *NetworkRecipe) GetCreds() *Creds
type Ports ¶
Ports is mapping the ports on the task or load balancer For Fargate task, both bort must be the same
func PortsFromString ¶
PortsFromString constructs Ports from a colon separate pair
type Rdb ¶
type Rdb struct { Name string // From service name in compose file DbEngine string DbName string UserName string Password string Port int Public bool MachineType string StorageType string StorageIops int StorageGigs int }
Rdb is a managed relational database
type RecipeServiceItems ¶
type RecipeServiceItems struct { DesiredNodes int `yaml:"desired_nodes"` Cpu int `yaml:"cpu"` Memory int `yaml:"memory"` DomainName string `yaml:"domain_name"` LoadBalancerHttp []string `yaml:"load_balancer_http"` LoadBalancerHttps []string `yaml:"load_balancer_https"` Environment map[string]string `yaml:"environment"` EnvFiles []string `yaml:"env_files"` DependsOn []string `yaml:"depends_on"` }
RecipeServiceItems is the configuration for each service from the recipe
type Service ¶
type Service struct { Name string Ports []Ports DbPort int LoadBalancerPortsTCP []Ports LoadBalancerPortsTLS []Ports LoadBalacerTargets []int NeedsCertificate bool Memory int // in MiB Cpu int // 1024 = 1vCPU DesiredCount int EnvsString string Entrypoint string IsOnlyService bool // true if there is only one service in the compose file BuildContext string // folder of where the build is done BuildHash string // hash of the build context TaskHash string // the last 10 characters of BuildHash BuildDockerfile string // name of Dockerfile BuildTarget string Image string // either a docker registry image or an ECR image after build and push DependsOn string HealthCheck HealthCheck DomainName string HostedZone string // contains filtered or unexported fields }
func (*Service) ComputeDependsOn ¶
func (*Service) CreateEnvsString ¶
func (srv *Service) CreateEnvsString()
func (*Service) ProcessImage ¶
func (*Service) ReadEnvFile ¶
ReadEnvFile reads a file of format name=value
func (*Service) UpdateFromRecipe ¶
UpdateFromRecipe updates the service from new data in the recipe
type SimpleEcs ¶
type SimpleEcs struct { Type string `yaml:"type"` // fargate or EC2 MachineType string `yaml:"machine_type"` // only for EC2 Services map[string]RecipeServiceItems `yaml:"services"` }
type SimpleLambda ¶
type SimpleLambda struct { FunctionName string `yaml:"function_name"` Handler string `yaml:"handler"` Runtime string `yaml:"runtime"` SourceFolder string `yaml:"source_folder"` MemorySize int `yaml:"memory_size"` Timeout int `yaml:"timeout"` EphemeralStorage int `yaml:"ephemeral_storage"` LambdaTriggers `yaml:"triggers"` Environment map[string]string `yaml:"environment"` EnvFiles []string `yaml:"env_files"` Layers []string `yaml:"layers"` EnvsString string // Constructed LayersString string // Constructed BuildFolder string // Constructed }
type StringPair ¶
Source Files ¶
- build.go
- build_utils.go
- config.go
- const.go
- constructors.go
- craft.go
- craft_types.go
- ecs_build_and_deploy.go
- envs.go
- hash_of_folder.go
- interfaces.go
- lambda_build_and_deploy.go
- list_services.go
- mqs.go
- net_build_and_deploy.go
- new_lambda_craft.go
- parameters.go
- rds.go
- service.go
- terraform.go
- types.go
- utils.go
- vars.go