From ec76bb3e33773cf609ce3a32b307be458d2f8e70 Mon Sep 17 00:00:00 2001 From: Yves Brissaud Date: Wed, 9 Oct 2024 19:07:03 +0200 Subject: [PATCH] fix: multiline issues from shell and command Signed-off-by: Yves Brissaud --- runkit/read.go | 11 ++++++++++- runkit/run.go | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/runkit/read.go b/runkit/read.go index ce9d1d2..744420a 100644 --- a/runkit/read.go +++ b/runkit/read.go @@ -4,11 +4,12 @@ import ( "context" "fmt" "io" + "strings" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/remote" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" "github.com/eunomie/docker-runx/internal/registry" "github.com/eunomie/docker-runx/internal/runkit" @@ -97,6 +98,14 @@ func Get(ctx context.Context, src string) (*RunKit, error) { if err = yaml.Unmarshal(runxConfig, &config); err != nil { return nil, fmt.Errorf("could not unmarshal runx config %s: %w", src, err) } + var actions []Action + // TODO: fix reading of multiline YAML strings + for _, a := range config.Actions { + // a := a + a.Command = strings.ReplaceAll(a.Command, "\n", " ") + actions = append(actions, a) + } + config.Actions = actions rk.Config = config } diff --git a/runkit/run.go b/runkit/run.go index 88a3dcb..daebc71 100644 --- a/runkit/run.go +++ b/runkit/run.go @@ -136,5 +136,5 @@ func sh(ctx context.Context, cmd string) (string, error) { return "", err } - return osOut.String(), nil + return strings.TrimSpace(osOut.String()), nil }