kube

package
v0.0.0-...-a5289b6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 23 Imported by: 0

README

kube

import "github.com/eclipse-symphony/symphony/packages/testutils/expectations/kube"

Index

Variables

var (
    PodReadyCondition types.Condition = conditions.All(
        NewKubernetesStatusCondition("Ready", true),
        NewKubernetesStatusCondition("Initialized", true),
        NewKubernetesStatusCondition("ContainersReady", true),
    )   // can be used for pods and certificates

    DeploymentCompleteCondition types.Condition = conditions.All(
        NewKubernetesStatusCondition("Available", true),
        NewKubernetesStatusCondition("Progressing", true),
    )   // can be used for deployments and statefulsets

    // AioManagerLabelCondition is a condition that checks if the resource is managed by the aio orc api
    AioManagerLabelCondition types.Condition = NewLabelMatchCondition("iotoperations.azure.com/managed-by", "symphony-api")

    // ProvisioningSucceededCondition is a condition that checks if the resource has succeeded provisioning
    ProvisioningSucceededCondition types.Condition = jq.Equality(".status.provisioningStatus.status", "Succeeded", statusDescription)

    // ProvisioningFailedCondition is a condition that checks if the resource has failed provisioning
    ProvisioningFailedCondition types.Condition = jq.Equality(".status.provisioningStatus.status", "Failed", statusDescription)
    // OperationIdMatchCondition is a condition that checks if the resource has the operation id  annotation and
    // ensures that it matches the operationId in the status of the resource
    OperationIdMatchCondition types.Condition = jq.MustNew(
        fmt.Sprintf(`.metadata.annotations["%s"]`, "management.azure.com/operationId"),
        jq.WithCustomMatcher(operationJqMatcher),
        jq.WithDescription("Operation Id"),
    )
)

func NewAnnotationMatchCondition

func NewAnnotationMatchCondition(annotation string, value string) types.Condition

NewAnnotationMatchCondition returns a condition that checks if the resource has the annotation and value

func NewKubernetesStatusCondition

func NewKubernetesStatusCondition(conditionType string, status bool) types.Condition

NewKubernetesStatusCondition returns a condition that checks the status of a kubernetes resource's condition

func NewLabelMatchCondition

func NewLabelMatchCondition(label string, value string) types.Condition

NewLabelMatchCondition returns a condition that checks if the resource has the label and value

func ProvisioningStatusComponentOutput

func ProvisioningStatusComponentOutput(componentKey string, value interface{}) types.Condition

type KubeExpectation

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

func AbsentInstance
func AbsentInstance(name, namespace string, opts ...Option) (*KubeExpectation, error)

AbsentInstance returns an expectation that the instance(s) is/are absent from the cluster

func AbsentPod
func AbsentPod(name, namespace string, opts ...Option) (*KubeExpectation, error)

AbsentPod returns an expectation that the pod(s) is/are absent from the cluster

func AbsentResource
func AbsentResource(name, namespace string, gvk schema.GroupVersionKind, opts ...Option) (*KubeExpectation, error)

AbsentResource returns an expectation for the resources is/are absent from the cluster

func AbsentSolution
func AbsentSolution(name, namespace string, opts ...Option) (*KubeExpectation, error)

AbsentSolution returns an expectation that the solution(s) is/are absent from the cluster

func AbsentTarget
func AbsentTarget(name, namespace string, opts ...Option) (*KubeExpectation, error)

AbsentTarget returns an expectation that the target(s) is/are absent from the cluster

func Instance
func Instance(name, namespace string, opts ...Option) (*KubeExpectation, error)

Instance returns an expectation for a instance(s) in the cluster

func Must
func Must(resource *KubeExpectation, err error) *KubeExpectation

Must returns a resource expectation or panics if there is an error

func Pod
func Pod(name, namespace string, opts ...Option) (*KubeExpectation, error)

Pod returns an expectation expectation for a pod(s) in the cluster

func Resource
func Resource(pattern, namespace string, gvk schema.GroupVersionKind, opts ...Option) (*KubeExpectation, error)

func Solution
func Solution(name, namespace string, opts ...Option) (*KubeExpectation, error)

Solution returns an expectation for a solution(s) in the cluster

func Target
func Target(name, namespace string, opts ...Option) (*KubeExpectation, error)

Target returns an expectation for a target(s) in the cluster

func (*KubeExpectation) AsGomegaSubject
func (e *KubeExpectation) AsGomegaSubject() func(context.Context) (interface{}, error)

func (*KubeExpectation) Description
func (re *KubeExpectation) Description() string

func (*KubeExpectation) Id
func (re *KubeExpectation) Id() string

func (*KubeExpectation) ToGomegaMatcher
func (e *KubeExpectation) ToGomegaMatcher() gomega.GomegaMatcher

func (*KubeExpectation) Verify
func (re *KubeExpectation) Verify(c context.Context) error

Verify implements types.Expectation.

type Option

type Option func(*KubeExpectation)

func IsAbsent
func IsAbsent() Option

func WithCondition
func WithCondition(condition types.Condition) Option

WithCondition specifies the conditions that the resource should satisfy.

func WithDescription
func WithDescription(description string) Option

func WithDiscoveryClientBuilder
func WithDiscoveryClientBuilder(builder func() (discovery.DiscoveryInterface, error)) Option

func WithDynamicClientBuilder
func WithDynamicClientBuilder(builder func() (dynamic.Interface, error)) Option

func WithListCondition
func WithListCondition(condition types.Condition) Option

WithListCondition specifies the conditions that the list of matched resources should satisfy.

func WithLogger
func WithLogger(logger func(format string, args ...interface{})) Option

WithLogger specifies the logger to be used.

func WithTick
func WithTick(tick time.Duration) Option

WithTick specifies the tick for the expectation.

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PodReadyCondition types.Condition = conditions.All(
		NewKubernetesStatusCondition("Ready", true),
		NewKubernetesStatusCondition("Initialized", true),
		NewKubernetesStatusCondition("ContainersReady", true),
	) // can be used for pods and certificates

	DeploymentCompleteCondition types.Condition = conditions.All(
		NewKubernetesStatusCondition("Available", true),
		NewKubernetesStatusCondition("Progressing", true),
	) // can be used for deployments and statefulsets

	// AioManagerLabelCondition is a condition that checks if the resource is managed by the aio orc api
	AioManagerLabelCondition types.Condition = NewLabelMatchCondition("iotoperations.azure.com/managed-by", "symphony-api")

	// ProvisioningSucceededCondition is a condition that checks if the resource has succeeded provisioning
	ProvisioningSucceededCondition types.Condition = jq.Equality(".status.provisioningStatus.status", "Succeeded", statusDescription)

	// ProvisioningFailedCondition is a condition that checks if the resource has failed provisioning
	ProvisioningFailedCondition types.Condition = jq.Equality(".status.provisioningStatus.status", "Failed", statusDescription)
	// OperationIdMatchCondition is a condition that checks if the resource has the operation id  annotation and
	// ensures that it matches the operationId in the status of the resource
	OperationIdMatchCondition types.Condition = jq.MustNew(
		fmt.Sprintf(`.metadata.annotations["%s"]`, "management.azure.com/operationId"),
		jq.WithCustomMatcher(operationJqMatcher),
		jq.WithDescription("Operation Id"),
	)
)

Functions

func NewAnnotationMatchCondition

func NewAnnotationMatchCondition(annotation string, value string) types.Condition

NewAnnotationMatchCondition returns a condition that checks if the resource has the annotation and value

func NewKubernetesStatusCondition

func NewKubernetesStatusCondition(conditionType string, status bool) types.Condition

NewKubernetesStatusCondition returns a condition that checks the status of a kubernetes resource's condition

func NewLabelMatchCondition

func NewLabelMatchCondition(label string, value string) types.Condition

NewLabelMatchCondition returns a condition that checks if the resource has the label and value

func ProvisioningStatusComponentOutput

func ProvisioningStatusComponentOutput(componentKey string, value interface{}) types.Condition

Types

type KubeExpectation

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

func AbsentInstance

func AbsentInstance(name, namespace string, opts ...Option) (*KubeExpectation, error)

AbsentInstance returns an expectation that the instance(s) is/are absent from the cluster

func AbsentPod

func AbsentPod(name, namespace string, opts ...Option) (*KubeExpectation, error)

AbsentPod returns an expectation that the pod(s) is/are absent from the cluster

func AbsentResource

func AbsentResource(name, namespace string, gvk schema.GroupVersionKind, opts ...Option) (*KubeExpectation, error)

AbsentResource returns an expectation for the resources is/are absent from the cluster

func AbsentSolution

func AbsentSolution(name, namespace string, opts ...Option) (*KubeExpectation, error)

AbsentSolution returns an expectation that the solution(s) is/are absent from the cluster

func AbsentTarget

func AbsentTarget(name, namespace string, opts ...Option) (*KubeExpectation, error)

AbsentTarget returns an expectation that the target(s) is/are absent from the cluster

func Instance

func Instance(name, namespace string, opts ...Option) (*KubeExpectation, error)

Instance returns an expectation for a instance(s) in the cluster

func Must

func Must(resource *KubeExpectation, err error) *KubeExpectation

Must returns a resource expectation or panics if there is an error

func Pod

func Pod(name, namespace string, opts ...Option) (*KubeExpectation, error)

Pod returns an expectation expectation for a pod(s) in the cluster

func Resource

func Resource(pattern, namespace string, gvk schema.GroupVersionKind, opts ...Option) (*KubeExpectation, error)

func Solution

func Solution(name, namespace string, opts ...Option) (*KubeExpectation, error)

Solution returns an expectation for a solution(s) in the cluster

func Target

func Target(name, namespace string, opts ...Option) (*KubeExpectation, error)

Target returns an expectation for a target(s) in the cluster

func (*KubeExpectation) AsGomegaSubject

func (e *KubeExpectation) AsGomegaSubject() func(context.Context) (interface{}, error)

func (*KubeExpectation) Description

func (re *KubeExpectation) Description() string

func (*KubeExpectation) Id

func (re *KubeExpectation) Id() string

func (*KubeExpectation) ToGomegaMatcher

func (e *KubeExpectation) ToGomegaMatcher() gomega.GomegaMatcher

func (*KubeExpectation) Verify

func (re *KubeExpectation) Verify(c context.Context) error

Verify implements types.Expectation.

type Option

type Option func(*KubeExpectation)

func IsAbsent

func IsAbsent() Option

func WithCondition

func WithCondition(condition types.Condition) Option

WithCondition specifies the conditions that the resource should satisfy.

func WithDescription

func WithDescription(description string) Option

func WithDiscoveryClientBuilder

func WithDiscoveryClientBuilder(builder func() (discovery.DiscoveryInterface, error)) Option

func WithDynamicClientBuilder

func WithDynamicClientBuilder(builder func() (dynamic.Interface, error)) Option

func WithListCondition

func WithListCondition(condition types.Condition) Option

WithListCondition specifies the conditions that the list of matched resources should satisfy.

func WithLogger

func WithLogger(logger func(format string, args ...interface{})) Option

WithLogger specifies the logger to be used.

func WithTick

func WithTick(tick time.Duration) Option

WithTick specifies the tick for the expectation.

Jump to

Keyboard shortcuts

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