...

Source file src/kubevirt.io/controller-lifecycle-operator-sdk/api/types.go

Documentation: kubevirt.io/controller-lifecycle-operator-sdk/api

     1  package api
     2  
     3  import (
     4  	conditions "github.com/openshift/custom-resource-status/conditions/v1"
     5  	corev1 "k8s.io/api/core/v1"
     6  )
     7  
     8  // Phase is the current phase of the deployment
     9  type Phase string
    10  
    11  const (
    12  	// PhaseDeploying signals that the resources are being deployed
    13  	PhaseDeploying Phase = "Deploying"
    14  
    15  	// PhaseDeployed signals that the resources are successfully deployed
    16  	PhaseDeployed Phase = "Deployed"
    17  
    18  	// PhaseDeleting signals that the resources are being removed
    19  	PhaseDeleting Phase = "Deleting"
    20  
    21  	// PhaseDeleted signals that the resources are deleted
    22  	PhaseDeleted Phase = "Deleted"
    23  
    24  	// PhaseError signals that the deployment is in an error state
    25  	PhaseError Phase = "Error"
    26  
    27  	// PhaseUpgrading signals that the resources are being deployed
    28  	PhaseUpgrading Phase = "Upgrading"
    29  
    30  	// PhaseEmpty is an uninitialized phase
    31  	PhaseEmpty Phase = ""
    32  )
    33  
    34  // Status represents status of a operator configuration resource; must be inlined in the operator configuration resource status
    35  type Status struct {
    36  	Phase Phase `json:"phase,omitempty"`
    37  	// A list of current conditions of the resource
    38  	Conditions []conditions.Condition `json:"conditions,omitempty" optional:"true"`
    39  	// The version of the resource as defined by the operator
    40  	OperatorVersion string `json:"operatorVersion,omitempty" optional:"true"`
    41  	// The desired version of the resource
    42  	TargetVersion string `json:"targetVersion,omitempty" optional:"true"`
    43  	// The observed version of the resource
    44  	ObservedVersion string `json:"observedVersion,omitempty" optional:"true"`
    45  }
    46  
    47  // NodePlacement describes node scheduling configuration.
    48  // +k8s:openapi-gen=true
    49  type NodePlacement struct {
    50  	// nodeSelector is the node selector applied to the relevant kind of pods
    51  	// It specifies a map of key-value pairs: for the pod to be eligible to run on a node,
    52  	// the node must have each of the indicated key-value pairs as labels
    53  	// (it can have additional labels as well).
    54  	// See https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
    55  	// +kubebuilder:validation:Optional
    56  	// +optional
    57  	NodeSelector map[string]string `json:"nodeSelector,omitempty"`
    58  
    59  	// affinity enables pod affinity/anti-affinity placement expanding the types of constraints
    60  	// that can be expressed with nodeSelector.
    61  	// affinity is going to be applied to the relevant kind of pods in parallel with nodeSelector
    62  	// See https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity
    63  	// +kubebuilder:validation:Optional
    64  	// +optional
    65  	Affinity *corev1.Affinity `json:"affinity,omitempty"`
    66  
    67  	// tolerations is a list of tolerations applied to the relevant kind of pods
    68  	// See https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ for more info.
    69  	// These are additional tolerations other than default ones.
    70  	// +kubebuilder:validation:Optional
    71  	// +optional
    72  	Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
    73  }
    74  
    75  // DeepCopyInto is copying the receiver, writing into out. in must be non-nil.
    76  func (in *Status) DeepCopyInto(out *Status) {
    77  	*out = *in
    78  	if in.Conditions != nil {
    79  		in, out := &in.Conditions, &out.Conditions
    80  		*out = make([]conditions.Condition, len(*in))
    81  		for i := range *in {
    82  			(*in)[i].DeepCopyInto(&(*out)[i])
    83  		}
    84  	}
    85  }
    86  
    87  // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
    88  func (in *NodePlacement) DeepCopyInto(out *NodePlacement) {
    89  	*out = *in
    90  	if in.NodeSelector != nil {
    91  		in, out := &in.NodeSelector, &out.NodeSelector
    92  		*out = make(map[string]string, len(*in))
    93  		for key, val := range *in {
    94  			(*out)[key] = val
    95  		}
    96  	}
    97  	if in.Affinity != nil {
    98  		in, out := &in.Affinity, &out.Affinity
    99  		*out = new(corev1.Affinity)
   100  		(*in).DeepCopyInto(*out)
   101  	}
   102  	if in.Tolerations != nil {
   103  		in, out := &in.Tolerations, &out.Tolerations
   104  		*out = make([]corev1.Toleration, len(*in))
   105  		for i := range *in {
   106  			(*in)[i].DeepCopyInto(&(*out)[i])
   107  		}
   108  	}
   109  	return
   110  }
   111  
   112  // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodePlacement.
   113  func (in *NodePlacement) DeepCopy() *NodePlacement {
   114  	if in == nil {
   115  		return nil
   116  	}
   117  	out := new(NodePlacement)
   118  	in.DeepCopyInto(out)
   119  	return out
   120  }
   121  
   122  // SwaggerDoc provides documentation for NodePlacement
   123  func (NodePlacement) SwaggerDoc() map[string]string {
   124  	return map[string]string{
   125  		"":             "NodePlacement describes  node scheduling configuration.",
   126  		"nodeSelector": "nodeSelector is the node selector applied to the relevant kind of pods\nIt specifies a map of key-value pairs: for the pod to be eligible to run on a node,\nthe node must have each of the indicated key-value pairs as labels\n(it can have additional labels as well).\nSee https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector\n+kubebuilder:validation:Optional\n+optional",
   127  		"affinity":     "affinity enables pod affinity/anti-affinity placement expanding the types of constraints\nthat can be expressed with nodeSelector.\naffinity is going to be applied to the relevant kind of pods in parallel with nodeSelector\nSee https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity\n+kubebuilder:validation:Optional\n+optional",
   128  		"tolerations":  "tolerations is a list of tolerations applied to the relevant kind of pods\nSee https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ for more info.\nThese are additional tolerations other than default ones.\n+kubebuilder:validation:Optional\n+optional",
   129  	}
   130  }
   131  

View as plain text