Package common

import "github.com/chaos-mesh/chaos-mesh/pkg/chaosctl/common"

Overview ▾


const (
    ItemSuccess = iota + 1

func CreateClient

func CreateClient(ctx context.Context, managerNamespace, managerSvc string) (*ctrlclient.CtrlClient, context.CancelFunc, error)

func MarshalChaos

func MarshalChaos(s interface{}) (string, error)

MarshalChaos returns json in readable format

func PrettyPrint

func PrettyPrint(s string, indentLevel int, color Color)

PrettyPrint print with tab number and color

func PrintResult

func PrintResult(result []*ChaosResult)

PrintResult prints result to users in prettier format

type ChaosResult

type ChaosResult struct {
    Name string
    Pods []PodResult

type ClientSet

ClientSet contains two different clients

type ClientSet struct {
    CtrlCli client.Client
    KubeCli *kubernetes.Clientset

func InitClientSet

func InitClientSet() (*ClientSet, error)

InitClientSet inits two different clients that would be used

type Color

type Color string
const (
    Blue    Color = "Blue"
    Red     Color = "Red"
    Green   Color = "Green"
    Cyan    Color = "Cyan"
    NoColor Color = ""

type ItemResult

type ItemResult struct {
    Name    string
    Value   string
    Status  int    `json:",omitempty"`
    SucInfo string `json:",omitempty"`
    ErrInfo string `json:",omitempty"`

type PodResult

type PodResult struct {
    Name  string
    Items []ItemResult