...

Source file src/sigs.k8s.io/cli-utils/pkg/kstatus/polling/engine/status_reader.go

Documentation: sigs.k8s.io/cli-utils/pkg/kstatus/polling/engine

     1  // Copyright 2020 The Kubernetes Authors.
     2  // SPDX-License-Identifier: Apache-2.0
     3  
     4  package engine
     5  
     6  import (
     7  	"context"
     8  
     9  	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
    10  	"k8s.io/apimachinery/pkg/runtime/schema"
    11  	"sigs.k8s.io/cli-utils/pkg/kstatus/polling/event"
    12  	"sigs.k8s.io/cli-utils/pkg/object"
    13  )
    14  
    15  // StatusReader is the main interface for computing status for resources. In this context,
    16  // a status reader is an object that can fetch a resource of a specific
    17  // GroupKind from the cluster and compute its status. For resources that
    18  // can own generated resources, the engine might also have knowledge about
    19  // how to identify these generated resources and how to compute status for
    20  // these generated resources.
    21  type StatusReader interface {
    22  	// Supports tells the caller whether the StatusReader can compute status for
    23  	// the provided GroupKind.
    24  	Supports(schema.GroupKind) bool
    25  
    26  	// ReadStatus will fetch the resource identified by the given identifier
    27  	// from the cluster and return an ResourceStatus that will contain
    28  	// information about the latest state of the resource, its computed status
    29  	// and information about any generated resources. Errors would usually be
    30  	// added to the event.ResourceStatus, but in the case of fatal errors
    31  	// that aren't connected to the particular resource, an error can also
    32  	// be returned. Currently, only context cancellation and deadline exceeded
    33  	// will cause an error to be returned.
    34  	ReadStatus(ctx context.Context, reader ClusterReader, resource object.ObjMetadata) (*event.ResourceStatus, error)
    35  
    36  	// ReadStatusForObject is similar to ReadStatus, but instead of looking up the
    37  	// resource based on an identifier, it will use the passed-in resource.
    38  	// Errors would usually be added to the event.ResourceStatus, but in the case
    39  	// of fatal errors that aren't connected to the particular resource, an error
    40  	// can also be returned. Currently, only context cancellation and deadline exceeded
    41  	// will cause an error to be returned.
    42  	ReadStatusForObject(ctx context.Context, reader ClusterReader, object *unstructured.Unstructured) (*event.ResourceStatus, error)
    43  }
    44  

View as plain text