revert back to yaml v2, fix envs with yaml lists

This commit is contained in:
Giovanni Harting 2024-12-15 02:08:03 +01:00
parent ab238cf897
commit d4dbfdea1c
4 changed files with 14 additions and 7 deletions

2
go.mod
View File

@ -17,7 +17,7 @@ require (
github.com/sethvargo/go-retry v0.3.0
github.com/sirupsen/logrus v1.9.3
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117
gopkg.in/yaml.v3 v3.0.1
gopkg.in/yaml.v2 v2.2.2
)
require (

1
go.sum
View File

@ -280,6 +280,7 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

View File

@ -9,7 +9,7 @@ import (
_ "github.com/jackc/pgx/v4/stdlib"
log "github.com/sirupsen/logrus"
"github.com/wercker/journalhook"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"
"os"
"os/signal"
"path/filepath"

View File

@ -9,7 +9,7 @@ import (
"github.com/c2h5oh/datasize"
"github.com/gobwas/glob"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"
"io"
"io/fs"
"net/http"
@ -490,12 +490,18 @@ func parseFlagSection(section any, makepkgConf, march string) (string, error) {
if len(orgMatch) == 0 {
// no match found, assume env var and append it
log.Debugf("no match found for %s:%v, appending", subSec, subMap)
if strings.Contains(subMap.(string), " ") {
makepkgConf += fmt.Sprintf("\nexport %s=%q", strings.ToUpper(subSec.(string)), replaceStringsFromMap(subMap.(string), replaceMap))
switch sm := subMap.(type) {
case string:
if strings.Contains(sm, " ") {
makepkgConf += fmt.Sprintf("\nexport %s=%q", strings.ToUpper(subSec.(string)), replaceStringsFromMap(sm, replaceMap))
continue
}
makepkgConf += fmt.Sprintf("\nexport %s=%s", strings.ToUpper(subSec.(string)), replaceStringsFromMap(sm, replaceMap))
continue
case []string:
makepkgConf += fmt.Sprintf("\nexport %s=%q", strings.ToUpper(subSec.(string)), replaceStringsFromMap(strings.Join(sm, " "), replaceMap))
continue
}
makepkgConf += fmt.Sprintf("\nexport %s=%s", strings.ToUpper(subSec.(string)), replaceStringsFromMap(subMap.(string), replaceMap))
continue
}
log.Debugf("original %s: %v (%d)", subSec, flags, len(flags))