switch to gopkg.in/yaml.v3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-01-14 23:07:44 +01:00
parent ce293bdb81
commit 58bf0f1846
28 changed files with 2761 additions and 1300 deletions

View File

@ -1,6 +1,7 @@
package stack
import (
"bytes"
"fmt"
"github.com/docker/cli/cli"
@ -11,7 +12,7 @@ import (
composeLoader "github.com/docker/cli/cli/compose/loader"
composetypes "github.com/docker/cli/cli/compose/types"
"github.com/spf13/cobra"
yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)
func newConfigCommand(dockerCli command.Cli) *cobra.Command {
@ -54,9 +55,12 @@ func outputConfig(configFiles composetypes.ConfigDetails, skipInterpolation bool
return "", err
}
d, err := yaml.Marshal(&config)
var buf bytes.Buffer
enc := yaml.NewEncoder(&buf)
enc.SetIndent(2)
err = enc.Encode(&config)
if err != nil {
return "", err
}
return string(d), nil
return buf.String(), nil
}

View File

@ -45,8 +45,8 @@ services:
services:
foo:
command:
- cat
- file2.txt
- cat
- file2.txt
image: busybox:1.0
`,
},
@ -69,8 +69,8 @@ services:
services:
foo:
command:
- cat
- file2.txt
- cat
- file2.txt
image: busybox:${VERSION}
`,
},