func (in *GCPChaosList) ListChaos() []GenericChaos {
	var result []GenericChaos
	for _, item := range in.Items {
		item := item
		result = append(result, &item)
	}
	return result
}
ListChaos returns a list of chaos
package v1alpha1
import (
	"encoding/json"
	"reflect"
	"time"
	"fmt"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"sigs.k8s.io/controller-runtime/pkg/webhook"
	logf "sigs.k8s.io/controller-runtime/pkg/log"
	"k8s.io/apimachinery/pkg/runtime"
	gw "github.com/chaos-mesh/chaos-mesh/api/v1alpha1/genericwebhook"
)
var ErrCanNotUpdateChaos = fmt.Errorf("Cannot update chaos spec")
const KindAWSChaos = "AWSChaos"
func (in *AWSChaos) IsDeleted() bool {
	return !in.DeletionTimestamp.IsZero()
}
func (in *AWSChaos) IsPaused() bool {
	if in.Annotations == nil || in.Annotations[PauseAnnotationKey] != "true" {
		return false
	}
	return true
}
func (in *AWSChaos) GetObjectMeta() *metav1.ObjectMeta {
	return &in.ObjectMeta
}
func (in *AWSChaosSpec) GetDuration() (*time.Duration, error) {
	if in.Duration == nil {
		return nil, nil
	}
	duration, err := time.ParseDuration(string(*in.Duration))
	if err != nil {
		return nil, err
	}
	return &duration, nil
}
func (in *AWSChaos) GetStatus() *ChaosStatus {
	return &in.Status.ChaosStatus
}
func (in *AWSChaos) GetSpecAndMetaString() (string, error) {
	spec, err := json.Marshal(in.Spec)
	if err != nil {
		return "", err
	}
	meta := in.ObjectMeta.DeepCopy()
	meta.SetResourceVersion("")
	meta.SetGeneration(0)
	return string(spec) + meta.String(), nil
}
type AWSChaosList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []AWSChaos `json:"items"`
}
func (in *AWSChaosList) DeepCopyList() GenericChaosList {
	return in.DeepCopy()
}
func (in *AWSChaosList) ListChaos() []GenericChaos {
	var result []GenericChaos
	for _, item := range in.Items {
		item := item
		result = append(result, &item)
	}
	return result
}
func (in *AWSChaos) DurationExceeded(now time.Time) (bool, time.Duration, error) {
	duration, err := in.Spec.GetDuration()
	if err != nil {
		return false, 0, err
	}
	if duration != nil {
		stopTime := in.GetCreationTimestamp().Add(*duration)
		if stopTime.Before(now) {
			return true, 0, nil
		}
		return false, stopTime.Sub(now), nil
	}
	return false, 0, nil
}
func (in *AWSChaos) IsOneShot() bool {
	if in.Spec.Action==Ec2Restart {
		return true
	}
	return false
}
var AWSChaosWebhookLog = logf.Log.WithName("AWSChaos-resource")
func (in *AWSChaos) ValidateCreate() error {
	AWSChaosWebhookLog.Info("validate create", "name", in.Name)
	return in.Validate()
}
func (in *AWSChaos) ValidateUpdate(old runtime.Object) error {
	AWSChaosWebhookLog.Info("validate update", "name", in.Name)
	if !reflect.DeepEqual(in.Spec, old.(*AWSChaos).Spec) {
		return ErrCanNotUpdateChaos
	}
	return in.Validate()
}
func (in *AWSChaos) ValidateDelete() error {
	AWSChaosWebhookLog.Info("validate delete", "name", in.Name)
	return nil
}
var _ webhook.Validator = &AWSChaos{}
func (in *AWSChaos) Validate() error {
	errs := gw.Validate(in)
	return gw.Aggregate(errs)
}
var _ webhook.Defaulter = &AWSChaos{}
func (in *AWSChaos) Default() {
	gw.Default(in)
}
const KindDNSChaos = "DNSChaos"
func (in *DNSChaos) IsDeleted() bool {
	return !in.DeletionTimestamp.IsZero()
}
func (in *DNSChaos) IsPaused() bool {
	if in.Annotations == nil || in.Annotations[PauseAnnotationKey] != "true" {
		return false
	}
	return true
}
func (in *DNSChaos) GetObjectMeta() *metav1.ObjectMeta {
	return &in.ObjectMeta
}
func (in *DNSChaosSpec) GetDuration() (*time.Duration, error) {
	if in.Duration == nil {
		return nil, nil
	}
	duration, err := time.ParseDuration(string(*in.Duration))
	if err != nil {
		return nil, err
	}
	return &duration, nil
}
func (in *DNSChaos) GetStatus() *ChaosStatus {
	return &in.Status.ChaosStatus
}
func (in *DNSChaos) GetSpecAndMetaString() (string, error) {
	spec, err := json.Marshal(in.Spec)
	if err != nil {
		return "", err
	}
	meta := in.ObjectMeta.DeepCopy()
	meta.SetResourceVersion("")
	meta.SetGeneration(0)
	return string(spec) + meta.String(), nil
}
type DNSChaosList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []DNSChaos `json:"items"`
}
func (in *DNSChaosList) DeepCopyList() GenericChaosList {
	return in.DeepCopy()
}
func (in *DNSChaosList) ListChaos() []GenericChaos {
	var result []GenericChaos
	for _, item := range in.Items {
		item := item
		result = append(result, &item)
	}
	return result
}
func (in *DNSChaos) DurationExceeded(now time.Time) (bool, time.Duration, error) {
	duration, err := in.Spec.GetDuration()
	if err != nil {
		return false, 0, err
	}
	if duration != nil {
		stopTime := in.GetCreationTimestamp().Add(*duration)
		if stopTime.Before(now) {
			return true, 0, nil
		}
		return false, stopTime.Sub(now), nil
	}
	return false, 0, nil
}
func (in *DNSChaos) IsOneShot() bool {
	return false
}
var DNSChaosWebhookLog = logf.Log.WithName("DNSChaos-resource")
func (in *DNSChaos) ValidateCreate() error {
	DNSChaosWebhookLog.Info("validate create", "name", in.Name)
	return in.Validate()
}
func (in *DNSChaos) ValidateUpdate(old runtime.Object) error {
	DNSChaosWebhookLog.Info("validate update", "name", in.Name)
	if !reflect.DeepEqual(in.Spec, old.(*DNSChaos).Spec) {
		return ErrCanNotUpdateChaos
	}
	return in.Validate()
}
func (in *DNSChaos) ValidateDelete() error {
	DNSChaosWebhookLog.Info("validate delete", "name", in.Name)
	return nil
}
var _ webhook.Validator = &DNSChaos{}
func (in *DNSChaos) Validate() error {
	errs := gw.Validate(in)
	return gw.Aggregate(errs)
}
var _ webhook.Defaulter = &DNSChaos{}
func (in *DNSChaos) Default() {
	gw.Default(in)
}
const KindGCPChaos = "GCPChaos"
func (in *GCPChaos) IsDeleted() bool {
	return !in.DeletionTimestamp.IsZero()
}
func (in *GCPChaos) IsPaused() bool {
	if in.Annotations == nil || in.Annotations[PauseAnnotationKey] != "true" {
		return false
	}
	return true
}
func (in *GCPChaos) GetObjectMeta() *metav1.ObjectMeta {
	return &in.ObjectMeta
}
func (in *GCPChaosSpec) GetDuration() (*time.Duration, error) {
	if in.Duration == nil {
		return nil, nil
	}
	duration, err := time.ParseDuration(string(*in.Duration))
	if err != nil {
		return nil, err
	}
	return &duration, nil
}
func (in *GCPChaos) GetStatus() *ChaosStatus {
	return &in.Status.ChaosStatus
}
func (in *GCPChaos) GetSpecAndMetaString() (string, error) {
	spec, err := json.Marshal(in.Spec)
	if err != nil {
		return "", err
	}
	meta := in.ObjectMeta.DeepCopy()
	meta.SetResourceVersion("")
	meta.SetGeneration(0)
	return string(spec) + meta.String(), nil
}
type GCPChaosList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []GCPChaos `json:"items"`
}
func (in *GCPChaosList) DeepCopyList() GenericChaosList {
	return in.DeepCopy()
}