| 284 | } |
| 285 | |
| 286 | func (w *World) CmdWithEnv(binary string, env []string, args ...string) *exec.Cmd { |
| 287 | hasVerbose := func() bool { |
| 288 | for _, v := range args { |
| 289 | if v == "-verbose" || v == "--verbose" { |
| 290 | return true |
| 291 | } |
| 292 | } |
| 293 | return false |
| 294 | } |
| 295 | var cmd *exec.Cmd |
| 296 | switch binary { |
| 297 | case "pk-get", "pk-put", "pk", "pk-mount": |
| 298 | // TODO(mpl): lift the pk-put restriction when we have a unified logging mechanism |
| 299 | if binary == "pk-put" && !hasVerbose() { |
| 300 | // pk-put and pk are the only ones to have a -verbose flag through cmdmain |
| 301 | // but pk is never used. (and pk-mount does not even have a -verbose). |
| 302 | args = append([]string{"-verbose"}, args...) |
| 303 | } |
| 304 | binary := w.lookPathGobin(binary) |
| 305 | |
| 306 | cmd = exec.Command(binary, args...) |
| 307 | clientConfigDir := filepath.Join(w.srcRoot, "config", "dev-client-dir") |
| 308 | cmd.Env = append(env, |
| 309 | "CAMLI_CONFIG_DIR="+clientConfigDir, |
| 310 | // Respected by env expansions in config/dev-client-dir/client-config.json: |
| 311 | "CAMLI_SERVER="+w.ServerBaseURL(), |
| 312 | "CAMLI_SECRET_RING="+w.SecretRingFile(), |
| 313 | "CAMLI_KEYID="+w.ClientIdentity(), |
| 314 | "CAMLI_AUTH=userpass:testuser:passTestWorld", |
| 315 | ) |
| 316 | default: |
| 317 | panic("Unknown binary " + binary) |
| 318 | } |
| 319 | return cmd |
| 320 | } |
| 321 | |
| 322 | func (w *World) ServerBaseURL() string { |
| 323 | return fmt.Sprintf("http://%s", w.addr) |