knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/apis/duck/interface.go (about)

     1  /*
     2  Copyright 2018 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 duck
    18  
    19  import (
    20  	"context"
    21  
    22  	"k8s.io/apimachinery/pkg/runtime/schema"
    23  	"k8s.io/client-go/tools/cache"
    24  	"knative.dev/pkg/kmeta"
    25  	"knative.dev/pkg/tracker"
    26  )
    27  
    28  // InformerFactory is used to create Informer/Lister pairs for a schema.GroupVersionResource
    29  type InformerFactory interface {
    30  	// Get returns a synced Informer/Lister pair for the provided schema.GroupVersionResource.
    31  	Get(context.Context, schema.GroupVersionResource) (cache.SharedIndexInformer, cache.GenericLister, error)
    32  }
    33  
    34  // OneOfOurs is the union of our Accessor interface and the OwnerRefable interface
    35  // that is implemented by our resources that implement the kmeta.Accessor.
    36  type OneOfOurs interface {
    37  	kmeta.Accessor
    38  	kmeta.OwnerRefable
    39  }
    40  
    41  // BindableStatus is the interface that the .status of Bindable resources must
    42  // implement to work smoothly with our BaseReconciler.
    43  type BindableStatus interface {
    44  	// InitializeConditions seeds the resource's status.conditions field
    45  	// with all of the conditions that this Binding surfaces.
    46  	InitializeConditions()
    47  
    48  	// MarkBindingAvailable notes that this Binding has been properly
    49  	// configured.
    50  	MarkBindingAvailable()
    51  
    52  	// MarkBindingUnavailable notes the provided reason for why the Binding
    53  	// has failed.
    54  	MarkBindingUnavailable(reason string, message string)
    55  
    56  	// SetObservedGeneration updates the .status.observedGeneration to the
    57  	// provided generation value.
    58  	SetObservedGeneration(int64)
    59  }
    60  
    61  // Bindable may be implemented by Binding resources to use shared libraries.
    62  type Bindable interface {
    63  	OneOfOurs
    64  
    65  	// GetSubject returns the standard Binding duck's "Subject" field.
    66  	GetSubject() tracker.Reference
    67  
    68  	// GetBindingStatus returns the status of the Binding, which must
    69  	// implement BindableStatus.
    70  	GetBindingStatus() BindableStatus
    71  }