fixture

package
v0.0.0-...-d16afb3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package fixture provides a client interface similar to the one provided by the controller-runtime package, in order to avoid creating a dependency on the controller-runtime package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanUp

func CleanUp(ctx context.Context, principalClient KubeClient, managedAgentClient KubeClient, autonomousAgentClient KubeClient) error

func GetSystemKubeConfig

func GetSystemKubeConfig(kcontext string) (*rest.Config, error)

GetSystemKubeConfig retrieves the given kube context from system-level Kubernetes config (e.g. ~/.kube/config). Use the empty string to retrieve the default context.

func SyncApplication

func SyncApplication(ctx context.Context, appKey types.NamespacedName, kclient KubeClient) error

SyncApplication syncs the named application using the "hook" strategy

func SyncApplicationWithOperation

func SyncApplicationWithOperation(ctx context.Context, appKey types.NamespacedName, operation argoapp.Operation, kclient KubeClient) error

SyncApplicationWithOperation syncs the named application using the provided operation

func ToNamespacedName

func ToNamespacedName(object KubeObject) types.NamespacedName

Types

type BaseSuite

type BaseSuite struct {
	suite.Suite
	Ctx                   context.Context
	PrincipalClient       KubeClient
	ManagedAgentClient    KubeClient
	AutonomousAgentClient KubeClient
}

func (*BaseSuite) SetupSuite

func (suite *BaseSuite) SetupSuite()

func (*BaseSuite) SetupTest

func (suite *BaseSuite) SetupTest()

func (*BaseSuite) TearDownTest

func (suite *BaseSuite) TearDownTest()

type KubeClient

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

func NewKubeClient

func NewKubeClient(config *rest.Config) (KubeClient, error)

func (KubeClient) Create

func (c KubeClient) Create(ctx context.Context, object KubeObject, options metav1.CreateOptions) error

Create creates the given object in the cluster. object must be a struct pointer so that it can be updated with the result returned by the server.

func (KubeClient) Delete

func (c KubeClient) Delete(ctx context.Context, object KubeObject, options metav1.DeleteOptions) error

Delete deletes the given object from the server.

func (KubeClient) EnsureApplicationUpdate

func (c KubeClient) EnsureApplicationUpdate(ctx context.Context, key types.NamespacedName, modify func(*argoapp.Application) error, options metav1.UpdateOptions) error

EnsureApplicationUpdate ensures the argocd application with the given key is updated by retrying if there is a conflicting change.

func (KubeClient) Get

func (c KubeClient) Get(ctx context.Context, key types.NamespacedName, object KubeObject, options metav1.GetOptions) error

Get returns the object with the specified key from the cluster. object must be a struct pointer so it can be updated with the result returned by the server.

func (KubeClient) List

func (c KubeClient) List(ctx context.Context, namespace string, list KubeObjectList, options metav1.ListOptions) error

List returns a list of objects matching the criteria specified by the given list options from the given namespace. list must be a struct pointer so that the Items field in the list can be populated with the results returned by the server.

func (KubeClient) Patch

func (c KubeClient) Patch(ctx context.Context, object KubeObject, jsonPatch []interface{}, options metav1.PatchOptions) error

Patch patches the given object in the cluster using the JSONPatch patch type. object must be a struct pointer so that it can be updated with the result returned by the server.

func (KubeClient) Update

func (c KubeClient) Update(ctx context.Context, object KubeObject, options metav1.UpdateOptions) error

Update updates the given object in the cluster. object must be a struct pointer so that it can be updated with the result returned by the server.

type KubeObject

type KubeObject interface {
	metav1.Object
	runtime.Object
}

KubeObject represents a Kubernetes object. This allows the client interface to work seamlessly with any resource that implements both the metav1.Object and runtime.Object interfaces. This is similar to the controller-runtime's client.Object interface.

type KubeObjectList

type KubeObjectList interface {
	metav1.ListInterface
	runtime.Object
}

KubeObjectList represents a Kubernetes object list. This allows the client interface to work seamlessly with any resource that implements both the metav1.ListInterface and runtime.Object interfaces. This is similar to the controller-runtime's client.ObjectList interface.

Jump to

Keyboard shortcuts

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