func (in *KernelChaos) 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
}
GetSpecAndMetaString returns a string including the meta and spec field of this chaos object.
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()
}
func (in *GCPChaosList) ListChaos() []GenericChaos {
	var result []GenericChaos
	for _, item := range in.Items {
		item := item
		result = append(result, &item)
	}
	return result
}
func (in *GCPChaos) 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 *GCPChaos) IsOneShot() bool {
	if in.Spec.Action==NodeReset {
		return true
	}
	return false
}
var GCPChaosWebhookLog = logf.Log.WithName("GCPChaos-resource")
func (in *GCPChaos) ValidateCreate() error {
	GCPChaosWebhookLog.Info("validate create", "name", in.Name)
	return in.Validate()
}
func (in *GCPChaos) ValidateUpdate(old runtime.Object) error {
	GCPChaosWebhookLog.Info("validate update", "name", in.Name)
	if !reflect.DeepEqual(in.Spec, old.(*GCPChaos).Spec) {
		return ErrCanNotUpdateChaos
	}
	return in.Validate()
}
func (in *GCPChaos) ValidateDelete() error {
	GCPChaosWebhookLog.Info("validate delete", "name", in.Name)
	return nil
}
var _ webhook.Validator = &GCPChaos{}
func (in *GCPChaos) Validate() error {
	errs := gw.Validate(in)
	return gw.Aggregate(errs)
}
var _ webhook.Defaulter = &GCPChaos{}
func (in *GCPChaos) Default() {
	gw.Default(in)
}
const KindHTTPChaos = "HTTPChaos"
func (in *HTTPChaos) IsDeleted() bool {
	return !in.DeletionTimestamp.IsZero()
}
func (in *HTTPChaos) IsPaused() bool {
	if in.Annotations == nil || in.Annotations[PauseAnnotationKey] != "true" {
		return false
	}
	return true
}
func (in *HTTPChaos) GetObjectMeta() *metav1.ObjectMeta {
	return &in.ObjectMeta
}
func (in *HTTPChaosSpec) 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 *HTTPChaos) GetStatus() *ChaosStatus {
	return &in.Status.ChaosStatus
}
func (in *HTTPChaos) 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 HTTPChaosList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []HTTPChaos `json:"items"`
}
func (in *HTTPChaosList) DeepCopyList() GenericChaosList {
	return in.DeepCopy()
}
func (in *HTTPChaosList) ListChaos() []GenericChaos {
	var result []GenericChaos
	for _, item := range in.Items {
		item := item
		result = append(result, &item)
	}
	return result
}
func (in *HTTPChaos) 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 *HTTPChaos) IsOneShot() bool {
	return false
}
var HTTPChaosWebhookLog = logf.Log.WithName("HTTPChaos-resource")
func (in *HTTPChaos) ValidateCreate() error {
	HTTPChaosWebhookLog.Info("validate create", "name", in.Name)
	return in.Validate()
}
func (in *HTTPChaos) ValidateUpdate(old runtime.Object) error {
	HTTPChaosWebhookLog.Info("validate update", "name", in.Name)
	if !reflect.DeepEqual(in.Spec, old.(*HTTPChaos).Spec) {
		return ErrCanNotUpdateChaos
	}
	return in.Validate()
}
func (in *HTTPChaos) ValidateDelete() error {
	HTTPChaosWebhookLog.Info("validate delete", "name", in.Name)
	return nil
}
var _ webhook.Validator = &HTTPChaos{}
func (in *HTTPChaos) Validate() error {
	errs := gw.Validate(in)
	return gw.Aggregate(errs)
}
var _ webhook.Defaulter = &HTTPChaos{}
func (in *HTTPChaos) Default() {
	gw.Default(in)
}
const KindIOChaos = "IOChaos"
func (in *IOChaos) IsDeleted() bool {
	return !in.DeletionTimestamp.IsZero()
}
func (in *IOChaos) IsPaused() bool {
	if in.Annotations == nil || in.Annotations[PauseAnnotationKey] != "true" {
		return false
	}
	return true
}
func (in *IOChaos) GetObjectMeta() *metav1.ObjectMeta {
	return &in.ObjectMeta
}
func (in *IOChaosSpec) 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 *IOChaos) GetStatus() *ChaosStatus {
	return &in.Status.ChaosStatus
}
func (in *IOChaos) 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 IOChaosList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []IOChaos `json:"items"`
}
func (in *IOChaosList) DeepCopyList() GenericChaosList {
	return in.DeepCopy()
}
func (in *IOChaosList) ListChaos() []GenericChaos {
	var result []GenericChaos
	for _, item := range in.Items {
		item := item
		result = append(result, &item)
	}
	return result
}
func (in *IOChaos) 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 *IOChaos) IsOneShot() bool {
	return false
}
var IOChaosWebhookLog = logf.Log.WithName("IOChaos-resource")
func (in *IOChaos) ValidateCreate() error {
	IOChaosWebhookLog.Info("validate create", "name", in.Name)
	return in.Validate()
}
func (in *IOChaos) ValidateUpdate(old runtime.Object) error {
	IOChaosWebhookLog.Info("validate update", "name", in.Name)
	if !reflect.DeepEqual(in.Spec, old.(*IOChaos).Spec) {
		return ErrCanNotUpdateChaos
	}
	return in.Validate()
}
func (in *IOChaos) ValidateDelete() error {
	IOChaosWebhookLog.Info("validate delete", "name", in.Name)
	return nil
}
var _ webhook.Validator = &IOChaos{}
func (in *IOChaos) Validate() error {
	errs := gw.Validate(in)
	return gw.Aggregate(errs)
}
var _ webhook.Defaulter = &IOChaos{}
func (in *IOChaos) Default() {
	gw.Default(in)
}
const KindJVMChaos = "JVMChaos"
func (in *JVMChaos) IsDeleted() bool {
	return !in.DeletionTimestamp.IsZero()
}
func (in *JVMChaos) IsPaused() bool {
	if in.Annotations == nil || in.Annotations[PauseAnnotationKey] != "true" {
		return false
	}
	return true
}
func (in *JVMChaos) GetObjectMeta() *metav1.ObjectMeta {
	return &in.ObjectMeta
}
func (in *JVMChaosSpec) 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 *JVMChaos) GetStatus() *ChaosStatus {
	return &in.Status.ChaosStatus
}
func (in *JVMChaos) 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 JVMChaosList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []JVMChaos `json:"items"`
}
func (in *JVMChaosList) DeepCopyList() GenericChaosList {
	return in.DeepCopy()
}
func (in *JVMChaosList) ListChaos() []GenericChaos {
	var result []GenericChaos
	for _, item := range in.Items {
		item := item
		result = append(result, &item)
	}
	return result
}
func (in *JVMChaos) 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 *JVMChaos) IsOneShot() bool {
	return false
}
var JVMChaosWebhookLog = logf.Log.WithName("JVMChaos-resource")
func (in *JVMChaos) ValidateCreate() error {
	JVMChaosWebhookLog.Info("validate create", "name", in.Name)
	return in.Validate()
}
func (in *JVMChaos) ValidateUpdate(old runtime.Object) error {
	JVMChaosWebhookLog.Info("validate update", "name", in.Name)
	if !reflect.DeepEqual(in.Spec, old.(*JVMChaos).Spec) {
		return ErrCanNotUpdateChaos
	}
	return in.Validate()
}
func (in *JVMChaos) ValidateDelete() error {
	JVMChaosWebhookLog.Info("validate delete", "name", in.Name)
	return nil
}
var _ webhook.Validator = &JVMChaos{}
func (in *JVMChaos) Validate() error {
	errs := gw.Validate(in)
	return gw.Aggregate(errs)
}
var _ webhook.Defaulter = &JVMChaos{}
func (in *JVMChaos) Default() {
	gw.Default(in)
}
const KindKernelChaos = "KernelChaos"
func (in *KernelChaos) IsDeleted() bool {
	return !in.DeletionTimestamp.IsZero()
}
func (in *KernelChaos) IsPaused() bool {
	if in.Annotations == nil || in.Annotations[PauseAnnotationKey] != "true" {
		return false
	}
	return true
}
func (in *KernelChaos) GetObjectMeta() *metav1.ObjectMeta {
	return &in.ObjectMeta
}
func (in *KernelChaosSpec) 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 *KernelChaos) GetStatus() *ChaosStatus {
	return &in.Status.ChaosStatus
}