...

Source file src/github.com/chaos-mesh/chaos-mesh/api/v1alpha1/timechaos_types.go

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

     1  // Copyright 2021 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  package v1alpha1
    17  
    18  import (
    19  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    20  )
    21  
    22  // +kubebuilder:object:root=true
    23  // +kubebuilder:printcolumn:name="duration",type=string,JSONPath=`.spec.duration`
    24  // +chaos-mesh:experiment
    25  
    26  // TimeChaos is the Schema for the timechaos API
    27  type TimeChaos struct {
    28  	metav1.TypeMeta   `json:",inline"`
    29  	metav1.ObjectMeta `json:"metadata,omitempty"`
    30  
    31  	// Spec defines the behavior of a time chaos experiment
    32  	Spec TimeChaosSpec `json:"spec"`
    33  
    34  	// +optional
    35  	// Most recently observed status of the time chaos experiment
    36  	Status TimeChaosStatus `json:"status,omitempty"`
    37  }
    38  
    39  var _ InnerObjectWithSelector = (*TimeChaos)(nil)
    40  var _ InnerObject = (*TimeChaos)(nil)
    41  
    42  // TimeChaosSpec defines the desired state of TimeChaos
    43  type TimeChaosSpec struct {
    44  	ContainerSelector `json:",inline"`
    45  
    46  	// TimeOffset defines the delta time of injected program. It's a possibly signed sequence of decimal numbers, such as
    47  	// "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
    48  	TimeOffset string `json:"timeOffset" webhook:"TimeOffset"`
    49  
    50  	// ClockIds defines all affected clock id
    51  	// All available options are ["CLOCK_REALTIME","CLOCK_MONOTONIC","CLOCK_PROCESS_CPUTIME_ID","CLOCK_THREAD_CPUTIME_ID",
    52  	// "CLOCK_MONOTONIC_RAW","CLOCK_REALTIME_COARSE","CLOCK_MONOTONIC_COARSE","CLOCK_BOOTTIME","CLOCK_REALTIME_ALARM",
    53  	// "CLOCK_BOOTTIME_ALARM"]
    54  	// Default value is ["CLOCK_REALTIME"]
    55  	ClockIds []string `json:"clockIds,omitempty" webhook:"ClockIds,nilable"`
    56  
    57  	// Duration represents the duration of the chaos action
    58  	Duration *string `json:"duration,omitempty"`
    59  
    60  	// RemoteCluster represents the remote cluster where the chaos will be deployed
    61  	// +optional
    62  	RemoteCluster string `json:"remoteCluster,omitempty"`
    63  }
    64  
    65  // TimeChaosStatus defines the observed state of TimeChaos
    66  type TimeChaosStatus struct {
    67  	ChaosStatus `json:",inline"`
    68  }
    69  
    70  func (in *TimeChaos) GetSelectorSpecs() map[string]interface{} {
    71  	return map[string]interface{}{
    72  		".": &in.Spec.ContainerSelector,
    73  	}
    74  }
    75