MCPcopy
hub / github.com/istio/istio / newInstance

Function newInstance

pkg/test/framework/components/echo/kube/instance.go:65–115  ·  view source on GitHub ↗
(ctx resource.Context, originalCfg echo.Config)

Source from the content-addressed store, hash-verified

63}
64
65func newInstance(ctx resource.Context, originalCfg echo.Config) (out *instance, err error) {
66 cfg := originalCfg.DeepCopy()
67
68 c := &instance{
69 cfg: cfg,
70 ctx: ctx,
71 cluster: cfg.Cluster,
72 }
73
74 // Deploy echo to the cluster
75 c.deployment, err = newDeployment(ctx, cfg)
76 if err != nil {
77 return nil, err
78 }
79
80 // Create the manager for echo workloads for this instance.
81 c.workloadMgr, err = newWorkloadManager(ctx, cfg, c.deployment)
82 if err != nil {
83 return nil, err
84 }
85
86 // Now that we have the successfully created the workload manager, track this resource so
87 // that it will be closed when it goes out of scope.
88 c.id = ctx.TrackResource(c)
89
90 // Now retrieve the service information to find the ClusterIP
91 s, err := c.cluster.Kube().CoreV1().Services(cfg.Namespace.Name()).Get(context.TODO(), cfg.Service, metav1.GetOptions{})
92 if err != nil {
93 return nil, err
94 }
95
96 c.clusterIP = s.Spec.ClusterIP
97 c.clusterIPs = s.Spec.ClusterIPs
98 switch c.clusterIP {
99 case corev1.ClusterIPNone, "":
100 if !cfg.Headless {
101 return nil, fmt.Errorf("invalid ClusterIP %s for non-headless service %s/%s",
102 c.clusterIP,
103 c.cfg.Namespace.Name(),
104 c.cfg.Service)
105 }
106 c.clusterIP = ""
107 }
108
109 // Start the workload manager.
110 if err := c.workloadMgr.Start(); err != nil {
111 return nil, err
112 }
113
114 return c, nil
115}
116
117func (c *instance) ID() resource.ID {
118 return c.id

Callers 1

BuildFunction · 0.85

Calls 10

newDeploymentFunction · 0.85
newWorkloadManagerFunction · 0.85
DeepCopyMethod · 0.65
TrackResourceMethod · 0.65
GetMethod · 0.65
ServicesMethod · 0.65
KubeMethod · 0.65
NameMethod · 0.65
ErrorfMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…