sigs.k8s.io/cluster-api@v1.7.1/internal/runtime/test/v1alpha1/fake_types.go (about)

     1  /*
     2  Copyright 2022 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1alpha1
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  
    22  	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
    23  	runtimecatalog "sigs.k8s.io/cluster-api/exp/runtime/catalog"
    24  	runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
    25  )
    26  
    27  // FakeRequest is a response for testing
    28  // +kubebuilder:object:root=true
    29  type FakeRequest struct {
    30  	metav1.TypeMeta `json:",inline"`
    31  
    32  	// CommonRequest contains Settings field common to all request types.
    33  	runtimehooksv1.CommonRequest `json:",inline"`
    34  
    35  	Cluster clusterv1.Cluster
    36  
    37  	Second string
    38  	First  int
    39  }
    40  
    41  var _ runtimehooksv1.ResponseObject = &FakeResponse{}
    42  
    43  // FakeResponse is a response for testing.
    44  // +kubebuilder:object:root=true
    45  type FakeResponse struct {
    46  	metav1.TypeMeta `json:",inline"`
    47  
    48  	runtimehooksv1.CommonResponse `json:",inline"`
    49  
    50  	Second string
    51  	First  int
    52  }
    53  
    54  func FakeHook(*FakeRequest, *FakeResponse) {}
    55  
    56  // SecondFakeRequest is a response for testing
    57  // +kubebuilder:object:root=true
    58  type SecondFakeRequest struct {
    59  	metav1.TypeMeta `json:",inline"`
    60  
    61  	// CommonRequest contains Settings field common to all request types.
    62  	runtimehooksv1.CommonRequest `json:",inline"`
    63  
    64  	Cluster clusterv1.Cluster
    65  
    66  	Second string
    67  	First  int
    68  }
    69  
    70  var _ runtimehooksv1.ResponseObject = &SecondFakeResponse{}
    71  
    72  // SecondFakeResponse is a response for testing.
    73  // +kubebuilder:object:root=true
    74  type SecondFakeResponse struct {
    75  	metav1.TypeMeta `json:",inline"`
    76  
    77  	runtimehooksv1.CommonResponse `json:",inline"`
    78  
    79  	Second string
    80  	First  int
    81  }
    82  
    83  func SecondFakeHook(*SecondFakeRequest, *SecondFakeResponse) {}
    84  
    85  // RetryableFakeRequest is a request for testing hooks with retryAfterSeconds.
    86  // +kubebuilder:object:root=true
    87  type RetryableFakeRequest struct {
    88  	metav1.TypeMeta `json:",inline"`
    89  
    90  	// CommonRequest contains Settings field common to all request types.
    91  	runtimehooksv1.CommonRequest `json:",inline"`
    92  
    93  	Cluster clusterv1.Cluster
    94  
    95  	Second string
    96  	First  int
    97  }
    98  
    99  var _ runtimehooksv1.RetryResponseObject = &RetryableFakeResponse{}
   100  
   101  // RetryableFakeResponse is a request for testing hooks with retryAfterSeconds.
   102  // +kubebuilder:object:root=true
   103  type RetryableFakeResponse struct {
   104  	metav1.TypeMeta `json:",inline"`
   105  
   106  	runtimehooksv1.CommonResponse `json:",inline"`
   107  
   108  	runtimehooksv1.CommonRetryResponse `json:",inline"`
   109  
   110  	Second string
   111  	First  int
   112  }
   113  
   114  // RetryableFakeHook is a request for testing hooks with retryAfterSeconds.
   115  func RetryableFakeHook(*RetryableFakeRequest, *RetryableFakeResponse) {}
   116  
   117  func init() {
   118  	catalogBuilder.RegisterHook(FakeHook, &runtimecatalog.HookMeta{
   119  		Tags:        []string{"fake-tag"},
   120  		Summary:     "FakeHook summary",
   121  		Description: "FakeHook description",
   122  		Deprecated:  true,
   123  	})
   124  
   125  	catalogBuilder.RegisterHook(SecondFakeHook, &runtimecatalog.HookMeta{
   126  		Tags:        []string{"fake-tag"},
   127  		Summary:     "SecondFakeHook summary",
   128  		Description: "SecondFakeHook description",
   129  		Deprecated:  true,
   130  	})
   131  
   132  	catalogBuilder.RegisterHook(RetryableFakeHook, &runtimecatalog.HookMeta{
   133  		Tags:        []string{"fake-tag"},
   134  		Summary:     "RetryableFakeHook summary",
   135  		Description: "RetryableFakeHook description",
   136  		Deprecated:  true,
   137  	})
   138  }