Commit 0956f590 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #54258 from JackDanger/jack/address-todo-in-test-helper

Automatic merge from submit-queue (batch tested with PRs 53474, 54258, 54356). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Directly using std{in,out} for test helper subproc **What this PR does / why we need it** This fixes one TODO in the code of a test helper and is an extremely minor improvement **Which issue this PR fixes** Fixes issue #54258 **Special notes for your reviewer** I'm using this to familiarize myself with the Kubernetes contribution process while being helpful in the process. ```release-note NONE ```
parents 1ba331ef fb462076
......@@ -20,6 +20,7 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"os"
......@@ -59,11 +60,27 @@ func lookup(svcName string) (sets.String, error) {
func shellOut(sendStdin, script string) {
log.Printf("execing: %v with stdin: %v", script, sendStdin)
// TODO: Switch to sending stdin from go
out, err := exec.Command("bash", "-c", fmt.Sprintf("echo -e '%v' | %v", sendStdin, script)).CombinedOutput()
cmd := exec.Command(script)
stdin, err := cmd.StdinPipe()
if err != nil {
log.Fatalf("Failed to get stdin pipe: %v", err)
}
stdout, err := cmd.StdoutPipe()
if err != nil {
log.Fatalf("Failed to get stdout pipe: %v", err)
}
cmd.Start()
stdin.Write([]byte(sendStdin))
stdin.Close()
out, err := ioutil.ReadAll(stdout)
if err != nil {
log.Fatalf("Failed to execute %v: %v, err: %v", script, string(out), err)
}
log.Print(string(out))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment