config

package
v0.0.0-...-004cd70 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: GPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_DOCKER_SECRET_LENGTH = 64
View Source
const MAX_SANITISED_APP_NAME_LENGTH = 45

Variables

View Source
var ABRA_DIR = getBaseDir()
View Source
var BACKUP_DIR = path.Join(ABRA_DIR, "backups")
View Source
var BackupbotLabel = "coop-cloud.backupbot.enabled"
View Source
var CATALOGUE_DIR = path.Join(ABRA_DIR, "catalogue")
View Source
var CATALOGUE_JSON_REPO_NAME = "recipes-catalogue-json"
View Source
var RECIPES_DIR = path.Join(ABRA_DIR, "recipes")
View Source
var RECIPES_JSON = path.Join(ABRA_DIR, "catalogue", "recipes.json")
View Source
var REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud"
View Source
var SERVERS_DIR = path.Join(ABRA_DIR, "servers")
View Source
var SSH_URL_TEMPLATE = "ssh://git@git.coopcloud.tech:2222/coop-cloud/%s.git"
View Source
var VENDOR_DIR = path.Join(ABRA_DIR, "vendor")

Functions

func ExposeAllEnv

func ExposeAllEnv(stackName string, compose *composetypes.Config, appEnv AppEnv)

ExposeAllEnv exposes all env variables to the app container

func GetAllFilesInDirectory

func GetAllFilesInDirectory(directory string) ([]fs.FileInfo, error)

GetAllFilesInDirectory returns filenames of all files in directory

func GetAllFoldersInDirectory

func GetAllFoldersInDirectory(directory string) ([]string, error)

GetAllFoldersInDirectory returns both folder and symlink paths

func GetAppComposeConfig

func GetAppComposeConfig(recipe string, opts stack.Deploy, appEnv AppEnv) (*composetypes.Config, error)

GetAppComposeConfig retrieves a compose specification for a recipe. This specification is the result of a merge of all the compose.**.yml files in the recipe repository.

func GetAppNames

func GetAppNames() ([]string, error)

GetAppNames retrieves a list of app names.

func GetAppServiceNames

func GetAppServiceNames(appName string) ([]string, error)

GetAppServiceNames retrieves a list of app service names.

func GetAppStatuses

func GetAppStatuses(apps []App, MachineReadable bool) (map[string]map[string]string, error)

GetAppStatuses queries servers to check the deployment status of given apps.

func GetComposeFiles

func GetComposeFiles(recipe string, appEnv AppEnv) ([]string, error)

GetComposeFiles gets the list of compose files for an app (or recipe if you don't already have an app) which should be merged into a composetypes.Config while respecting the COMPOSE_FILE env var.

func GetLabel

func GetLabel(compose *composetypes.Config, stackName string, label string) string

GetLabel reads docker labels in the format of "coop-cloud.${STACK_NAME}.${LABEL}" from the local compose files

func GetServers

func GetServers() ([]string, error)

GetServers retrieves all servers.

func GetTimeoutFromLabel

func GetTimeoutFromLabel(compose *composetypes.Config, stackName string) (int, error)

GetTimeoutFromLabel reads the timeout value from docker label "coop-cloud.${STACK_NAME}.TIMEOUT" and returns 50 as default value

func ReadAbraShCmdNames

func ReadAbraShCmdNames(abraSh string) ([]string, error)

ReadAbraShCmdNames reads the names of commands.

func ReadAbraShEnvVars

func ReadAbraShEnvVars(abraSh string) (map[string]string, error)

ReadAbraShEnvVars reads env vars from an abra.sh recipe file.

func ReadEnvWithModifiers

func ReadEnvWithModifiers(filePath string) (AppEnv, AppModifiers, error)

ReadEnv loads an app envivornment and their modifiers in two different maps.

func ReadServerNames

func ReadServerNames() ([]string, error)

ReadServerNames retrieves all server names.

func SanitiseAppName

func SanitiseAppName(name string) string

SanitiseAppName makes a app name usable with Docker by replacing illegal characters.

func ServiceFilter

func ServiceFilter(stack, service string, exact bool) string

ServiceFilter creates a filter string for filtering a service in the docker container runtime. When exact match is true, it uses regex to match the string exactly.

func SetChaosLabel

func SetChaosLabel(compose *composetypes.Config, stackName string, chaos bool)

SetChaosLabel adds the label 'coop-cloud.${STACK_NAME}.chaos=true/false' to the app container to signal if the app is deployed in chaos mode

func SetChaosVersionLabel

func SetChaosVersionLabel(compose *composetypes.Config, stackName string, chaosVersion string)

SetChaosVersionLabel adds the label 'coop-cloud.${STACK_NAME}.chaos-version=$(GIT_COMMIT)' to the app container

func SetRecipeLabel

func SetRecipeLabel(compose *composetypes.Config, stackName string, recipe string)

SetRecipeLabel adds the label 'coop-cloud.${STACK_NAME}.recipe=${RECIPE}' to the app container to signal which recipe is connected to the deployed app

func SetUpdateLabel

func SetUpdateLabel(compose *composetypes.Config, stackName string, appEnv AppEnv)

SetUpdateLabel adds env ENABLE_AUTO_UPDATE as label to enable/disable the auto update process for this app. The default if this variable is not set is to disable the auto update process.

func StackName

func StackName(appName string) string

StackName gets whatever the docker safe (uses the right delimiting character, e.g. "_") stack name is for the app. In general, you don't want to use this to show anything to end-users, you want use a.Name instead.

func TemplateAppEnvSample

func TemplateAppEnvSample(recipeName, appName, server, domain string) error

TemplateAppEnvSample copies the example env file for the app into the users env files.

Types

type App

type App struct {
	Name   AppName
	Recipe string
	Domain string
	Env    AppEnv
	Server string
	Path   string
}

App reprents an app with its env file read into memory

func GetApp

func GetApp(apps AppFiles, name AppName) (App, error)

GetApp loads an apps settings, reading it from file, in preparation to use it. It should only be used when ready to use the env file to keep IO operations down.

func GetApps

func GetApps(appFiles AppFiles, recipeFilter string) ([]App, error)

GetApps returns a slice of Apps with their env files read from a given slice of AppFiles.

func NewApp

func NewApp(env AppEnv, name string, appFile AppFile) (App, error)

NewApp creates new App object

func ReadAppEnvFile

func ReadAppEnvFile(appFile AppFile, name AppName) (App, error)

func (App) Filters

func (a App) Filters(appendServiceNames, exactMatch bool, services ...string) (filters.Args, error)

Filters retrieves app filters for querying the container runtime. By default it filters on all services in the app. It is also possible to pass an otional list of service names, which get filtered instead.

Due to upstream issues, filtering works different depending on what you're querying. So, for example, secrets don't work with regex! The caller needs to implement their own validation that the right secrets are matched. In order to handle these cases, we provide the `appendServiceNames` / `exactMatch` modifiers.

func (App) StackName

func (a App) StackName() string

See documentation of config.StackName

type AppEnv

type AppEnv = map[string]string

AppEnv is a map of the values in an apps env config

func ReadEnv

func ReadEnv(filePath string) (AppEnv, error)

ReadEnv loads an app envivornment into a map.

type AppFile

type AppFile struct {
	Path   string
	Server string
}

AppFile represents app env files on disk without reading the contents

type AppFiles

type AppFiles map[AppName]AppFile

AppFiles is a slice of appfiles

func LoadAppFiles

func LoadAppFiles(servers ...string) (AppFiles, error)

LoadAppFiles gets all app files for a given set of servers or all servers.

type AppModifiers

type AppModifiers = map[string]map[string]string

AppModifiers is a map of modifiers in an apps env config

type AppName

type AppName = string

AppName is AppName

type ByName

type ByName []App

ByName sort a slice of Apps

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type ByRecipe

type ByRecipe []App

ByRecipe sort a slice of Apps

func (ByRecipe) Len

func (a ByRecipe) Len() int

func (ByRecipe) Less

func (a ByRecipe) Less(i, j int) bool

func (ByRecipe) Swap

func (a ByRecipe) Swap(i, j int)

type ByServer

type ByServer []App

ByServer sort a slice of Apps

func (ByServer) Len

func (a ByServer) Len() int

func (ByServer) Less

func (a ByServer) Less(i, j int) bool

func (ByServer) Swap

func (a ByServer) Swap(i, j int)

type ByServerAndRecipe

type ByServerAndRecipe []App

ByServerAndRecipe sort a slice of Apps

func (ByServerAndRecipe) Len

func (a ByServerAndRecipe) Len() int

func (ByServerAndRecipe) Less

func (a ByServerAndRecipe) Less(i, j int) bool

func (ByServerAndRecipe) Swap

func (a ByServerAndRecipe) Swap(i, j int)

type EnvVar

type EnvVar struct {
	Name    string
	Present bool
}

func CheckEnv

func CheckEnv(app App) ([]EnvVar, error)

Jump to

Keyboard shortcuts

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