refactor: move app files from config to app package
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
appPkg "coopcloud.tech/abra/pkg/app"
|
||||
"coopcloud.tech/abra/pkg/client"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
"coopcloud.tech/abra/pkg/lint"
|
||||
@ -192,7 +193,7 @@ func getBoolLabel(cl *dockerclient.Client, stackName string, label string) (bool
|
||||
}
|
||||
|
||||
// getEnv reads env variables from docker services.
|
||||
func getEnv(cl *dockerclient.Client, stackName string) (config.AppEnv, error) {
|
||||
func getEnv(cl *dockerclient.Client, stackName string) (appPkg.AppEnv, error) {
|
||||
envMap := make(map[string]string)
|
||||
filter := filters.NewArgs()
|
||||
filter.Add("label", fmt.Sprintf("%s=%s", convert.LabelNamespace, stackName))
|
||||
@ -339,9 +340,9 @@ func processRecipeRepoVersion(recipeName, version string) error {
|
||||
}
|
||||
|
||||
// mergeAbraShEnv merges abra.sh env vars into the app env vars.
|
||||
func mergeAbraShEnv(recipeName string, env config.AppEnv) error {
|
||||
func mergeAbraShEnv(recipeName string, env appPkg.AppEnv) error {
|
||||
abraShPath := fmt.Sprintf("%s/%s/%s", config.RECIPES_DIR, recipeName, "abra.sh")
|
||||
abraShEnv, err := config.ReadAbraShEnvVars(abraShPath)
|
||||
abraShEnv, err := appPkg.ReadAbraShEnvVars(abraShPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -355,7 +356,7 @@ func mergeAbraShEnv(recipeName string, env config.AppEnv) error {
|
||||
}
|
||||
|
||||
// createDeployConfig merges and enriches the compose config for the deployment.
|
||||
func createDeployConfig(recipeName string, stackName string, env config.AppEnv) (*composetypes.Config, stack.Deploy, error) {
|
||||
func createDeployConfig(recipeName string, stackName string, env appPkg.AppEnv) (*composetypes.Config, stack.Deploy, error) {
|
||||
env["STACK_NAME"] = stackName
|
||||
|
||||
deployOpts := stack.Deploy{
|
||||
@ -365,23 +366,23 @@ func createDeployConfig(recipeName string, stackName string, env config.AppEnv)
|
||||
Detach: false,
|
||||
}
|
||||
|
||||
composeFiles, err := config.GetComposeFiles(recipeName, env)
|
||||
composeFiles, err := appPkg.GetComposeFiles(recipeName, env)
|
||||
if err != nil {
|
||||
return nil, deployOpts, err
|
||||
}
|
||||
|
||||
deployOpts.Composefiles = composeFiles
|
||||
compose, err := config.GetAppComposeConfig(stackName, deployOpts, env)
|
||||
compose, err := appPkg.GetAppComposeConfig(stackName, deployOpts, env)
|
||||
if err != nil {
|
||||
return nil, deployOpts, err
|
||||
}
|
||||
|
||||
config.ExposeAllEnv(stackName, compose, env)
|
||||
appPkg.ExposeAllEnv(stackName, compose, env)
|
||||
|
||||
// after the upgrade the deployment won't be in chaos state anymore
|
||||
config.SetChaosLabel(compose, stackName, false)
|
||||
config.SetRecipeLabel(compose, stackName, recipeName)
|
||||
config.SetUpdateLabel(compose, stackName, env)
|
||||
appPkg.SetChaosLabel(compose, stackName, false)
|
||||
appPkg.SetRecipeLabel(compose, stackName, recipeName)
|
||||
appPkg.SetUpdateLabel(compose, stackName, env)
|
||||
|
||||
return compose, deployOpts, nil
|
||||
}
|
||||
@ -436,7 +437,7 @@ func upgrade(cl *dockerclient.Client, stackName, recipeName,
|
||||
return err
|
||||
}
|
||||
|
||||
app := config.App{
|
||||
app := appPkg.App{
|
||||
Name: stackName,
|
||||
Recipe: recipeName,
|
||||
Server: SERVER,
|
||||
|
Reference in New Issue
Block a user