forked from toolshed/abra
refactor!: type -> recipes
This commit is contained in:
@ -36,7 +36,7 @@ type AppFiles map[AppName]AppFile
|
||||
// App reprents an app with its env file read into memory
|
||||
type App struct {
|
||||
Name AppName
|
||||
Type string
|
||||
Recipe string
|
||||
Domain string
|
||||
Env AppEnv
|
||||
Server string
|
||||
@ -63,8 +63,6 @@ func (a App) StackName() string {
|
||||
return stackName
|
||||
}
|
||||
|
||||
// SORTING TYPES
|
||||
|
||||
// ByServer sort a slice of Apps
|
||||
type ByServer []App
|
||||
|
||||
@ -74,25 +72,25 @@ func (a ByServer) Less(i, j int) bool {
|
||||
return strings.ToLower(a[i].Server) < strings.ToLower(a[j].Server)
|
||||
}
|
||||
|
||||
// ByServerAndType sort a slice of Apps
|
||||
type ByServerAndType []App
|
||||
// ByServerAndRecipe sort a slice of Apps
|
||||
type ByServerAndRecipe []App
|
||||
|
||||
func (a ByServerAndType) Len() int { return len(a) }
|
||||
func (a ByServerAndType) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByServerAndType) Less(i, j int) bool {
|
||||
func (a ByServerAndRecipe) Len() int { return len(a) }
|
||||
func (a ByServerAndRecipe) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByServerAndRecipe) Less(i, j int) bool {
|
||||
if a[i].Server == a[j].Server {
|
||||
return strings.ToLower(a[i].Type) < strings.ToLower(a[j].Type)
|
||||
return strings.ToLower(a[i].Recipe) < strings.ToLower(a[j].Recipe)
|
||||
}
|
||||
return strings.ToLower(a[i].Server) < strings.ToLower(a[j].Server)
|
||||
}
|
||||
|
||||
// ByType sort a slice of Apps
|
||||
type ByType []App
|
||||
// ByRecipe sort a slice of Apps
|
||||
type ByRecipe []App
|
||||
|
||||
func (a ByType) Len() int { return len(a) }
|
||||
func (a ByType) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByType) Less(i, j int) bool {
|
||||
return strings.ToLower(a[i].Type) < strings.ToLower(a[j].Type)
|
||||
func (a ByRecipe) Len() int { return len(a) }
|
||||
func (a ByRecipe) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByRecipe) Less(i, j int) bool {
|
||||
return strings.ToLower(a[i].Recipe) < strings.ToLower(a[j].Recipe)
|
||||
}
|
||||
|
||||
// ByName sort a slice of Apps
|
||||
@ -124,15 +122,15 @@ func readAppEnvFile(appFile AppFile, name AppName) (App, error) {
|
||||
func newApp(env AppEnv, name string, appFile AppFile) (App, error) {
|
||||
domain := env["DOMAIN"]
|
||||
|
||||
appType, exists := env["TYPE"]
|
||||
recipe, exists := env["RECIPE"]
|
||||
if !exists {
|
||||
return App{}, fmt.Errorf("%s is missing the TYPE env var", name)
|
||||
return App{}, fmt.Errorf("%s is missing the RECIPE env var", name)
|
||||
}
|
||||
|
||||
return App{
|
||||
Name: name,
|
||||
Domain: domain,
|
||||
Type: appType,
|
||||
Recipe: recipe,
|
||||
Env: env,
|
||||
Server: appFile.Server,
|
||||
Path: appFile.Path,
|
||||
@ -219,13 +217,13 @@ func GetAppServiceNames(appName string) ([]string, error) {
|
||||
return serviceNames, err
|
||||
}
|
||||
|
||||
composeFiles, err := GetAppComposeFiles(app.Type, app.Env)
|
||||
composeFiles, err := GetAppComposeFiles(app.Recipe, app.Env)
|
||||
if err != nil {
|
||||
return serviceNames, err
|
||||
}
|
||||
|
||||
opts := stack.Deploy{Composefiles: composeFiles}
|
||||
compose, err := GetAppComposeConfig(app.Type, opts, app.Env)
|
||||
compose, err := GetAppComposeConfig(app.Recipe, opts, app.Env)
|
||||
if err != nil {
|
||||
return serviceNames, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user