...

Source file src/github.com/chaos-mesh/chaos-mesh/api/v1alpha1/zz_generated.workflow.chaosmesh.go

Documentation: github.com/chaos-mesh/chaos-mesh/api/v1alpha1

     1  // Copyright 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  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  
    16  // Code generated by chaos-builder. DO NOT EDIT.
    17  
    18  package v1alpha1
    19  
    20  
    21  import (
    22  	"fmt"
    23  )
    24  
    25  
    26  const (
    27  	TypeAWSChaos TemplateType = "AWSChaos"
    28  	TypeDNSChaos TemplateType = "DNSChaos"
    29  	TypeGCPChaos TemplateType = "GCPChaos"
    30  	TypeHTTPChaos TemplateType = "HTTPChaos"
    31  	TypeIOChaos TemplateType = "IOChaos"
    32  	TypeJVMChaos TemplateType = "JVMChaos"
    33  	TypeKernelChaos TemplateType = "KernelChaos"
    34  	TypeNetworkChaos TemplateType = "NetworkChaos"
    35  	TypePhysicalMachineChaos TemplateType = "PhysicalMachineChaos"
    36  	TypePodChaos TemplateType = "PodChaos"
    37  	TypeStressChaos TemplateType = "StressChaos"
    38  	TypeTimeChaos TemplateType = "TimeChaos"
    39  
    40  )
    41  
    42  var allChaosTemplateType = []TemplateType{
    43  	TypeSchedule,
    44  	TypeAWSChaos,
    45  	TypeDNSChaos,
    46  	TypeGCPChaos,
    47  	TypeHTTPChaos,
    48  	TypeIOChaos,
    49  	TypeJVMChaos,
    50  	TypeKernelChaos,
    51  	TypeNetworkChaos,
    52  	TypePhysicalMachineChaos,
    53  	TypePodChaos,
    54  	TypeStressChaos,
    55  	TypeTimeChaos,
    56  
    57  }
    58  
    59  type EmbedChaos struct {
    60  	// +optional
    61  	AWSChaos *AWSChaosSpec `json:"awsChaos,omitempty"`
    62  	// +optional
    63  	DNSChaos *DNSChaosSpec `json:"dnsChaos,omitempty"`
    64  	// +optional
    65  	GCPChaos *GCPChaosSpec `json:"gcpChaos,omitempty"`
    66  	// +optional
    67  	HTTPChaos *HTTPChaosSpec `json:"httpChaos,omitempty"`
    68  	// +optional
    69  	IOChaos *IOChaosSpec `json:"ioChaos,omitempty"`
    70  	// +optional
    71  	JVMChaos *JVMChaosSpec `json:"jvmChaos,omitempty"`
    72  	// +optional
    73  	KernelChaos *KernelChaosSpec `json:"kernelChaos,omitempty"`
    74  	// +optional
    75  	NetworkChaos *NetworkChaosSpec `json:"networkChaos,omitempty"`
    76  	// +optional
    77  	PhysicalMachineChaos *PhysicalMachineChaosSpec `json:"physicalmachineChaos,omitempty"`
    78  	// +optional
    79  	PodChaos *PodChaosSpec `json:"podChaos,omitempty"`
    80  	// +optional
    81  	StressChaos *StressChaosSpec `json:"stressChaos,omitempty"`
    82  	// +optional
    83  	TimeChaos *TimeChaosSpec `json:"timeChaos,omitempty"`
    84  
    85  }
    86  
    87  func (it *EmbedChaos) SpawnNewObject(templateType TemplateType) (GenericChaos, error) {
    88  	switch templateType {
    89  	case TypeAWSChaos:
    90  		result := AWSChaos{}
    91  		result.Spec = *it.AWSChaos
    92  		return &result, nil
    93  	case TypeDNSChaos:
    94  		result := DNSChaos{}
    95  		result.Spec = *it.DNSChaos
    96  		return &result, nil
    97  	case TypeGCPChaos:
    98  		result := GCPChaos{}
    99  		result.Spec = *it.GCPChaos
   100  		return &result, nil
   101  	case TypeHTTPChaos:
   102  		result := HTTPChaos{}
   103  		result.Spec = *it.HTTPChaos
   104  		return &result, nil
   105  	case TypeIOChaos:
   106  		result := IOChaos{}
   107  		result.Spec = *it.IOChaos
   108  		return &result, nil
   109  	case TypeJVMChaos:
   110  		result := JVMChaos{}
   111  		result.Spec = *it.JVMChaos
   112  		return &result, nil
   113  	case TypeKernelChaos:
   114  		result := KernelChaos{}
   115  		result.Spec = *it.KernelChaos
   116  		return &result, nil
   117  	case TypeNetworkChaos:
   118  		result := NetworkChaos{}
   119  		result.Spec = *it.NetworkChaos
   120  		return &result, nil
   121  	case TypePhysicalMachineChaos:
   122  		result := PhysicalMachineChaos{}
   123  		result.Spec = *it.PhysicalMachineChaos
   124  		return &result, nil
   125  	case TypePodChaos:
   126  		result := PodChaos{}
   127  		result.Spec = *it.PodChaos
   128  		return &result, nil
   129  	case TypeStressChaos:
   130  		result := StressChaos{}
   131  		result.Spec = *it.StressChaos
   132  		return &result, nil
   133  	case TypeTimeChaos:
   134  		result := TimeChaos{}
   135  		result.Spec = *it.TimeChaos
   136  		return &result, nil
   137  
   138  	default:
   139  		return nil, fmt.Errorf("unsupported template type %s", templateType)
   140  	}
   141  }
   142  
   143  func (it *EmbedChaos) RestoreChaosSpec(root interface{}) error {
   144  	switch chaos := root.(type) {
   145  	case *AWSChaos:
   146  		*it.AWSChaos = chaos.Spec
   147  		return nil
   148  	case *DNSChaos:
   149  		*it.DNSChaos = chaos.Spec
   150  		return nil
   151  	case *GCPChaos:
   152  		*it.GCPChaos = chaos.Spec
   153  		return nil
   154  	case *HTTPChaos:
   155  		*it.HTTPChaos = chaos.Spec
   156  		return nil
   157  	case *IOChaos:
   158  		*it.IOChaos = chaos.Spec
   159  		return nil
   160  	case *JVMChaos:
   161  		*it.JVMChaos = chaos.Spec
   162  		return nil
   163  	case *KernelChaos:
   164  		*it.KernelChaos = chaos.Spec
   165  		return nil
   166  	case *NetworkChaos:
   167  		*it.NetworkChaos = chaos.Spec
   168  		return nil
   169  	case *PhysicalMachineChaos:
   170  		*it.PhysicalMachineChaos = chaos.Spec
   171  		return nil
   172  	case *PodChaos:
   173  		*it.PodChaos = chaos.Spec
   174  		return nil
   175  	case *StressChaos:
   176  		*it.StressChaos = chaos.Spec
   177  		return nil
   178  	case *TimeChaos:
   179  		*it.TimeChaos = chaos.Spec
   180  		return nil
   181  
   182  	default:
   183  		return fmt.Errorf("unsupported chaos %#v", root)
   184  	}
   185  }
   186  
   187  func (it *EmbedChaos) SpawnNewList(templateType TemplateType) (GenericChaosList, error) {
   188  	switch templateType {
   189  	case TypeAWSChaos:
   190  		result := AWSChaosList{}
   191  		return &result, nil
   192  	case TypeDNSChaos:
   193  		result := DNSChaosList{}
   194  		return &result, nil
   195  	case TypeGCPChaos:
   196  		result := GCPChaosList{}
   197  		return &result, nil
   198  	case TypeHTTPChaos:
   199  		result := HTTPChaosList{}
   200  		return &result, nil
   201  	case TypeIOChaos:
   202  		result := IOChaosList{}
   203  		return &result, nil
   204  	case TypeJVMChaos:
   205  		result := JVMChaosList{}
   206  		return &result, nil
   207  	case TypeKernelChaos:
   208  		result := KernelChaosList{}
   209  		return &result, nil
   210  	case TypeNetworkChaos:
   211  		result := NetworkChaosList{}
   212  		return &result, nil
   213  	case TypePhysicalMachineChaos:
   214  		result := PhysicalMachineChaosList{}
   215  		return &result, nil
   216  	case TypePodChaos:
   217  		result := PodChaosList{}
   218  		return &result, nil
   219  	case TypeStressChaos:
   220  		result := StressChaosList{}
   221  		return &result, nil
   222  	case TypeTimeChaos:
   223  		result := TimeChaosList{}
   224  		return &result, nil
   225  
   226  	default:
   227  		return nil, fmt.Errorf("unsupported template type %s", templateType)
   228  	}
   229  }
   230  
   231  func (in *AWSChaosList) GetItems() []GenericChaos {
   232  	var result []GenericChaos
   233  	for _, item := range in.Items {
   234  		item := item
   235  		result = append(result, &item)
   236  	}
   237  	return result
   238  }
   239  func (in *DNSChaosList) GetItems() []GenericChaos {
   240  	var result []GenericChaos
   241  	for _, item := range in.Items {
   242  		item := item
   243  		result = append(result, &item)
   244  	}
   245  	return result
   246  }
   247  func (in *GCPChaosList) GetItems() []GenericChaos {
   248  	var result []GenericChaos
   249  	for _, item := range in.Items {
   250  		item := item
   251  		result = append(result, &item)
   252  	}
   253  	return result
   254  }
   255  func (in *HTTPChaosList) GetItems() []GenericChaos {
   256  	var result []GenericChaos
   257  	for _, item := range in.Items {
   258  		item := item
   259  		result = append(result, &item)
   260  	}
   261  	return result
   262  }
   263  func (in *IOChaosList) GetItems() []GenericChaos {
   264  	var result []GenericChaos
   265  	for _, item := range in.Items {
   266  		item := item
   267  		result = append(result, &item)
   268  	}
   269  	return result
   270  }
   271  func (in *JVMChaosList) GetItems() []GenericChaos {
   272  	var result []GenericChaos
   273  	for _, item := range in.Items {
   274  		item := item
   275  		result = append(result, &item)
   276  	}
   277  	return result
   278  }
   279  func (in *KernelChaosList) GetItems() []GenericChaos {
   280  	var result []GenericChaos
   281  	for _, item := range in.Items {
   282  		item := item
   283  		result = append(result, &item)
   284  	}
   285  	return result
   286  }
   287  func (in *NetworkChaosList) GetItems() []GenericChaos {
   288  	var result []GenericChaos
   289  	for _, item := range in.Items {
   290  		item := item
   291  		result = append(result, &item)
   292  	}
   293  	return result
   294  }
   295  func (in *PhysicalMachineChaosList) GetItems() []GenericChaos {
   296  	var result []GenericChaos
   297  	for _, item := range in.Items {
   298  		item := item
   299  		result = append(result, &item)
   300  	}
   301  	return result
   302  }
   303  func (in *PodChaosList) GetItems() []GenericChaos {
   304  	var result []GenericChaos
   305  	for _, item := range in.Items {
   306  		item := item
   307  		result = append(result, &item)
   308  	}
   309  	return result
   310  }
   311  func (in *StressChaosList) GetItems() []GenericChaos {
   312  	var result []GenericChaos
   313  	for _, item := range in.Items {
   314  		item := item
   315  		result = append(result, &item)
   316  	}
   317  	return result
   318  }
   319  func (in *TimeChaosList) GetItems() []GenericChaos {
   320  	var result []GenericChaos
   321  	for _, item := range in.Items {
   322  		item := item
   323  		result = append(result, &item)
   324  	}
   325  	return result
   326  }
   327  
   328