Documentation ¶
Index ¶
- type ApplyOpts
- type Checker
- type Cluster
- func (c *Cluster) APIConfig() *api.Config
- func (c *Cluster) Apply(yml string) error
- func (c *Cluster) ApplyFile(path string) error
- func (c *Cluster) ApplyWithOpts(yml string, opts ApplyOpts) error
- func (c *Cluster) Delete(yml string) error
- func (c *Cluster) DeleteFile(path string) error
- func (c *Cluster) DeleteWithOpts(yml string, opts DeleteOpts) error
- func (c *Cluster) ExecWithOpts(pod string, container string, command []string, opts ExecOpts) ExecResult
- func (c *Cluster) Execf(pod, container, command string, args ...any) ExecResult
- func (c *Cluster) Get(apiVersion, kind, name string) (*unstructured.Unstructured, error)
- func (c *Cluster) GetWithOpts(apiVersion, kind, name string, opts GetOpts) (*unstructured.Unstructured, error)
- func (c *Cluster) List(apiVersion, kind, labelSelector string) (*unstructured.UnstructuredList, error)
- func (c *Cluster) ListWithOpts(apiVersion, kind, labelSelector string, opts ListOpts) (*unstructured.UnstructuredList, error)
- func (c *Cluster) RESTConfig() *rest.Config
- func (c *Cluster) TestNamespace() string
- func (c *Cluster) WaitFor(check Checker) error
- func (c *Cluster) WaitForWithOpts(check Checker, opts WaitForOpts) error
- type DeleteOpts
- type ExecOpts
- type ExecResult
- type GetOpts
- type ListOpts
- type WaitForOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplyOpts ¶
type ApplyOpts struct { // here you can pass your context. It it's not set, the default // context.Background() will be used Context context.Context // namespace where to apply resource. If it's not set, the cluster's // test namespace will be used. This is ignored for cluster-wide resources Namespace string }
options for GetWithOpts function
type Checker ¶
enables the WaitFor() function to receive and execute custom checking functions, allowing the caller to define their own conditions for waiting on a specific resource or state to be reached.
func PodIsRunning ¶
check if given pod is running, that means it's in `Running` phase. The function expect also namespace. If you provide empty string, then cluster's default test namespace will be used.
func ResourceExist ¶
check if resource of given kind and name exists in the given cluster, in the cluster's test namespace
func ResourceNotExist ¶
check if resource of given kind and name doesn't exists in the given cluster, in the cluster's test namespace
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
representing running cluster for your tests
func NewFromEnvironment ¶
create cluster instance from KUBECONFIG
func NewFromFile ¶
create cluster instance from given kubeconfig file
func (*Cluster) Apply ¶
Same as kubectl apply. Function apply any YAML into given cluster, into default test namespace.
func (*Cluster) ApplyWithOpts ¶
More verbose version of Apply() function where you can pass your own context or set namespace
func (*Cluster) Delete ¶
Delete resource of given YAML. The resource must be located in cluster's default test namespace or it must be cluster-wide resource. If you want to delete resource in another namespace, you should use more verbose DeleteWithOpts.
func (*Cluster) DeleteFile ¶
Delete resource in given file
func (*Cluster) DeleteWithOpts ¶
func (c *Cluster) DeleteWithOpts(yml string, opts DeleteOpts) error
More verbose version of Delete() function that allow you pass the context or change the namespace etc.
func (*Cluster) ExecWithOpts ¶
func (c *Cluster) ExecWithOpts(pod string, container string, command []string, opts ExecOpts) ExecResult
function executes command as array (without shell) in given pod and container. It's very general function.
func (*Cluster) Execf ¶
func (c *Cluster) Execf(pod, container, command string, args ...any) ExecResult
Less verbose version of ExecWithOpts, which will format and executes given command with args with '/bin/sh' shell in given pod.
func (*Cluster) Get ¶
func (c *Cluster) Get(apiVersion, kind, name string) (*unstructured.Unstructured, error)
Get unstructured data of given resource in test namespace. Resource is identified by it's name apiVersion e.g. ('networking.k8s.io/v1') and kind (e.g. 'NetworkPolicy')
func (*Cluster) GetWithOpts ¶
func (c *Cluster) GetWithOpts(apiVersion, kind, name string, opts GetOpts) (*unstructured.Unstructured, error)
More verbose version of Get() function. Use this function if you want to pass own context, or specify the namespace
func (*Cluster) List ¶
func (c *Cluster) List(apiVersion, kind, labelSelector string) (*unstructured.UnstructuredList, error)
More verbose version of List() function. Use this function if you want to pass own context, or specify the namespace
func (*Cluster) ListWithOpts ¶
func (c *Cluster) ListWithOpts(apiVersion, kind, labelSelector string, opts ListOpts) (*unstructured.UnstructuredList, error)
More verbose version of List() function. Use this function if you want to pass own context, or specify the namespace
func (*Cluster) RESTConfig ¶
returns low-level client rest config
func (*Cluster) TestNamespace ¶
func (*Cluster) WaitFor ¶
simple, sort version of WaitForOpts with default values. The timeout is 2 minutes and interval is set to 2 seconds. Is't equivalent to:
WaitForOpts(check, WaitForOpts{})
func (*Cluster) WaitForWithOpts ¶
func (c *Cluster) WaitForWithOpts(check Checker, opts WaitForOpts) error
the function will check if system met given condition. The checking is triggered every n seconds defined by interval in opts. The invocation of checking function continue until:
- function ends with true
- reach timeout limit defined in opts
The function returns nil if the given checking function met the condition. If we reach the timeout or some error occured during checking, the function returns error.
type DeleteOpts ¶
type DeleteOpts struct { // here you can pass your context. It it's not set, the default // context.Background() will be used Context context.Context // namespace where delete resource. If it's not set, the cluster's // test namespace will be used. This is ignored for cluster-wide resources Namespace string }
options for DeleteWithOpts function
type ExecResult ¶
func (ExecResult) String ¶
func (e ExecResult) String() string
type GetOpts ¶
type GetOpts struct { // here you can pass your context. It it's not set, the default // context.Background() will be used Context context.Context // namespace where is the resource. If it's not set, the cluster's // testNamespace will be used Namespace string }
Optional options for GetWithOpts function
type ListOpts ¶
type ListOpts struct { // here you can pass your context. It it's not set, the default // context.Background() will be used Context context.Context // namespace where is the resource. If it's not set, the cluster's // testNamespace will be used Namespace string }
Optional options for ListWithOpts function
type WaitForOpts ¶
type WaitForOpts struct { // here you can pass your context. It it's not set, the default // context.Background() will be used Context context.Context // maximum duration for which the function will wait for the condition // to be met. If it's not set, the default 2 minutes will be used Timeout time.Duration // represents the duration between invocations of the checker function // If it's not set, the defauls 2 seconds will be used Interval time.Duration }
Optional options for WaitForWithOpts function