|
|
|
@ -81,27 +81,25 @@ func executeActionCommandC(store *storage.Storage, cmd string) (*cobra.Command,
|
|
|
|
return executeActionCommandStdinC(store, nil, cmd)
|
|
|
|
return executeActionCommandStdinC(store, nil, cmd)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string) (*cobra.Command, string, error) {
|
|
|
|
func executeActionCommandWithWriters(store *storage.Storage, in *os.File, outWriter, errWriter io.Writer, cmd string) (*cobra.Command, error) {
|
|
|
|
args, err := shellwords.Parse(cmd)
|
|
|
|
args, err := shellwords.Parse(cmd)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, "", err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actionConfig := &action.Configuration{
|
|
|
|
actionConfig := &action.Configuration{
|
|
|
|
Releases: store,
|
|
|
|
Releases: store,
|
|
|
|
KubeClient: &kubefake.PrintingKubeClient{Out: io.Discard},
|
|
|
|
KubeClient: &kubefake.PrintingKubeClient{Out: io.Discard},
|
|
|
|
Capabilities: common.DefaultCapabilities,
|
|
|
|
Capabilities: common.DefaultCapabilities,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
root, err := newRootCmdWithConfig(actionConfig, buf, args, SetupLogging)
|
|
|
|
root, err := newRootCmdWithConfig(actionConfig, outWriter, args, SetupLogging)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, "", err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
root.SetOut(buf)
|
|
|
|
root.SetOut(outWriter)
|
|
|
|
root.SetErr(buf)
|
|
|
|
root.SetErr(errWriter)
|
|
|
|
root.SetArgs(args)
|
|
|
|
root.SetArgs(args)
|
|
|
|
|
|
|
|
|
|
|
|
oldStdin := os.Stdin
|
|
|
|
oldStdin := os.Stdin
|
|
|
|
@ -118,10 +116,13 @@ func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string)
|
|
|
|
mem.SetNamespace(settings.Namespace())
|
|
|
|
mem.SetNamespace(settings.Namespace())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
c, err := root.ExecuteC()
|
|
|
|
c, err := root.ExecuteC()
|
|
|
|
|
|
|
|
return c, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result := buf.String()
|
|
|
|
func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string) (*cobra.Command, string, error) {
|
|
|
|
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
return c, result, err
|
|
|
|
c, err := executeActionCommandWithWriters(store, in, buf, buf, cmd)
|
|
|
|
|
|
|
|
return c, buf.String(), err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// cmdTestCase describes a test case that works with releases.
|
|
|
|
// cmdTestCase describes a test case that works with releases.
|
|
|
|
@ -301,3 +302,10 @@ func TestCmdGetDryRunFlagStrategy(t *testing.T) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func executeActionCommandErr(store *storage.Storage, in *os.File, cmd string) (*cobra.Command, string, string, error) {
|
|
|
|
|
|
|
|
bufOut := new(bytes.Buffer)
|
|
|
|
|
|
|
|
bufErr := new(bytes.Buffer)
|
|
|
|
|
|
|
|
c, err := executeActionCommandWithWriters(store, in, bufOut, bufErr, cmd)
|
|
|
|
|
|
|
|
return c, bufOut.String(), bufErr.String(), err
|
|
|
|
|
|
|
|
}
|
|
|
|
|