knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/apis/test/pub/v1alpha1/bar_types.go (about)

     1  /*
     2  Copyright 2020 The Knative 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  	"context"
    21  
    22  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    23  	"k8s.io/apimachinery/pkg/runtime/schema"
    24  	"knative.dev/pkg/apis"
    25  	duckv1 "knative.dev/pkg/apis/duck/v1"
    26  	"knative.dev/pkg/kmeta"
    27  )
    28  
    29  // +genclient
    30  // +genreconciler:class=example.com/filter.class,stubs
    31  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    32  
    33  // Bar is for testing.
    34  type Bar struct {
    35  	metav1.TypeMeta `json:",inline"`
    36  	// +optional
    37  	metav1.ObjectMeta `json:"metadata,omitempty"`
    38  
    39  	// Spec holds the desired state of the Bar (from the client).
    40  	// +optional
    41  	Spec BarSpec `json:"spec,omitempty"`
    42  
    43  	// Status communicates the observed state of the Bar (from the controller).
    44  	// +optional
    45  	Status BarStatus `json:"status,omitempty"`
    46  }
    47  
    48  // Check that Bar can be validated and defaulted.
    49  var (
    50  	_ apis.Validatable   = (*Bar)(nil)
    51  	_ apis.Defaultable   = (*Bar)(nil)
    52  	_ kmeta.OwnerRefable = (*Bar)(nil)
    53  	_ duckv1.KRShaped    = (*Bar)(nil)
    54  )
    55  
    56  // BarSpec holds the desired state of the Bar (from the client).
    57  type BarSpec struct{}
    58  
    59  // BarStatus communicates the observed state of the Bar (from the controller).
    60  type BarStatus struct {
    61  	duckv1.Status `json:",inline"`
    62  }
    63  
    64  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    65  
    66  // BarList is a list of Bar resources
    67  type BarList struct {
    68  	metav1.TypeMeta `json:",inline"`
    69  	metav1.ListMeta `json:"metadata"`
    70  
    71  	Items []Bar `json:"items"`
    72  }
    73  
    74  // -- lifecycle --
    75  
    76  func (bs *BarStatus) InitializeConditions() {}
    77  
    78  // GetGroupVersionKind implements kmeta.OwnerRefable
    79  func (b *Bar) GetGroupVersionKind() schema.GroupVersionKind {
    80  	return SchemeGroupVersion.WithKind("Bar")
    81  }
    82  
    83  // -- Defaults --
    84  
    85  // SetDefaults implements apis.Defaultable
    86  func (b *Bar) SetDefaults(ctx context.Context) {
    87  	// Nothing to default.
    88  }
    89  
    90  // -- Validation --
    91  
    92  // Validate implements apis.Validatable
    93  func (b *Bar) Validate(ctx context.Context) *apis.FieldError {
    94  	// Nothing to validate.
    95  	return nil
    96  }
    97  
    98  // GetStatus retrieves the status of the Bar. Implements the KRShaped interface.
    99  func (b *Bar) GetStatus() *duckv1.Status {
   100  	return &b.Status.Status
   101  }
   102  
   103  // GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
   104  func (*Bar) GetConditionSet() apis.ConditionSet {
   105  	return apis.NewLivingConditionSet()
   106  }