MCPcopy Index your code
hub / github.com/docker/cli / withPluginClientConn

Function withPluginClientConn

cli-plugins/plugin/plugin.go:115–148  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

113}
114
115func 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
150func newPluginCommand(dockerCli *command.DockerCli, plugin *cobra.Command, meta metadata.Metadata) *cli.TopLevelCommand {
151 name := plugin.Name()

Callers 1

RunPluginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…