Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return from RunWithCancel if cmd is kapp #1638

Merged
merged 4 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cli/pkg/kctrl/cmd/app/release/release_cmd_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ func (r ReleaseCmdRunner) Run(cmd *goexec.Cmd) error {
r.ui.PrintHeaderText("Building images and resolving references")
}

if filepath.Base(cmd.Path) == "kapp" {
return nil
}
if filepath.Base(cmd.Path) == "kbld" {
cmd.Args = append(cmd.Args, fmt.Sprintf("--imgpkg-lock-output=%s", r.tempImgLockFilepath))
}
Expand All @@ -57,6 +54,10 @@ func (r ReleaseCmdRunner) Run(cmd *goexec.Cmd) error {
}

func (r ReleaseCmdRunner) RunWithCancel(cmd *goexec.Cmd, cancelCh chan struct{}) error {
if filepath.Base(cmd.Path) == "kapp" {
return nil
}

if r.fullOutput {
cmd.Stdout = io.MultiWriter(r.log, cmd.Stdout)
cmd.Stderr = io.MultiWriter(r.log, cmd.Stderr)
Expand Down
21 changes: 21 additions & 0 deletions cli/pkg/kctrl/cmd/app/release/release_cmd_runner_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package release

import (
"bytes"
"os/exec"
"testing"

"github.com/stretchr/testify/require"
)

func TestReleaseCmdRunnerForKappCmd(t *testing.T) {
var buf bytes.Buffer
ReleaseCmdRunner := NewReleaseCmdRunner(&buf, false, "", false, nil)
cmd := exec.Command("kapp", "deploy", "-f", "-", "-a", "pkg-test", "-y")
err := ReleaseCmdRunner.RunWithCancel(cmd, nil)
require.NoError(t, err)
devanshuVmware marked this conversation as resolved.
Show resolved Hide resolved
expectedLength := 0
if actualLength := buf.Len(); actualLength != expectedLength {
t.Errorf("Got Buffer length = %d, Expected empty", actualLength)
devanshuVmware marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading