knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/apis/interfaces.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 apis
    18  
    19  import (
    20  	"context"
    21  
    22  	"k8s.io/apimachinery/pkg/runtime"
    23  )
    24  
    25  // Defaultable defines an interface for setting the defaults for the
    26  // uninitialized fields of this instance.
    27  type Defaultable interface {
    28  	SetDefaults(context.Context)
    29  }
    30  
    31  // Validatable indicates that a particular type may have its fields validated.
    32  type Validatable interface {
    33  	// Validate checks the validity of this types fields.
    34  	Validate(context.Context) *FieldError
    35  }
    36  
    37  // Convertible indicates that a particular type supports conversions to/from
    38  // "higher" versions of the same type.
    39  type Convertible interface {
    40  	// ConvertTo converts the receiver into `to`.
    41  	ConvertTo(ctx context.Context, to Convertible) error
    42  
    43  	// ConvertFrom converts `from` into the receiver.
    44  	ConvertFrom(ctx context.Context, from Convertible) error
    45  }
    46  
    47  // Listable indicates that a particular type can be returned via the returned
    48  // list type by the API server.
    49  type Listable interface {
    50  	runtime.Object
    51  
    52  	GetListType() runtime.Object
    53  }
    54  
    55  // Annotatable indicates that a particular type applies various annotations.
    56  //
    57  // Deprecated: Use WithUserInfo / GetUserInfo from within SetDefaults instead.
    58  // The webhook functionality for this has been turned down, which is why this
    59  // interface is empty.
    60  type Annotatable interface{}
    61  
    62  // HasSpec indicates that a particular type has a specification information
    63  // and that information is retrievable.
    64  type HasSpec interface {
    65  	// GetUntypedSpec returns the spec of the resource.
    66  	GetUntypedSpec() interface{}
    67  }