(name string)
| 113 | } |
| 114 | |
| 115 | func withPluginClientConn(name string) command.CLIOption { |
| 116 | return func(cli *command.DockerCli) error { |
| 117 | cmd := "docker" |
| 118 | if x := os.Getenv(metadata.ReexecEnvvar); x != "" { |
| 119 | cmd = x |
| 120 | } |
| 121 | var flags []string |
| 122 | |
| 123 | // Accumulate all the global arguments, that is those |
| 124 | // up to (but not including) the plugin's name. This |
| 125 | // ensures that `docker system dial-stdio` is |
| 126 | // evaluating the same set of `--config`, `--tls*` etc |
| 127 | // global options as the plugin was called with, which |
| 128 | // in turn is the same as what the original docker |
| 129 | // invocation was passed. |
| 130 | for _, a := range os.Args[1:] { |
| 131 | if a == name { |
| 132 | break |
| 133 | } |
| 134 | flags = append(flags, a) |
| 135 | } |
| 136 | flags = append(flags, "system", "dial-stdio") |
| 137 | |
| 138 | helper, err := connhelper.GetCommandConnectionHelper(cmd, flags...) |
| 139 | if err != nil { |
| 140 | return err |
| 141 | } |
| 142 | apiClient, err := client.New(client.WithDialContext(helper.Dialer)) |
| 143 | if err != nil { |
| 144 | return err |
| 145 | } |
| 146 | return command.WithAPIClient(apiClient)(cli) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | func newPluginCommand(dockerCli *command.DockerCli, plugin *cobra.Command, meta metadata.Metadata) *cli.TopLevelCommand { |
| 151 | name := plugin.Name() |
no outgoing calls
no test coverage detected
searching dependent graphs…