(store *storage.Storage, in *os.File, cmd string)
| 85 | } |
| 86 | |
| 87 | func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string) (*cobra.Command, string, error) { |
| 88 | args, err := shellwords.Parse(cmd) |
| 89 | if err != nil { |
| 90 | return nil, "", err |
| 91 | } |
| 92 | |
| 93 | buf := new(bytes.Buffer) |
| 94 | |
| 95 | actionConfig := &action.Configuration{ |
| 96 | Releases: store, |
| 97 | KubeClient: &kubefake.PrintingKubeClient{Out: io.Discard}, |
| 98 | Capabilities: common.DefaultCapabilities, |
| 99 | } |
| 100 | |
| 101 | root, err := newRootCmdWithConfig(actionConfig, buf, args, SetupLogging) |
| 102 | if err != nil { |
| 103 | return nil, "", err |
| 104 | } |
| 105 | |
| 106 | root.SetOut(buf) |
| 107 | root.SetErr(buf) |
| 108 | root.SetArgs(args) |
| 109 | |
| 110 | oldStdin := os.Stdin |
| 111 | defer func() { |
| 112 | os.Stdin = oldStdin |
| 113 | }() |
| 114 | |
| 115 | if in != nil { |
| 116 | root.SetIn(in) |
| 117 | os.Stdin = in |
| 118 | } |
| 119 | |
| 120 | if mem, ok := store.Driver.(*driver.Memory); ok { |
| 121 | mem.SetNamespace(settings.Namespace()) |
| 122 | } |
| 123 | c, err := root.ExecuteC() |
| 124 | |
| 125 | result := buf.String() |
| 126 | |
| 127 | return c, result, err |
| 128 | } |
| 129 | |
| 130 | // cmdTestCase describes a test case that works with releases. |
| 131 | type cmdTestCase struct { |
no test coverage detected
searching dependent graphs…