WIP heinous appEnv threading for env var loading
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
09873b42ce
commit
063fa66af9
|
@ -51,7 +51,7 @@ var appDeployCommand = &cli.Command{
|
||||||
Prune: false,
|
Prune: false,
|
||||||
ResolveImage: stack.ResolveImageAlways,
|
ResolveImage: stack.ResolveImageAlways,
|
||||||
}
|
}
|
||||||
compose, err := loader.LoadComposefile(deployOpts)
|
compose, err := loader.LoadComposefile(deployOpts, appEnv.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ var appVersionCommand = &cli.Command{
|
||||||
|
|
||||||
app := appFiles[appName]
|
app := appFiles[appName]
|
||||||
|
|
||||||
compose, err := config.GetAppComposeFiles(appEnv.Type)
|
compose, err := config.GetAppComposeFiles(appEnv.Type, appEnv.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,17 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||||
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
compose, err := config.GetAppComposeFiles(recipe)
|
appFiles, err := config.LoadAppFiles("")
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
appEnv, err := config.GetApp(appFiles, recipe)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
compose, err := config.GetAppComposeFiles(recipe, appEnv.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -263,7 +273,7 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := config.UpdateAppComposeTag(recipe, image, upgradeTag); err != nil {
|
if err := config.UpdateAppComposeTag(recipe, image, upgradeTag, appEnv.Env); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +302,17 @@ the versioning metadata of up-and-running containers are.
|
||||||
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
compose, err := config.GetAppComposeFiles(recipe)
|
appFiles, err := config.LoadAppFiles("")
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
appEnv, err := config.GetApp(appFiles, recipe)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
compose, err := config.GetAppComposeFiles(recipe, appEnv.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -321,7 +341,7 @@ the versioning metadata of up-and-running containers are.
|
||||||
|
|
||||||
tag := img.(reference.NamedTagged).Tag()
|
tag := img.(reference.NamedTagged).Tag()
|
||||||
label := fmt.Sprintf("coop-cloud.${STACK_NAME}.%s.version=%s-%s", service.Name, tag, digest)
|
label := fmt.Sprintf("coop-cloud.${STACK_NAME}.%s.version=%s-%s", service.Name, tag, digest)
|
||||||
if err := config.UpdateAppComposeLabel(recipe, service.Name, label); err != nil {
|
if err := config.UpdateAppComposeLabel(recipe, service.Name, label, appEnv.Env); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,7 +360,17 @@ var recipeLintCommand = &cli.Command{
|
||||||
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe provided"))
|
||||||
}
|
}
|
||||||
|
|
||||||
compose, err := config.GetAppComposeFiles(recipe)
|
appFiles, err := config.LoadAppFiles("")
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
appEnv, err := config.GetApp(appFiles, recipe)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
compose, err := config.GetAppComposeFiles(recipe, appEnv.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package stack
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -16,8 +15,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// LoadComposefile parse the composefile specified in the cli and returns its Config and version.
|
// LoadComposefile parse the composefile specified in the cli and returns its Config and version.
|
||||||
func LoadComposefile(opts options.Deploy) (*composetypes.Config, error) {
|
func LoadComposefile(opts options.Deploy, appEnv map[string]string) (*composetypes.Config, error) {
|
||||||
configDetails, err := getConfigDetails(opts.Composefiles)
|
configDetails, err := getConfigDetails(opts.Composefiles, appEnv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -66,7 +65,7 @@ func propertyWarnings(properties map[string]string) string {
|
||||||
return strings.Join(msgs, "\n\n")
|
return strings.Join(msgs, "\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfigDetails(composefiles []string) (composetypes.ConfigDetails, error) {
|
func getConfigDetails(composefiles []string, appEnv map[string]string) (composetypes.ConfigDetails, error) {
|
||||||
var details composetypes.ConfigDetails
|
var details composetypes.ConfigDetails
|
||||||
|
|
||||||
absPath, err := filepath.Abs(composefiles[0])
|
absPath, err := filepath.Abs(composefiles[0])
|
||||||
|
@ -81,7 +80,7 @@ func getConfigDetails(composefiles []string) (composetypes.ConfigDetails, error)
|
||||||
}
|
}
|
||||||
// Take the first file version (2 files can't have different version)
|
// Take the first file version (2 files can't have different version)
|
||||||
details.Version = schema.Version(details.ConfigFiles[0].Config)
|
details.Version = schema.Version(details.ConfigFiles[0].Config)
|
||||||
details.Environment, err = buildEnvironment(os.Environ())
|
details.Environment = appEnv
|
||||||
return details, err
|
return details, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ func GetAppStatuses(appFiles AppFiles) (map[string]string, error) {
|
||||||
// GetAppComposeFiles retrieves a compose specification for a recipe. This
|
// GetAppComposeFiles retrieves a compose specification for a recipe. This
|
||||||
// specification is the result of a merge of all the compose.**.yml files in
|
// specification is the result of a merge of all the compose.**.yml files in
|
||||||
// the recipe repository.
|
// the recipe repository.
|
||||||
func GetAppComposeFiles(recipe string) (*composetypes.Config, error) {
|
func GetAppComposeFiles(recipe string, appEnv AppEnv) (*composetypes.Config, error) {
|
||||||
pattern := fmt.Sprintf("%s/%s/compose**yml", APPS_DIR, recipe)
|
pattern := fmt.Sprintf("%s/%s/compose**yml", APPS_DIR, recipe)
|
||||||
composeFiles, err := filepath.Glob(pattern)
|
composeFiles, err := filepath.Glob(pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -237,7 +237,7 @@ func GetAppComposeFiles(recipe string) (*composetypes.Config, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := options.Deploy{Composefiles: composeFiles}
|
opts := options.Deploy{Composefiles: composeFiles}
|
||||||
compose, err := loader.LoadComposefile(opts)
|
compose, err := loader.LoadComposefile(opts, appEnv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &composetypes.Config{}, err
|
return &composetypes.Config{}, err
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ func GetAppComposeFiles(recipe string) (*composetypes.Config, error) {
|
||||||
return compose, nil
|
return compose, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateAppComposeTag(recipe, image, tag string) error {
|
func UpdateAppComposeTag(recipe, image, tag string, appEnv AppEnv) error {
|
||||||
pattern := fmt.Sprintf("%s/%s/compose**yml", APPS_DIR, recipe)
|
pattern := fmt.Sprintf("%s/%s/compose**yml", APPS_DIR, recipe)
|
||||||
composeFiles, err := filepath.Glob(pattern)
|
composeFiles, err := filepath.Glob(pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -254,7 +254,7 @@ func UpdateAppComposeTag(recipe, image, tag string) error {
|
||||||
|
|
||||||
for _, composeFile := range composeFiles {
|
for _, composeFile := range composeFiles {
|
||||||
opts := options.Deploy{Composefiles: []string{composeFile}}
|
opts := options.Deploy{Composefiles: []string{composeFile}}
|
||||||
compose, err := loader.LoadComposefile(opts)
|
compose, err := loader.LoadComposefile(opts, appEnv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ func UpdateAppComposeTag(recipe, image, tag string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateAppComposeLabel(recipe, serviceName, newLabel string) error {
|
func UpdateAppComposeLabel(recipe, serviceName, newLabel string, appEnv AppEnv) error {
|
||||||
pattern := fmt.Sprintf("%s/%s/compose**yml", APPS_DIR, recipe)
|
pattern := fmt.Sprintf("%s/%s/compose**yml", APPS_DIR, recipe)
|
||||||
composeFiles, err := filepath.Glob(pattern)
|
composeFiles, err := filepath.Glob(pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -307,7 +307,7 @@ func UpdateAppComposeLabel(recipe, serviceName, newLabel string) error {
|
||||||
|
|
||||||
for _, composeFile := range composeFiles {
|
for _, composeFile := range composeFiles {
|
||||||
opts := options.Deploy{Composefiles: []string{composeFile}}
|
opts := options.Deploy{Composefiles: []string{composeFile}}
|
||||||
compose, err := loader.LoadComposefile(opts)
|
compose, err := loader.LoadComposefile(opts, appEnv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue