client

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 30 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TempDebugManifest          = "tmp-manifest.yaml"
	LogPollInterval            = 2 * time.Second
	ContainerStatePollInterval = 2 * time.Second
)

Variables

View Source
var (
	ProjectRoot = filepath.Join(filepath.Dir(b), "../")
	DistRoot    = filepath.Join(ProjectRoot, "dist")
	DiffsDir    = filepath.Join(ProjectRoot, "diffs")
)

Functions

func ExecCmd

func ExecCmd(command string) error

func GetLocalK8sDeps

func GetLocalK8sDeps() (*kubernetes.Clientset, *rest.Config, error)

GetLocalK8sDeps get local k8s context config

Types

type ConnectionInfo

type ConnectionInfo struct {
	Ports portforward.ForwardedPort
	Host  string
}

type ConnectionMode

type ConnectionMode int
const (
	LocalConnection ConnectionMode = iota
	RemoteConnection
)

type Forwarder

type Forwarder struct {
	Client *K8sClient

	KeepConnection bool
	Info           map[string]interface{}
	// contains filtered or unexported fields
}

func NewForwarder

func NewForwarder(client *K8sClient, keepConnection bool) *Forwarder

func (*Forwarder) Connect

func (m *Forwarder) Connect(namespaceName string, selector string) error

func (*Forwarder) FindPort

func (m *Forwarder) FindPort(ks ...string) *URLConverter

type K8sClient

type K8sClient struct {
	ClientSet  *kubernetes.Clientset
	RESTConfig *rest.Config
}

K8sClient high level k8s client

func NewK8sClient

func NewK8sClient() *K8sClient

NewK8sClient creates a new k8s client with a REST config

func (*K8sClient) Apply

func (m *K8sClient) Apply(manifest string) error

func (*K8sClient) CheckReady

func (m *K8sClient) CheckReady(c ManifestOutput) error

CheckReady application heath check using ManifestOutputData params

func (*K8sClient) CopyToPod

func (m *K8sClient) CopyToPod(namespace, src, destination, containername string) (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error)

CopyToPod copies src to a particular container. Destination should be in the form of a proper K8s destination path NAMESPACE/POD_NAME:folder/FILE_NAME

func (*K8sClient) Create

func (m *K8sClient) Create(manifest string) error

func (*K8sClient) DryRun

func (m *K8sClient) DryRun(manifest string) error

func (*K8sClient) ListNamespaces

func (m *K8sClient) ListNamespaces(selector string) (*v1.NamespaceList, error)

func (*K8sClient) ListPods

func (m *K8sClient) ListPods(namespace, selector string) (*v1.PodList, error)

ListPods lists pods for a namespace and selector

func (*K8sClient) NamespaceExists

func (m *K8sClient) NamespaceExists(namespace string) bool

NamespaceExists check if namespace exists

func (*K8sClient) RemoveNamespace

func (m *K8sClient) RemoveNamespace(namespace string) error

RemoveNamespace removes namespace

func (*K8sClient) WaitContainersReady added in v0.2.1

func (m *K8sClient) WaitContainersReady(c ManifestOutput) error

WaitContainersReady waits until all containers ReadinessChecks are passed

func (*K8sClient) WaitForPodBySelectorRunning

func (m *K8sClient) WaitForPodBySelectorRunning(c ManifestOutput) error

WaitForPodBySelectorRunning Wait up to timeout seconds for all pods in 'namespace' with given 'selector' to enter running state. Returns an error if no pods are found or not all discovered pods enter running state.

func (*K8sClient) WaitLogMessages

func (m *K8sClient) WaitLogMessages(c ManifestOutput) error

WaitLogMessages waits for log messages substrings

type ManifestOutput

type ManifestOutput interface {
	SetNamespace(ns string)
	GetNamespace() string
	GetReadyCheckData() ReadyCheckData
	ProcessConnections(fwd *Forwarder) (map[string][]string, error)
}

ManifestOutput and interface to interact with a deployed environment

type Protocol

type Protocol int

Protocol represents a URL scheme to use when fetching connection details

const (
	// WS : Web Socket Protocol
	WS Protocol = iota
	// WSS : Web Socket Secure Protocol
	WSS
	// HTTP : Hypertext Transfer Protocol
	HTTP
	// HTTPS : Hypertext Transfer Protocol Secure
	HTTPS
)

type ReadyCheckData

type ReadyCheckData struct {
	ReadinessProbeCheckSelector string
	Selector                    string
	Container                   string
	LogSubStr                   string
	Timeout                     time.Duration
}

type URLConverter

type URLConverter struct {
	// contains filtered or unexported fields
}

URLConverter converts ports to URLs

func NewURLConverter

func NewURLConverter(fp ConnectionInfo, err error) *URLConverter

NewURLConverter creates new URLConverter instance

func (*URLConverter) As

func (m *URLConverter) As(conn ConnectionMode, proto Protocol) (string, error)

As converts host/port to an URL

Jump to

Keyboard shortcuts

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