New echo deployment with the given configuration.
(ctx resource.Context, cfg Config)
| 449 | |
| 450 | // New echo deployment with the given configuration. |
| 451 | func New(ctx resource.Context, cfg Config) (*Echos, error) { |
| 452 | if err := cfg.fillDefaults(ctx); err != nil { |
| 453 | return nil, err |
| 454 | } |
| 455 | |
| 456 | apps := cfg.Echos |
| 457 | apps.NS = make([]EchoNamespace, len(cfg.Namespaces)) |
| 458 | for i, ns := range cfg.Namespaces { |
| 459 | apps.NS[i].Namespace = ns.Get() |
| 460 | apps.NS[i].ServiceNamePrefix = cfg.ServiceNamePrefix |
| 461 | } |
| 462 | if !cfg.NoExternalNamespace { |
| 463 | apps.External.Namespace = cfg.ExternalNamespace.Get() |
| 464 | } |
| 465 | |
| 466 | builder := deployment.New(ctx).WithClusters(ctx.Clusters()...) |
| 467 | for _, n := range apps.NS { |
| 468 | builder = n.build(builder, cfg) |
| 469 | } |
| 470 | |
| 471 | if !cfg.NoExternalNamespace { |
| 472 | builder = apps.External.Build(ctx, builder) |
| 473 | } |
| 474 | |
| 475 | echos, err := builder.Build() |
| 476 | if err != nil { |
| 477 | return nil, err |
| 478 | } |
| 479 | |
| 480 | if ctx.Settings().Ambient { |
| 481 | |
| 482 | waypointProxies := make(map[string]ambient.Waypoints) |
| 483 | |
| 484 | for _, echo := range echos { |
| 485 | svcwp := echo.Config().ServiceWaypointProxy |
| 486 | wlwp := echo.Config().WorkloadWaypointProxy |
| 487 | var err error |
| 488 | if svcwp != "" { |
| 489 | if _, found := waypointProxies[svcwp]; !found { |
| 490 | waypointProxies[svcwp], err = ambient.NewWaypointProxy(ctx, echo.Config().Namespace, svcwp) |
| 491 | if err != nil { |
| 492 | return nil, err |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | if wlwp != "" { |
| 497 | if _, found := waypointProxies[wlwp]; !found { |
| 498 | waypointProxies[wlwp], err = ambient.NewWaypointProxy(ctx, echo.Config().Namespace, wlwp) |
| 499 | if err != nil { |
| 500 | return nil, err |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | apps.All = echos.Services() |
no test coverage detected