()
| 426 | } |
| 427 | |
| 428 | func (c *serverCmd) makeThings() error { |
| 429 | const importerPrefix = "/importer/" |
| 430 | // check that "/importer/" prefix is in config, just in case it ever changes. |
| 431 | configFile := filepath.Join(camliSrcRoot, "config", "dev-server-config.json") |
| 432 | config, err := os.ReadFile(configFile) |
| 433 | if err != nil { |
| 434 | return fmt.Errorf("could not read config file %v: %v", configFile, err) |
| 435 | } |
| 436 | if !bytes.Contains(config, []byte(importerPrefix)) { |
| 437 | return fmt.Errorf("%s prefix not found in dev config. Did it change?", importerPrefix) |
| 438 | } |
| 439 | |
| 440 | if err := netutil.AwaitReachable("localhost:"+c.port, time.Minute); err != nil { |
| 441 | return err |
| 442 | } |
| 443 | |
| 444 | osutil.AddSecretRingFlag() |
| 445 | setCamdevVars() |
| 446 | |
| 447 | baseURL := c.env.m["CAMLI_BASEURL"] |
| 448 | if baseURL == "" { |
| 449 | return errors.New("CAMLI_BASEURL is not set") |
| 450 | } |
| 451 | |
| 452 | cl, err := client.New(client.OptionServer(baseURL)) |
| 453 | if err != nil { |
| 454 | return fmt.Errorf("making client: %v", err) |
| 455 | } |
| 456 | signer, err := cl.Signer() |
| 457 | if err != nil { |
| 458 | return err |
| 459 | } |
| 460 | ClientId := make(map[string]string) |
| 461 | ClientSecret := make(map[string]string) |
| 462 | for name := range importer.All() { |
| 463 | ClientId[name] = "fakeStaticClientId" |
| 464 | ClientSecret[name] = "fakeStaticClientSecret" |
| 465 | } |
| 466 | hc := importer.HostConfig{ |
| 467 | BaseURL: baseURL, |
| 468 | Prefix: importerPrefix, |
| 469 | Target: cl, |
| 470 | BlobSource: cl, |
| 471 | Signer: signer, |
| 472 | Search: cl, |
| 473 | ClientId: ClientId, |
| 474 | ClientSecret: ClientSecret, |
| 475 | } |
| 476 | |
| 477 | for name, imp := range importer.All() { |
| 478 | mk, ok := imp.(importer.TestDataMaker) |
| 479 | if !ok { |
| 480 | continue |
| 481 | } |
| 482 | |
| 483 | tr := mk.MakeTestData() |
| 484 | |
| 485 | hc.HTTPClient = &http.Client{Transport: tr} |
no test coverage detected