mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 03:08:15 +00:00
Dump stdin to a temporary file in kubectl replace --force
This commit is contained in:
@@ -19,7 +19,9 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -131,6 +133,22 @@ func forceReplace(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []
|
||||
return err
|
||||
}
|
||||
|
||||
for i, filename := range filenames {
|
||||
if filename == "-" {
|
||||
tempDir, err := ioutil.TempDir("", "kubectl_replace_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.RemoveAll(tempDir)
|
||||
tempFilename := filepath.Join(tempDir, "resource.stdin")
|
||||
err = cmdutil.DumpReaderToFile(os.Stdin, tempFilename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
filenames[i] = tempFilename
|
||||
}
|
||||
}
|
||||
|
||||
mapper, typer := f.Object()
|
||||
r := resource.NewBuilder(mapper, typer, f.ClientMapperForCommand()).
|
||||
ContinueOnError().
|
||||
|
||||
Reference in New Issue
Block a user