...

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