mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
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 ```
This commit is contained in:
commit
0956f5909b
@ -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))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user