Browse Source

bridge - run transformer container as current user

Signed-off-by: Guillaume Lours <[email protected]>
Guillaume Lours 6 months ago
parent
commit
d49a68ecbf
2 changed files with 9 additions and 3 deletions
  1. 6 0
      pkg/bridge/convert.go
  2. 3 3
      pkg/e2e/bridge_test.go

+ 6 - 0
pkg/bridge/convert.go

@@ -21,6 +21,7 @@ import (
 	"fmt"
 	"io"
 	"os"
+	"os/user"
 	"path/filepath"
 	"strconv"
 
@@ -110,9 +111,14 @@ func convert(ctx context.Context, dockerCli command.Cli, model map[string]any, o
 			return err
 		}
 
+		user, err := user.Current()
+		if err != nil {
+			return err
+		}
 		created, err := dockerCli.Client().ContainerCreate(ctx, &container.Config{
 			Image: transformation,
 			Env:   []string{"LICENSE_AGREEMENT=true"},
+			User:  user.Uid,
 		}, &container.HostConfig{
 			AutoRemove: true,
 			Binds:      binds,

+ 3 - 3
pkg/e2e/bridge_test.go

@@ -17,7 +17,7 @@
 package e2e
 
 import (
-	"fmt"
+	"path/filepath"
 	"strings"
 	"testing"
 
@@ -31,7 +31,7 @@ func TestConvertAndTransformList(t *testing.T) {
 	tmpDir := t.TempDir()
 
 	t.Run("kubernetes manifests", func(t *testing.T) {
-		kubedir := fmt.Sprintf("%s/kubernetes", tmpDir)
+		kubedir := filepath.Join(tmpDir, "kubernetes")
 		res := c.RunDockerComposeCmd(t, "-f", "./fixtures/bridge/compose.yaml", "--project-name", projectName, "bridge", "convert",
 			"--output", kubedir)
 		assert.NilError(t, res.Error)
@@ -41,7 +41,7 @@ func TestConvertAndTransformList(t *testing.T) {
 	})
 
 	t.Run("helm charts", func(t *testing.T) {
-		helmDir := fmt.Sprintf("%s/helm", tmpDir)
+		helmDir := filepath.Join(tmpDir, "helm")
 		res := c.RunDockerComposeCmd(t, "-f", "./fixtures/bridge/compose.yaml", "--project-name", projectName, "bridge", "convert",
 			"--output", helmDir, "--transformation", "docker/compose-bridge-helm")
 		assert.NilError(t, res.Error)