...

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

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

     1  // Copyright 2022 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  	"encoding/json"
    20  
    21  	corev1 "k8s.io/api/core/v1"
    22  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    23  )
    24  
    25  // +kubebuilder:object:root=true
    26  // +kubebuilder:resource:scope=Cluster
    27  // +kubebuilder:subresource:status
    28  // +chaos-mesh:base
    29  // RemoteCluster defines a remote cluster
    30  type RemoteCluster struct {
    31  	metav1.TypeMeta   `json:",inline"`
    32  	metav1.ObjectMeta `json:"metadata,omitempty"`
    33  
    34  	Spec RemoteClusterSpec `json:"spec,omitempty"`
    35  
    36  	// +optional
    37  	Status RemoteClusterStatus `json:"status,omitempty"`
    38  }
    39  
    40  // RemoteClusterSpec defines the specification of a remote cluster
    41  type RemoteClusterSpec struct {
    42  	Namespace string `json:"namespace"`
    43  	Version   string `json:"version"`
    44  
    45  	KubeConfig RemoteClusterKubeConfig `json:"kubeConfig"`
    46  
    47  	// +optional
    48  	// +kubebuilder:validation:Schemaless
    49  	// +kubebuilder:pruning:PreserveUnknownFields
    50  	// +kubebuilder:validation:Type=object
    51  	ConfigOverride json.RawMessage `json:"configOverride,omitempty"`
    52  }
    53  
    54  // RemoteClusterKubeConfig refers to a secret by which we'll use to connect remote cluster
    55  type RemoteClusterKubeConfig struct {
    56  	SecretRef RemoteClusterSecretRef `json:"secretRef"`
    57  }
    58  
    59  // RemoteClusterSecretRef refers to a secret in any namespaces
    60  type RemoteClusterSecretRef struct {
    61  	Namespace string `json:"namespace"`
    62  	Name      string `json:"name"`
    63  
    64  	Key string `json:"key"`
    65  }
    66  
    67  type RemoteClusterStatus struct {
    68  	CurrentVersion string `json:"currentVersion"`
    69  
    70  	// Conditions represents the current condition of the remote cluster
    71  	// +optional
    72  	Conditions         []RemoteClusterCondition `json:"conditions,omitempty"`
    73  	ObservedGeneration int64                    `json:"observedGeneration,omitempty"`
    74  }
    75  
    76  type RemoteClusterConditionType string
    77  
    78  var (
    79  	RemoteClusterConditionInstalled RemoteClusterConditionType = "Installed"
    80  	RemoteClusterConditionReady     RemoteClusterConditionType = "Ready"
    81  )
    82  
    83  type RemoteClusterCondition struct {
    84  	Type   RemoteClusterConditionType `json:"type"`
    85  	Status corev1.ConditionStatus     `json:"status"`
    86  	// +optional
    87  	Reason string `json:"reason"`
    88  }
    89  
    90  // RemoteClusterList contains a list of RemoteCluster
    91  // +kubebuilder:object:root=true
    92  type RemoteClusterList struct {
    93  	metav1.TypeMeta `json:",inline"`
    94  	metav1.ListMeta `json:"metadata,omitempty"`
    95  	Items           []RemoteCluster `json:"items"`
    96  }
    97