parser

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProfilePath

func GetProfilePath() (string, error)

GetProfilePath returns the path to the profile file in the user's home directory

func LoadEnvVarsFromFile

func LoadEnvVarsFromFile(envFile string) (map[string]string, error)

LoadEnvVarsFromFile reads environment variables from the specified file and returns them as a map

func SaveProfile

func SaveProfile(profile *Profile, profilePath string) error

SaveProfile saves the profile to the specified path

Types

type AppService

type AppService struct {
	ResourceGroupName  string `toml:"resource_group_name"`
	AppServicePlanName string `toml:"app_service_plan_name"`
	AppServiceName     string `toml:"app_service_name"`
}

type CloudResource

type CloudResource 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"`
		} `mapstructure:"provider"`
	} `mapstructure:"deploy"`
	Tags map[string]*string `mapstructure:"tags"`
}

func LoadConfig

func LoadConfig(filePath string) (*Config, error)

func (*Config) IsAppServiceSet

func (config *Config) IsAppServiceSet() bool

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

func (config *Config) IsContainerInstanceSet() bool

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

func (config *Config) IsNgrokConfigured() bool

type ContainerInstance

type ContainerInstance struct {
	ResourceGroupName     string `toml:"resource_group_name"`
	ContainerInstanceName string `toml:"container_instance_name"`
}

type LocalRegistry

type LocalRegistry struct {
	RegistryID string `toml:"registry_id"`
	Username   string `toml:"username"`
	Password   string `toml:"password"`
}

type Profile

type Profile struct {
	LocalRegistry *LocalRegistry `toml:"local_registry,omitempty"`
	Tunnel        *Tunnel        `toml:"tunnel,omitempty"`
	CloudResource *CloudResource `toml:"cloud_resource,omitempty"`
}

func LoadOrCreateProfile

func LoadOrCreateProfile(profilePath string) (*Profile, error)

LoadOrCreateProfile loads an existing profile or creates a new one if it doesn't exist

func LoadProfileData

func LoadProfileData() (*Profile, string)

type Tunnel

type Tunnel struct {
	URL         string `toml:"tunnel_url"`
	ContainerID string `toml:"tunnel_container_id"`
}

Jump to

Keyboard shortcuts

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