github.com/zsuzhengdu/helm@v3.0.0-beta.3+incompatible/pkg/kube/interface.go (about)

     1  /*
     2  Copyright The Helm 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 kube
    18  
    19  import (
    20  	"io"
    21  	"time"
    22  
    23  	v1 "k8s.io/api/core/v1"
    24  )
    25  
    26  // Interface represents a client capable of communicating with the Kubernetes API.
    27  //
    28  // A KubernetesClient must be concurrency safe.
    29  type Interface interface {
    30  	// Create creates one or more resources.
    31  	Create(resources ResourceList) (*Result, error)
    32  
    33  	Wait(resources ResourceList, timeout time.Duration) error
    34  
    35  	// Delete destroys one or more resources.
    36  	Delete(resources ResourceList) (*Result, []error)
    37  
    38  	// Watch the resource in reader until it is "ready". This method
    39  	//
    40  	// For Jobs, "ready" means the Job ran to completion (exited without error).
    41  	// For Pods, "ready" means the Pod phase is marked "succeeded".
    42  	// For all other kinds, it means the kind was created or modified without
    43  	// error.
    44  	WatchUntilReady(resources ResourceList, timeout time.Duration) error
    45  
    46  	// Update updates one or more resources or creates the resource
    47  	// if it doesn't exist.
    48  	Update(original, target ResourceList, force bool) (*Result, error)
    49  
    50  	// Build creates a resource list from a Reader
    51  	//
    52  	// reader must contain a YAML stream (one or more YAML documents separated
    53  	// by "\n---\n")
    54  	Build(reader io.Reader) (ResourceList, error)
    55  
    56  	// WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase
    57  	// and returns said phase (PodSucceeded or PodFailed qualify).
    58  	WaitAndGetCompletedPodPhase(name string, timeout time.Duration) (v1.PodPhase, error)
    59  
    60  	// isReachable checks whether the client is able to connect to the cluster
    61  	IsReachable() error
    62  }
    63  
    64  var _ Interface = (*Client)(nil)