...

Source file src/github.com/chaos-mesh/chaos-mesh/e2e-test/e2e/config/config.go

Documentation: github.com/chaos-mesh/chaos-mesh/e2e-test/e2e/config

     1  // Copyright 2020 Chaos Mesh Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package config
    15  
    16  import (
    17  	"flag"
    18  
    19  	"k8s.io/client-go/tools/clientcmd"
    20  	clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
    21  	"k8s.io/kubernetes/test/e2e/framework"
    22  
    23  	test "github.com/chaos-mesh/chaos-mesh/e2e-test"
    24  )
    25  
    26  // TestConfig for the test config
    27  var TestConfig = test.NewDefaultConfig()
    28  
    29  // RegisterOperatorFlags registers flags for chaos-mesh.
    30  func RegisterOperatorFlags(flags *flag.FlagSet) {
    31  	flags.StringVar(&TestConfig.ManagerImage, "manager-image", "pingcap/chaos-mesh", "chaos-mesh image")
    32  	flags.StringVar(&TestConfig.ManagerTag, "manager-image-tag", "latest", "chaos-mesh image tag")
    33  	flags.StringVar(&TestConfig.DaemonImage, "daemon-image", "pingcap/chaos-daemon", "chaos-daemon image")
    34  	flags.StringVar(&TestConfig.DaemonTag, "daemon-image-tag", "latest", "chaos-daemon image tag")
    35  	flags.StringVar(&TestConfig.E2EImage, "e2e-image", "pingcap/e2e-helper:latest", "e2e helper image")
    36  	flags.StringVar(&TestConfig.ChaosDNSImage, "chaos-dns-image", "pingcap/coredns:v0.2.0", "chaos-dns image")
    37  	flags.BoolVar(&TestConfig.InstallChaosMesh, "install-chaos-mesh", false, "automatically install chaos-mesh")
    38  	flags.BoolVar(&TestConfig.EnableDashboard, "enable-dashboard", false, "enable Chaos Dashboard")
    39  }
    40  
    41  // LoadClientRawConfig would provide client raw config
    42  func LoadClientRawConfig() (clientcmdapi.Config, error) {
    43  	loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
    44  	loadingRules.ExplicitPath = framework.TestContext.KubeConfig
    45  	overrides := &clientcmd.ConfigOverrides{ClusterDefaults: clientcmd.ClusterDefaults}
    46  	if framework.TestContext.KubeContext != "" {
    47  		overrides.CurrentContext = framework.TestContext.KubeContext
    48  	}
    49  	return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, overrides).RawConfig()
    50  }
    51