MCPcopy
hub / github.com/istio/istio / New

Function New

pkg/test/framework/components/echo/common/deployment/echos.go:451–526  ·  view source on GitHub ↗

New echo deployment with the given configuration.

(ctx resource.Context, cfg Config)

Source from the content-addressed store, hash-verified

449
450// New echo deployment with the given configuration.
451func 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()

Callers 2

NewOrFailFunction · 0.70
SetupFunction · 0.70

Calls 15

NewFunction · 0.92
ConfigStruct · 0.92
NewWaypointProxyFunction · 0.92
GoMethod · 0.80
loadValuesMethod · 0.80
LoadValuesMethod · 0.80
GetMethod · 0.65
WithClustersMethod · 0.65
ClustersMethod · 0.65
BuildMethod · 0.65
SettingsMethod · 0.65
ServicesMethod · 0.65

Tested by

no test coverage detected