Skip to content

Commit

Permalink
fixed error
Browse files Browse the repository at this point in the history
  • Loading branch information
qrnvttrl committed Feb 14, 2024
1 parent 737d74f commit 1698b3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions integration/localfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ func Test_Localfs_Restore(t *testing.T) {
}

func addLocalfsTestData(t *testing.T, ctx context.Context) {
_, _, err := execCommand(ctx, "backup-restore-sidecar", []string{"sh", "-c", "echo 'I am precious' > /data/test.txt"})
_, err := execCommand(ctx, "backup-restore-sidecar", []string{"sh", "-c", "echo 'I am precious' > /data/test.txt"})
require.NoError(t, err)
}

func verifyLocalfsTestData(t *testing.T, ctx context.Context) {
resp, _, err := execCommand(ctx, "backup-restore-sidecar", []string{"cat", "/data/test.txt"})
resp, err := execCommand(ctx, "backup-restore-sidecar", []string{"cat", "/data/test.txt"})
require.NoError(t, err)

assert.Equal(t, "I am precious", resp)
Expand Down
12 changes: 6 additions & 6 deletions integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,11 @@ func waitUntilNotFound(ctx context.Context, obj client.Object) error {
}, retry.Context(ctx), retry.Attempts(0), retry.MaxDelay(2*time.Second))
}

func execCommand(ctx context.Context, containerName string, cmd []string) (string, string, error) {
func execCommand(ctx context.Context, containerName string, cmd []string) (string, error) {
var stdout, stderr bytes.Buffer
client, err := kubernetes.NewForConfig(restConfig)
if err != nil {
return "", "", err
return "", err
}

req := client.CoreV1().RESTClient().Post().Resource("pods").Name(pod.Name).Namespace(pod.Namespace).SubResource("exec")
Expand All @@ -425,15 +425,15 @@ func execCommand(ctx context.Context, containerName string, cmd []string) (strin
)
exec, err := remotecommand.NewSPDYExecutor(restConfig, "POST", req.URL())
if err != nil {
return "", "", err
return "", err
}
err = exec.StreamWithContext(ctx, remotecommand.StreamOptions{
err = exec.StreamWithContext(context.WithoutCancel(ctx), remotecommand.StreamOptions{
Stdin: nil,
Stdout: &stdout,
Stderr: &stderr,
})
if err != nil {
return "", "", err
return "", err
}
return strings.TrimSpace(stdout.String()), strings.TrimSpace(stderr.String()), nil
return strings.TrimSpace(stdout.String()), nil
}

0 comments on commit 1698b3b

Please sign in to comment.