refactor(recipe): load load compoes config where its used

This commit is contained in:
2024-07-08 12:31:39 +02:00
parent 99da8d4e57
commit c1b03bcbd7
16 changed files with 263 additions and 230 deletions

View File

@ -65,12 +65,12 @@ your SSH keys configured on your account.
recipe := internal.ValidateRecipe(c)
r := recipePkg.Get2(recipe.Name)
imagesTmp, err := getImageVersions(recipe)
imagesTmp, err := getImageVersions(r)
if err != nil {
log.Fatal(err)
}
mainApp, err := internal.GetMainAppImage(recipe)
mainApp, err := internal.GetMainAppImage(r)
if err != nil {
log.Fatal(err)
}
@ -104,7 +104,7 @@ your SSH keys configured on your account.
if tagString == "" && (!internal.Major && !internal.Minor && !internal.Patch) {
var err error
tagString, err = getLabelVersion(recipe, false)
tagString, err = getLabelVersion(r, false)
if err != nil {
log.Fatal(err)
}
@ -143,11 +143,15 @@ your SSH keys configured on your account.
}
// getImageVersions retrieves image versions for a recipe
func getImageVersions(recipe recipe.Recipe) (map[string]string, error) {
func getImageVersions(recipe recipe.Recipe2) (map[string]string, error) {
services := make(map[string]string)
config, err := recipe.GetComposeConfig(nil)
if err != nil {
return nil, err
}
missingTag := false
for _, service := range recipe.Config.Services {
for _, service := range config.Services {
if service.Image == "" {
continue
}
@ -526,8 +530,8 @@ func cleanUpTag(tag, recipeName string) error {
return nil
}
func getLabelVersion(recipe recipe.Recipe, prompt bool) (string, error) {
initTag, err := recipePkg.GetVersionLabelLocal(recipe)
func getLabelVersion(recipe recipe.Recipe2, prompt bool) (string, error) {
initTag, err := recipe.GetVersionLabelLocal()
if err != nil {
return "", err
}