MCPcopy Create free account
hub / github.com/conforma/cli / setupKubernetes

Function setupKubernetes

acceptance/cli/cli.go:350–389  ·  view source on GitHub ↗
(ctx context.Context, vars map[string]string, environment []string)

Source from the content-addressed store, hash-verified

348}
349
350func setupKubernetes(ctx context.Context, vars map[string]string, environment []string) ([]string, map[string]string, error) {
351 if !testenv.HasState[kubernetes.ClusterState](ctx) {
352 return environment, vars, nil
353 }
354
355 c := testenv.FetchState[kubernetes.ClusterState](ctx)
356
357 if !c.Up(ctx) {
358 return environment, vars, nil
359 }
360
361 kubeconfig, err := os.CreateTemp("", "*.kubeconfig")
362 if err != nil {
363 return environment, vars, err
364 }
365
366 testenv.Testing(ctx).Cleanup(func() {
367 if !testenv.Persisted(ctx) {
368 os.Remove(kubeconfig.Name())
369 }
370 })
371
372 cfg, err := c.KubeConfig(ctx)
373 if err != nil {
374 return environment, vars, err
375 }
376
377 _, err = kubeconfig.WriteString(cfg)
378 if err != nil {
379 return environment, vars, err
380 }
381 err = kubeconfig.Close()
382 if err != nil {
383 return environment, vars, err
384 }
385
386 environment = append(environment, "KUBECONFIG="+kubeconfig.Name())
387
388 return environment, vars, nil
389}
390
391func setupGitHost(ctx context.Context, vars map[string]string, environment []string) ([]string, map[string]string, error) {
392 if !git.IsRunning(ctx) {

Callers 1

variablesFunction · 0.85

Calls 7

TestingFunction · 0.92
PersistedFunction · 0.92
CleanupMethod · 0.80
UpMethod · 0.65
NameMethod · 0.65
KubeConfigMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected