Merge pull request #16969 from smarterclayton/fix_secret_in_container
Auto commit by PR queue bot
This commit is contained in:
		| @@ -17,6 +17,7 @@ limitations under the License. | |||||||
| package io | package io | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"bytes" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 	"os" | 	"os" | ||||||
| @@ -49,6 +50,7 @@ func (writer *StdWriter) WriteFile(filename string, data []byte, perm os.FileMod | |||||||
| type NsenterWriter struct { | type NsenterWriter struct { | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // TODO: should take a writer, not []byte | ||||||
| func (writer *NsenterWriter) WriteFile(filename string, data []byte, perm os.FileMode) error { | func (writer *NsenterWriter) WriteFile(filename string, data []byte, perm os.FileMode) error { | ||||||
| 	cmd := "nsenter" | 	cmd := "nsenter" | ||||||
| 	base_args := []string{ | 	base_args := []string{ | ||||||
| @@ -56,10 +58,11 @@ func (writer *NsenterWriter) WriteFile(filename string, data []byte, perm os.Fil | |||||||
| 		"--", | 		"--", | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	echo_args := append(base_args, "sh", "-c", | 	echo_args := append(base_args, "sh", "-c", fmt.Sprintf("cat > %s", filename)) | ||||||
| 		fmt.Sprintf("echo %q | cat > %s", data, filename)) |  | ||||||
| 	glog.V(5).Infof("Command to write data to file: %v %v", cmd, echo_args) | 	glog.V(5).Infof("Command to write data to file: %v %v", cmd, echo_args) | ||||||
| 	outputBytes, err := exec.Command(cmd, echo_args...).CombinedOutput() | 	command := exec.Command(cmd, echo_args...) | ||||||
|  | 	command.Stdin = bytes.NewBuffer(data) | ||||||
|  | 	outputBytes, err := command.CombinedOutput() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		glog.Errorf("Output from writing to %q: %v", filename, string(outputBytes)) | 		glog.Errorf("Output from writing to %q: %v", filename, string(outputBytes)) | ||||||
| 		return err | 		return err | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 k8s-merge-robot
					k8s-merge-robot