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

Method args

cli/connhelper/ssh/ssh.go:103–135  ·  view source on GitHub ↗
(sshFlags ...string)

Source from the content-addressed store, hash-verified

101}
102
103func (sp *Spec) args(sshFlags ...string) ([]string, error) {
104 var args []string
105 if sp.Host == "" {
106 return nil, errors.New("no host specified")
107 }
108 if sp.User != "" {
109 // Quote user, as it's obtained from the URL.
110 usr, err := syntax.Quote(sp.User, syntax.LangPOSIX)
111 if err != nil {
112 return nil, fmt.Errorf("invalid user: %w", err)
113 }
114 args = append(args, "-l", usr)
115 }
116 if sp.Port != "" {
117 // Quote port, as it's obtained from the URL.
118 port, err := syntax.Quote(sp.Port, syntax.LangPOSIX)
119 if err != nil {
120 return nil, fmt.Errorf("invalid port: %w", err)
121 }
122 args = append(args, "-p", port)
123 }
124
125 // We consider "sshFlags" to be "trusted", and set from code only,
126 // as they are not parsed from the DOCKER_HOST URL.
127 args = append(args, sshFlags...)
128
129 host, err := syntax.Quote(sp.Host, syntax.LangPOSIX)
130 if err != nil {
131 return nil, fmt.Errorf("invalid host: %w", err)
132 }
133
134 return append(args, "--", host), nil
135}
136
137// Command returns the ssh flags and arguments to execute a command
138// (remoteCommandAndArgs) on the remote host. Where needed, it quotes

Callers 2

ArgsMethod · 0.95
CommandMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected