...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package config
17
18 import (
19 "flag"
20
21 "k8s.io/client-go/tools/clientcmd"
22 clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
23 "k8s.io/kubernetes/test/e2e/framework"
24
25 test "github.com/chaos-mesh/chaos-mesh/e2e-test"
26 )
27
28
29 var TestConfig = test.NewDefaultConfig()
30
31
32 func RegisterOperatorFlags(flags *flag.FlagSet) {
33 flags.StringVar(&TestConfig.ManagerImage, "manager-image-registry", "ghcr.io", "chaos-mesh image registry")
34 flags.StringVar(&TestConfig.ManagerImage, "manager-image", "chaos-mesh/chaos-mesh", "chaos-mesh image")
35 flags.StringVar(&TestConfig.ManagerTag, "manager-image-tag", "latest", "chaos-mesh image tag")
36 flags.StringVar(&TestConfig.DaemonImage, "daemon-image-registry", "ghcr.io", "chaos-daemon image registry")
37 flags.StringVar(&TestConfig.DaemonImage, "daemon-image", "chaos-mesh/chaos-daemon", "chaos-daemon image")
38 flags.StringVar(&TestConfig.DaemonTag, "daemon-image-tag", "latest", "chaos-daemon image tag")
39 flags.StringVar(&TestConfig.E2EImage, "e2e-image", "chaos-mesh/e2e-helper:latest", "e2e-helper image")
40 flags.StringVar(&TestConfig.ChaosCoreDNSImage, "chaos-coredns-image", "chaos-mesh/chaos-coredns:v0.2.6", "chaos-coredns image")
41 flags.StringVar(&TestConfig.PauseImage, "pause-image", "gcr.io/google-containers/pause:latest", "custom pause container image for pod failure chaos")
42 flags.BoolVar(&TestConfig.InstallChaosMesh, "install-chaos-mesh", false, "automatically install chaos-mesh")
43 flags.BoolVar(&TestConfig.EnableDashboard, "enable-dashboard", false, "enable Chaos Dashboard")
44 }
45
46
47 func LoadClientRawConfig() (clientcmdapi.Config, error) {
48 loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
49 loadingRules.ExplicitPath = framework.TestContext.KubeConfig
50 overrides := &clientcmd.ConfigOverrides{ClusterDefaults: clientcmd.ClusterDefaults}
51 if framework.TestContext.KubeContext != "" {
52 overrides.CurrentContext = framework.TestContext.KubeContext
53 }
54 return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, overrides).RawConfig()
55 }
56