refactor: use app getting instead of boilerplate

This commit is contained in:
2021-09-05 23:17:35 +02:00
parent 48bcc9cb36
commit d4333c2dc0
18 changed files with 111 additions and 266 deletions

View File

@ -40,7 +40,8 @@ type App struct {
Type string
Domain string
Env AppEnv
File AppFile
Server string
Path string
}
// StackName gets what the docker safe stack name is for the app
@ -56,7 +57,7 @@ type ByServer []App
func (a ByServer) Len() int { return len(a) }
func (a ByServer) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByServer) Less(i, j int) bool {
return strings.ToLower(a[i].File.Server) < strings.ToLower(a[j].File.Server)
return strings.ToLower(a[i].Server) < strings.ToLower(a[j].Server)
}
// ByServerAndType sort a slice of Apps
@ -65,10 +66,10 @@ type ByServerAndType []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 {
if a[i].File.Server == a[j].File.Server {
if a[i].Server == a[j].Server {
return strings.ToLower(a[i].Type) < strings.ToLower(a[j].Type)
}
return strings.ToLower(a[i].File.Server) < strings.ToLower(a[j].File.Server)
return strings.ToLower(a[i].Server) < strings.ToLower(a[j].Server)
}
// ByType sort a slice of Apps
@ -114,7 +115,8 @@ func newApp(env AppEnv, name string, appFile AppFile) (App, error) {
Domain: domain,
Type: apptype,
Env: env,
File: appFile,
Server: appFile.Server,
Path: appFile.Path,
}, nil
}