Documentation
¶
Overview ¶
Package helpers offers functions to simplify dealing with kubernetes resources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeHTTPClient ¶ added in v0.1.2
FakeHTTPClient implement a fake HTTPClient that returns a fixed response. When invoked, it records the request it received
type FakePodCommandExecutor ¶
type FakePodCommandExecutor struct {
// contains filtered or unexported fields
}
FakePodCommandExecutor mocks the execution of a command in a pod recording the command history and returning a predefined stdout, stderr, and error
func NewFakePodCommandExecutor ¶
func NewFakePodCommandExecutor() *FakePodCommandExecutor
NewFakePodCommandExecutor creates a new instance of FakePodCommandExecutor with default attributes
func (*FakePodCommandExecutor) Exec ¶
func (f *FakePodCommandExecutor) Exec( pod string, container string, cmd []string, stdin []byte, ) ([]byte, []byte, error)
Exec records the execution of a command and returns the pre-defined
func (*FakePodCommandExecutor) GetHistory ¶
func (f *FakePodCommandExecutor) GetHistory() []Command
GetHistory returns the history of commands executed by the FakePodCommandExecutor
type Helpers ¶
type Helpers interface { NamespaceHelper ServiceHelper PodHelper }
Helpers offers Helper functions grouped by the objects they handle
func NewFakeHelper ¶
func NewFakeHelper(client kubernetes.Interface, namespace string, executor *FakePodCommandExecutor) Helpers
NewFakeHelper creates a set of helpers on the default namespace
type NamespaceHelper ¶
type NamespaceHelper interface { // CreateRandomNamespace creates a namespace with a random name starting with // the provided prefix and returns its name CreateRandomNamespace(ctx context.Context, prefix string) (string, error) }
NamespaceHelper defines helper methods for handling namespaces
type PodHelper ¶
type PodHelper interface { // WaitPodRunning waits for the Pod to be running for up to given timeout and returns a boolean indicating // if the status was reached. If the pod is Failed returns error. WaitPodRunning(ctx context.Context, name string, timeout time.Duration) (bool, error) // Exec executes a non-interactive command described in options and returns the stdout and stderr outputs Exec(pod string, container string, command []string, stdin []byte) ([]byte, []byte, error) // AttachEphemeralContainer adds an ephemeral container to a running pod, waiting for up to // a given timeout until the container is running AttachEphemeralContainer( ctx context.Context, podName string, container corev1.EphemeralContainer, timeout time.Duration, ) error }
PodHelper defines helper methods for handling Pods
type ServiceClient ¶ added in v0.1.2
type ServiceClient interface { // Do executes the request to the service and returns the response // From the request only the URL path method, headers and body are considered Do(request *http.Request) (*http.Response, error) }
ServiceClient is the minimal interface for executing HTTP requests Offers an interface similar to http.Client but only the Do method is supported It is used primarily to allow mocking the client in unit tests
type ServiceHelper ¶
type ServiceHelper interface { // WaitServiceReady waits for the given service to have at least one endpoint available WaitServiceReady(ctx context.Context, service string, timeout time.Duration) error // GetServiceProxy returns a client for making HTTP requests to the service using api server's proxy GetServiceProxy(service string, port int) (ServiceClient, error) }
ServiceHelper implements functions for dealing with services
type ServiceProxy ¶ added in v0.1.2
type ServiceProxy struct {
// contains filtered or unexported fields
}
ServiceProxy implements the HTTPClient interface for making HTTP request to a service