github.com/tilt-dev/tilt@v0.36.0/internal/k8s/exploding_client.go (about)

     1  package k8s
     2  
     3  import (
     4  	"context"
     5  	"io"
     6  	"time"
     7  
     8  	"github.com/distribution/reference"
     9  	"github.com/pkg/errors"
    10  	v1 "k8s.io/api/core/v1"
    11  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    12  	"k8s.io/apimachinery/pkg/runtime/schema"
    13  	"k8s.io/apimachinery/pkg/types"
    14  	"k8s.io/apimachinery/pkg/version"
    15  	"k8s.io/client-go/tools/clientcmd/api"
    16  
    17  	"github.com/tilt-dev/tilt/internal/container"
    18  	"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
    19  	"github.com/tilt-dev/tilt/pkg/model"
    20  )
    21  
    22  var _ Client = &explodingClient{}
    23  
    24  type explodingClient struct {
    25  	err error
    26  }
    27  
    28  func NewExplodingClient(err error) Client {
    29  	return &explodingClient{
    30  		err: err,
    31  	}
    32  }
    33  
    34  func (ec *explodingClient) Upsert(ctx context.Context, entities []K8sEntity, timeout time.Duration) ([]K8sEntity, error) {
    35  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    36  }
    37  
    38  func (ec *explodingClient) Delete(ctx context.Context, entities []K8sEntity, wait time.Duration) error {
    39  	return errors.Wrap(ec.err, "could not set up kubernetes client")
    40  }
    41  
    42  func (ec *explodingClient) GetMetaByReference(ctx context.Context, ref v1.ObjectReference) (metav1.Object, error) {
    43  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    44  }
    45  
    46  func (ec *explodingClient) ListMeta(ctx context.Context, gvk schema.GroupVersionKind, ns Namespace) ([]metav1.Object, error) {
    47  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    48  }
    49  
    50  func (ec *explodingClient) PodsWithImage(ctx context.Context, image reference.NamedTagged, n Namespace, lp []model.LabelPair) ([]v1.Pod, error) {
    51  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    52  }
    53  
    54  func (ec *explodingClient) PollForPodsWithImage(ctx context.Context, image reference.NamedTagged, n Namespace, lp []model.LabelPair, timeout time.Duration) ([]v1.Pod, error) {
    55  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    56  }
    57  
    58  func (ec *explodingClient) ContainerLogs(ctx context.Context, podID PodID, cName container.Name, n Namespace, startTime time.Time) (io.ReadCloser, error) {
    59  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    60  }
    61  
    62  func (ec *explodingClient) CreatePortForwarder(ctx context.Context, namespace Namespace, podID PodID, optionalLocalPort, remotePort int, host string) (PortForwarder, error) {
    63  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    64  }
    65  
    66  func (ec *explodingClient) WatchPods(ctx context.Context, ns Namespace) (<-chan ObjectUpdate, error) {
    67  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    68  }
    69  
    70  func (ec *explodingClient) PodFromInformerCache(ctx context.Context, nn types.NamespacedName) (*v1.Pod, error) {
    71  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    72  }
    73  
    74  func (ec *explodingClient) WatchServices(ctx context.Context, ns Namespace) (<-chan *v1.Service, error) {
    75  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    76  }
    77  
    78  func (ec *explodingClient) WatchEvents(ctx context.Context, ns Namespace) (<-chan *v1.Event, error) {
    79  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    80  }
    81  
    82  func (ec *explodingClient) WatchMeta(ctx context.Context, gvk schema.GroupVersionKind, ns Namespace) (<-chan metav1.Object, error) {
    83  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
    84  }
    85  
    86  func (ec *explodingClient) ContainerRuntime(ctx context.Context) container.Runtime {
    87  	return container.RuntimeUnknown
    88  }
    89  
    90  func (ec *explodingClient) LocalRegistry(_ context.Context) *v1alpha1.RegistryHosting {
    91  	return nil
    92  }
    93  
    94  func (ec *explodingClient) NodeIP(ctx context.Context) NodeIP {
    95  	return ""
    96  }
    97  
    98  func (ec *explodingClient) Exec(ctx context.Context, podID PodID, cName container.Name, n Namespace, cmd []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error {
    99  	return errors.Wrap(ec.err, "could not set up kubernetes client")
   100  }
   101  
   102  func (ec *explodingClient) CheckConnected(ctx context.Context) (*version.Info, error) {
   103  	return nil, errors.Wrap(ec.err, "could not set up kubernetes client")
   104  }
   105  
   106  func (ec *explodingClient) OwnerFetcher() OwnerFetcher {
   107  	return NewOwnerFetcher(context.Background(), ec)
   108  }
   109  
   110  func (ec *explodingClient) ClusterHealth(_ context.Context, _ bool) (ClusterHealth, error) {
   111  	return ClusterHealth{}, errors.Wrap(ec.err, "could not set up kubernetes client")
   112  }
   113  
   114  func (ec *explodingClient) APIConfig() *api.Config {
   115  	return &api.Config{}
   116  }