kubeclient

package
v1.75.0-pre Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package kubeclient provides a client to interact with Kubernetes. This package is Tailscale-internal and not meant for external consumption. Further, the API should not be considered stable. Client is split into a separate package for consumption of non-Kubernetes shared libraries and binaries. Be mindful of not increasing dependency size for those consumers when adding anything new here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFoundErr

func IsNotFoundErr(err error) bool

func SetRootPathForTesting

func SetRootPathForTesting(p string)

SetRootPathForTesting sets the path to the service account directory.

Types

type Client

type Client interface {
	GetSecret(context.Context, string) (*kubeapi.Secret, error)
	UpdateSecret(context.Context, *kubeapi.Secret) error
	CreateSecret(context.Context, *kubeapi.Secret) error
	StrategicMergePatchSecret(context.Context, string, *kubeapi.Secret, string) error
	JSONPatchSecret(context.Context, string, []JSONPatch) error
	CheckSecretPermissions(context.Context, string) (bool, bool, error)
	SetDialer(dialer func(context.Context, string, string) (net.Conn, error))
	SetURL(string)
}

Client handles connections to Kubernetes. It expects to be run inside a cluster.

func New

func New() (Client, error)

New returns a new client

type FakeClient

type FakeClient struct {
	GetSecretImpl              func(context.Context, string) (*kubeapi.Secret, error)
	CheckSecretPermissionsImpl func(ctx context.Context, name string) (bool, bool, error)
}

func (*FakeClient) CheckSecretPermissions

func (fc *FakeClient) CheckSecretPermissions(ctx context.Context, name string) (bool, bool, error)

func (*FakeClient) CreateSecret

func (fc *FakeClient) CreateSecret(context.Context, *kubeapi.Secret) error

func (*FakeClient) GetSecret

func (fc *FakeClient) GetSecret(ctx context.Context, name string) (*kubeapi.Secret, error)

func (*FakeClient) JSONPatchSecret

func (fc *FakeClient) JSONPatchSecret(context.Context, string, []JSONPatch) error

func (*FakeClient) SetDialer

func (fc *FakeClient) SetDialer(dialer func(ctx context.Context, network, addr string) (net.Conn, error))

func (*FakeClient) SetURL

func (fc *FakeClient) SetURL(_ string)

func (*FakeClient) StrategicMergePatchSecret

func (fc *FakeClient) StrategicMergePatchSecret(context.Context, string, *kubeapi.Secret, string) error

func (*FakeClient) UpdateSecret

func (fc *FakeClient) UpdateSecret(context.Context, *kubeapi.Secret) error

type JSONPatch

type JSONPatch struct {
	Op    string `json:"op"`
	Path  string `json:"path"`
	Value any    `json:"value,omitempty"`
}

JSONPatch is a JSON patch operation. It currently (2023-03-02) only supports "add" and "remove" operations.

https://tools.ietf.org/html/rfc6902

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL