diff --git a/.release-notes/v0.1.6.md b/.release-notes/v0.1.6.md new file mode 100644 index 000000000..e0d672f62 --- /dev/null +++ b/.release-notes/v0.1.6.md @@ -0,0 +1,7 @@ +# Release notes + +Release notes for `v0.1.6`. + +## 🔧 Fixes 🔧 + +- Fix an issue with temporary KUBECONFIG not being an absolute path \ No newline at end of file diff --git a/pkg/runner/operations/command/operation.go b/pkg/runner/operations/command/operation.go index a6c0e04a4..d1b9d2cab 100644 --- a/pkg/runner/operations/command/operation.go +++ b/pkg/runner/operations/command/operation.go @@ -67,11 +67,11 @@ func (o *operation) createCommand(ctx context.Context) (*exec.Cmd, context.Cance args := env.Expand(map[string]string{"NAMESPACE": o.namespace}, o.command.Args...) cmd := exec.CommandContext(ctx, o.command.Entrypoint, args...) //nolint:gosec env := os.Environ() - if cwd, err := os.Getwd(); err != nil { + cwd, err := os.Getwd() + if err != nil { return nil, nil, fmt.Errorf("failed to get current working directory (%w)", err) - } else { - env = append(env, fmt.Sprintf("PATH=%s/bin/:%s", cwd, os.Getenv("PATH"))) } + env = append(env, fmt.Sprintf("PATH=%s/bin/:%s", cwd, os.Getenv("PATH"))) env = append(env, fmt.Sprintf("NAMESPACE=%s", o.namespace)) if o.cfg != nil { f, err := os.CreateTemp(o.basePath, "chainsaw-kubeconfig-") @@ -90,7 +90,9 @@ func (o *operation) createCommand(ctx context.Context) (*exec.Cmd, context.Cance if err := restutils.Save(o.cfg, f); err != nil { return nil, cancel, err } - env = append(env, fmt.Sprintf("KUBECONFIG=%s", filepath.Base(path))) + fmt.Println(f.Name()) + fmt.Println(o.basePath) + env = append(env, fmt.Sprintf("KUBECONFIG=%s", filepath.Join(cwd, path))) } cmd.Env = env cmd.Dir = o.basePath diff --git a/pkg/runner/operations/script/operation.go b/pkg/runner/operations/script/operation.go index 100a4832e..ab5d1d2be 100644 --- a/pkg/runner/operations/script/operation.go +++ b/pkg/runner/operations/script/operation.go @@ -65,11 +65,11 @@ func (o *operation) createCommand(ctx context.Context) (*exec.Cmd, context.Cance var cancel context.CancelFunc cmd := exec.CommandContext(ctx, "sh", "-c", o.script.Content) //nolint:gosec env := os.Environ() - if cwd, err := os.Getwd(); err != nil { + cwd, err := os.Getwd() + if err != nil { return nil, nil, fmt.Errorf("failed to get current working directory (%w)", err) - } else { - env = append(env, fmt.Sprintf("PATH=%s/bin/:%s", cwd, os.Getenv("PATH"))) } + env = append(env, fmt.Sprintf("PATH=%s/bin/:%s", cwd, os.Getenv("PATH"))) env = append(env, fmt.Sprintf("NAMESPACE=%s", o.namespace)) if o.cfg != nil { f, err := os.CreateTemp(o.basePath, "chainsaw-kubeconfig-") @@ -88,7 +88,7 @@ func (o *operation) createCommand(ctx context.Context) (*exec.Cmd, context.Cance if err := restutils.Save(o.cfg, f); err != nil { return nil, cancel, err } - env = append(env, fmt.Sprintf("KUBECONFIG=%s", filepath.Base(path))) + env = append(env, fmt.Sprintf("KUBECONFIG=%s", filepath.Join(cwd, path))) } cmd.Env = env cmd.Dir = o.basePath diff --git a/testdata/e2e/examples/basic/chainsaw-test.yaml b/testdata/e2e/examples/basic/chainsaw-test.yaml index 942a811be..c9947b0a1 100644 --- a/testdata/e2e/examples/basic/chainsaw-test.yaml +++ b/testdata/e2e/examples/basic/chainsaw-test.yaml @@ -15,4 +15,4 @@ spec: assert: file: configmap-assert.yaml - script: - content: kubectl get pod -A \ No newline at end of file + content: cd .. && kubectl get pod -A \ No newline at end of file