Documentation
¶
Index ¶
- func GenerateRandomString(length int) string
- func GetProfilePath() (string, error)
- func LoadEnvVarsFromFile(envFile string) (map[string]string, error)
- func SaveProfile(profile *Profile, profilePath string) error
- type AWSCloudResource
- type AppService
- type AzureCloudResource
- type Config
- func (config *Config) GenerateContainerPorts() []types.PortMapping
- func (config *Config) GenerateECSTags() []types.Tag
- func (config *Config) GenerateRulesForSG() []ec2Types.IpPermission
- func (config *Config) GenerateSecretTags() []secretsTypes.Tag
- func (config *Config) GenerateVPCTags(tagResourceType ec2Types.ResourceType) []ec2Types.TagSpecification
- func (config *Config) GetRegistryImage() string
- func (config *Config) IsAppServiceSet() bool
- func (config *Config) IsContainerInstanceSet() bool
- func (config *Config) IsNgrokConfigured() bool
- type ContainerInstance
- type ECS
- type LocalRegistry
- type Profile
- type Tunnel
- type VPC
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRandomString ¶ added in v0.2.0
func GetProfilePath ¶
GetProfilePath returns the path to the profile file in the user's home directory
func LoadEnvVarsFromFile ¶
LoadEnvVarsFromFile reads environment variables from the specified file and returns them as a map
func SaveProfile ¶
SaveProfile saves the profile to the specified path
Types ¶
type AWSCloudResource ¶ added in v0.2.0
type AppService ¶
type AzureCloudResource ¶ added in v0.2.0
type AzureCloudResource struct {
AppService *AppService `toml:"app_service,omitempty"`
ContainerInstance *ContainerInstance `toml:"container_instance,omitempty"`
}
type Config ¶
type Config struct {
Registry struct {
Port int `mapstructure:"port" default:"5000"`
Tag string `mapstructure:"tag" default:"2"`
Name string `mapstructure:"name" default:"locreg-registry"`
Image string `mapstructure:"image" default:"registry"`
Username string `mapstructure:"username"` // Set separately as should be unique each time
Password string `mapstructure:"password"` // Set separately as should be unique each time
} `mapstructure:"registry"`
Image struct {
Name string `mapstructure:"name" default:"locreg-built-image"`
Tag string `mapstructure:"tag"` // Set a git SHA if not peresent default to latest
} `mapstructure:"image"`
Tunnel struct {
Provider struct {
Ngrok struct {
Name string `mapstructure:"name" default:"locreg-ngrok"`
Image string `mapstructure:"image" default:"ngrok/ngrok"`
Tag string `mapstructure:"tag" default:"latest"`
Port int `mapstructure:"port" default:"4040"`
NetworkName string `mapstructure:"networkName" default:"locreg-ngrok"`
} `mapstructure:"ngrok"`
} `mapstructure:"provider"`
} `mapstructure:"tunnel"`
Deploy struct {
Provider struct {
Azure struct {
Location string `mapstructure:"location" default:"eastus"`
ResourceGroup string `mapstructure:"resourceGroup" default:"LocregResourceGroup"`
AppServicePlan struct {
Name string `mapstructure:"name" default:"LocregAppServicePlan"`
Sku struct {
Name string `mapstructure:"name" default:"F1"`
Capacity int `mapstructure:"capacity" default:"1"`
} `mapstructure:"sku"`
PlanProperties struct {
Reserved bool `mapstructure:"reserved" default:"true"`
} `mapstructure:"planProperties"`
} `mapstructure:"appServicePlan"`
AppService struct {
Name string `mapstructure:"name"` // Generated with random suffix
SiteConfig struct {
AlwaysOn bool `mapstructure:"alwaysOn" default:"false"`
} `mapstructure:"siteConfig"`
} `mapstructure:"appService"`
ContainerInstance struct {
Name string `mapstructure:"name" default:"locreg-container"`
OsType string `mapstructure:"osType" default:"Linux"`
RestartPolicy string `mapstructure:"restartPolicy" default:"Always"`
IPAddress struct {
Type string `mapstructure:"type" default:"Public"`
Ports []struct {
Port int `mapstructure:"port"`
Protocol string `mapstructure:"protocol"`
} `mapstructure:"ports"`
} `mapstructure:"ipAddress"`
Resources struct {
Requests struct {
CPU float64 `mapstructure:"cpu" default:"1.0"`
Memory float64 `mapstructure:"memory" default:"1.5"`
} `mapstructure:"requests"`
} `mapstructure:"resources"`
} `mapstructure:"containerInstance"`
} `mapstructure:"azure"`
AWS struct {
Region string `mapstructure:"region" default:"us-east-1"`
ECS struct {
ClusterName string `mapstructure:"clusterName" default:"locreg-cluster"`
ServiceName string `mapstructure:"serviceName" default:"locreg-service"`
ServiceContainerCount int `mapstructure:"serviceContainerCount" default:"1"`
TaskDefinition struct {
Family string `mapstructure:"family" default:"locreg-task"`
IAMRoleName string `mapstructure:"awsRoleName" default:"locreg-role"`
MemoryAllocation int `mapstructure:"memoryAllocation" default:"512"`
CPUAllocation int `mapstructure:"cpuAllocation" default:"256"`
ContainerDefinition struct {
Name string `mapstructure:"name" default:"locreg-container"`
PortMappings []struct {
ContainerPort int `mapstructure:"containerPort"`
HostPort int `mapstructure:"hostPort"`
Protocol string `mapstructure:"protocol"`
} `mapstructure:"portMappings"`
} `mapstructure:"containerDefinitions"`
} `mapstructure:"taskDefinition"`
} `mapstructure:"ecs"`
VPC struct {
CIDRBlock string `mapstructure:"cidrBlock" default:"10.10.0.0/16"`
Subnet struct {
CIDRBlock string `mapstructure:"cidrBlock" default:"10.10.10.0/24"`
} `mapstructure:"subnet"`
} `mapstructure:"vpc"`
} `mapstructure:"aws"`
} `mapstructure:"provider"`
} `mapstructure:"deploy"`
Tags map[string]*string `mapstructure:"tags"`
}
func LoadConfig ¶
func (*Config) GenerateContainerPorts ¶ added in v0.2.0
func (config *Config) GenerateContainerPorts() []types.PortMapping
GenerateContainerPorts generates the container ports mappings for the task definition
func (*Config) GenerateECSTags ¶ added in v0.2.0
GenerateECSTags generates tags for the ECS cluster and task definition that is created
func (*Config) GenerateRulesForSG ¶ added in v0.2.0
func (config *Config) GenerateRulesForSG() []ec2Types.IpPermission
GenerateRulesForSG generates ingress and egress rules for a default security group. Generate rules to allow traffic only to ports that are exposed on container
func (*Config) GenerateSecretTags ¶ added in v0.2.0
func (config *Config) GenerateSecretTags() []secretsTypes.Tag
GenerateSecretTags generates tags for the ECS cluster and task definition that is created
func (*Config) GenerateVPCTags ¶ added in v0.2.0
func (config *Config) GenerateVPCTags(tagResourceType ec2Types.ResourceType) []ec2Types.TagSpecification
GenerateVPCTags generates tags for the VPC and subnet and all other parts of networking that must be created
func (*Config) GetRegistryImage ¶ added in v0.2.0
GetRegistryImage returns the registry image with the tag
func (*Config) IsAppServiceSet ¶
IsAppServiceSet checks if the App Service configuration is set in the config. If it is set returns true if not returns false
func (*Config) IsContainerInstanceSet ¶
IsContainerInstanceSet checks if the Container Instance configuration is set in the config. If it is set returns true if not returns false
func (*Config) IsNgrokConfigured ¶
type ContainerInstance ¶
type LocalRegistry ¶
type Profile ¶
type Profile struct {
LocalRegistry *LocalRegistry `toml:"local_registry,omitempty"`
Tunnel *Tunnel `toml:"tunnel,omitempty"`
AzureCloudResource *AzureCloudResource `toml:"cloud_resource,omitempty"`
AWSCloudResource *AWSCloudResource `toml:"aws_cloud_resource,omitempty"`
}
func LoadOrCreateProfile ¶
LoadOrCreateProfile loads an existing profile or creates a new one if it doesn't exist
func LoadProfileData ¶
LoadProfileData loads the profile data from the user's home directory or creates what it is not found.
Newer version of LoadOrCreateProfile function