sigs.k8s.io/cluster-api@v1.6.3/internal/controllers/topology/cluster/patches/api/interface.go (about)

     1  /*
     2  Copyright 2021 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 api contains the API definition for the patch engine.
    18  // NOTE: We are introducing this API as a decoupling layer between the patch engine and the concrete components
    19  // responsible for generating patches, because we aim to provide support for external patches in a future iteration.
    20  // We also assume that this API and all the related types will be moved in a separate (versioned) package thus
    21  // providing a versioned contract between Cluster API and the components implementing external patch extensions.
    22  package api
    23  
    24  import (
    25  	"context"
    26  
    27  	"sigs.k8s.io/controller-runtime/pkg/client"
    28  
    29  	runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
    30  )
    31  
    32  // Generator defines a component that can generate patches for ClusterClass templates.
    33  type Generator interface {
    34  	// Generate generates patches for templates.
    35  	// GeneratePatchesRequest contains templates and the corresponding variables.
    36  	// GeneratePatchesResponse contains the patches which should be applied to the templates of the GenerateRequest.
    37  	Generate(context.Context, client.Object, *runtimehooksv1.GeneratePatchesRequest) (*runtimehooksv1.GeneratePatchesResponse, error)
    38  }
    39  
    40  // Validator defines a component that can validate ClusterClass templates.
    41  type Validator interface {
    42  	// Validate validates templates..
    43  	// ValidateTopologyRequest contains templates and the corresponding variables.
    44  	// ValidateTopologyResponse contains the validation response.
    45  	Validate(context.Context, client.Object, *runtimehooksv1.ValidateTopologyRequest) (*runtimehooksv1.ValidateTopologyResponse, error)
    46  }