...

Source file src/github.com/chaos-mesh/chaos-mesh/api/v1alpha1/zz_generated.schedule.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  	ScheduleTypeAWSChaos ScheduleTemplateType = "AWSChaos"
    28  	ScheduleTypeAzureChaos ScheduleTemplateType = "AzureChaos"
    29  	ScheduleTypeBlockChaos ScheduleTemplateType = "BlockChaos"
    30  	ScheduleTypeDNSChaos ScheduleTemplateType = "DNSChaos"
    31  	ScheduleTypeGCPChaos ScheduleTemplateType = "GCPChaos"
    32  	ScheduleTypeHTTPChaos ScheduleTemplateType = "HTTPChaos"
    33  	ScheduleTypeIOChaos ScheduleTemplateType = "IOChaos"
    34  	ScheduleTypeJVMChaos ScheduleTemplateType = "JVMChaos"
    35  	ScheduleTypeKernelChaos ScheduleTemplateType = "KernelChaos"
    36  	ScheduleTypeNetworkChaos ScheduleTemplateType = "NetworkChaos"
    37  	ScheduleTypePhysicalMachineChaos ScheduleTemplateType = "PhysicalMachineChaos"
    38  	ScheduleTypePodChaos ScheduleTemplateType = "PodChaos"
    39  	ScheduleTypeStressChaos ScheduleTemplateType = "StressChaos"
    40  	ScheduleTypeTimeChaos ScheduleTemplateType = "TimeChaos"
    41  	ScheduleTypeWorkflow ScheduleTemplateType = "Workflow"
    42  
    43  )
    44  
    45  var allScheduleTemplateType = []ScheduleTemplateType{
    46  	ScheduleTypeAWSChaos,
    47  	ScheduleTypeAzureChaos,
    48  	ScheduleTypeBlockChaos,
    49  	ScheduleTypeDNSChaos,
    50  	ScheduleTypeGCPChaos,
    51  	ScheduleTypeHTTPChaos,
    52  	ScheduleTypeIOChaos,
    53  	ScheduleTypeJVMChaos,
    54  	ScheduleTypeKernelChaos,
    55  	ScheduleTypeNetworkChaos,
    56  	ScheduleTypePhysicalMachineChaos,
    57  	ScheduleTypePodChaos,
    58  	ScheduleTypeStressChaos,
    59  	ScheduleTypeTimeChaos,
    60  	ScheduleTypeWorkflow,
    61  
    62  }
    63  
    64  func (it *ScheduleItem) SpawnNewObject(templateType ScheduleTemplateType) (GenericChaos, error) {
    65  	switch templateType {
    66  	case ScheduleTypeAWSChaos:
    67  		result := AWSChaos{}
    68  		result.Spec = *it.AWSChaos
    69  		return &result, nil
    70  	case ScheduleTypeAzureChaos:
    71  		result := AzureChaos{}
    72  		result.Spec = *it.AzureChaos
    73  		return &result, nil
    74  	case ScheduleTypeBlockChaos:
    75  		result := BlockChaos{}
    76  		result.Spec = *it.BlockChaos
    77  		return &result, nil
    78  	case ScheduleTypeDNSChaos:
    79  		result := DNSChaos{}
    80  		result.Spec = *it.DNSChaos
    81  		return &result, nil
    82  	case ScheduleTypeGCPChaos:
    83  		result := GCPChaos{}
    84  		result.Spec = *it.GCPChaos
    85  		return &result, nil
    86  	case ScheduleTypeHTTPChaos:
    87  		result := HTTPChaos{}
    88  		result.Spec = *it.HTTPChaos
    89  		return &result, nil
    90  	case ScheduleTypeIOChaos:
    91  		result := IOChaos{}
    92  		result.Spec = *it.IOChaos
    93  		return &result, nil
    94  	case ScheduleTypeJVMChaos:
    95  		result := JVMChaos{}
    96  		result.Spec = *it.JVMChaos
    97  		return &result, nil
    98  	case ScheduleTypeKernelChaos:
    99  		result := KernelChaos{}
   100  		result.Spec = *it.KernelChaos
   101  		return &result, nil
   102  	case ScheduleTypeNetworkChaos:
   103  		result := NetworkChaos{}
   104  		result.Spec = *it.NetworkChaos
   105  		return &result, nil
   106  	case ScheduleTypePhysicalMachineChaos:
   107  		result := PhysicalMachineChaos{}
   108  		result.Spec = *it.PhysicalMachineChaos
   109  		return &result, nil
   110  	case ScheduleTypePodChaos:
   111  		result := PodChaos{}
   112  		result.Spec = *it.PodChaos
   113  		return &result, nil
   114  	case ScheduleTypeStressChaos:
   115  		result := StressChaos{}
   116  		result.Spec = *it.StressChaos
   117  		return &result, nil
   118  	case ScheduleTypeTimeChaos:
   119  		result := TimeChaos{}
   120  		result.Spec = *it.TimeChaos
   121  		return &result, nil
   122  	case ScheduleTypeWorkflow:
   123  		result := Workflow{}
   124  		result.Spec = *it.Workflow
   125  		return &result, nil
   126  
   127  	default:
   128  		return nil, errors.Wrapf(errInvalidValue, "unknown template type %s", templateType)
   129  	}
   130  }
   131  
   132  func (it *ScheduleItem) RestoreChaosSpec(root interface{}) error {
   133  	switch chaos := root.(type) {
   134  	case *AWSChaos:
   135  		*it.AWSChaos = chaos.Spec
   136  		return nil
   137  	case *AzureChaos:
   138  		*it.AzureChaos = chaos.Spec
   139  		return nil
   140  	case *BlockChaos:
   141  		*it.BlockChaos = chaos.Spec
   142  		return nil
   143  	case *DNSChaos:
   144  		*it.DNSChaos = chaos.Spec
   145  		return nil
   146  	case *GCPChaos:
   147  		*it.GCPChaos = chaos.Spec
   148  		return nil
   149  	case *HTTPChaos:
   150  		*it.HTTPChaos = chaos.Spec
   151  		return nil
   152  	case *IOChaos:
   153  		*it.IOChaos = chaos.Spec
   154  		return nil
   155  	case *JVMChaos:
   156  		*it.JVMChaos = chaos.Spec
   157  		return nil
   158  	case *KernelChaos:
   159  		*it.KernelChaos = chaos.Spec
   160  		return nil
   161  	case *NetworkChaos:
   162  		*it.NetworkChaos = chaos.Spec
   163  		return nil
   164  	case *PhysicalMachineChaos:
   165  		*it.PhysicalMachineChaos = chaos.Spec
   166  		return nil
   167  	case *PodChaos:
   168  		*it.PodChaos = chaos.Spec
   169  		return nil
   170  	case *StressChaos:
   171  		*it.StressChaos = chaos.Spec
   172  		return nil
   173  	case *TimeChaos:
   174  		*it.TimeChaos = chaos.Spec
   175  		return nil
   176  	case *Workflow:
   177  		*it.Workflow = chaos.Spec
   178  		return nil
   179  
   180  	default:
   181  		return errors.Wrapf(errInvalidValue, "unknown chaos %#v", root)
   182  	}
   183  }
   184