controller

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package controller contains the controllers for the Harbor provider.

Index

Constants

View Source
const (
	// ExternalNameAnnotation is the annotation key used to store the external identifier
	ExternalNameAnnotation = "crossplane.io/external-name"
)

Variables

This section is empty.

Functions

func AssertError added in v0.14.0

func AssertError(t *testing.T, err error, expectedMsg string)

AssertError checks if an error matches the expected message

func GetExternalName added in v0.17.0

func GetExternalName(mg resource.Managed) string

GetExternalName retrieves the external name from resource annotations

func HasExternalName added in v0.17.0

func HasExternalName(mg resource.Managed) bool

HasExternalName checks if a resource has an external name set

func NewTestManagedResource added in v0.14.0

func NewTestManagedResource(name string) interface{}

NewTestManagedResource creates a simple test object Note: This is a stub for testing error handling paths

func PointerTo added in v0.14.0

func PointerTo[T any](v T) *T

PointerTo returns a pointer to the given value

func SetExternalName added in v0.17.0

func SetExternalName(mg resource.Managed, name string)

SetExternalName sets the external name in resource annotations

func Setup

func Setup(mgr ctrl.Manager) error

Setup sets up all controllers for the Harbor provider.

func ShouldDeleteExternal added in v0.17.0

func ShouldDeleteExternal(mg resource.Managed) bool

ShouldDeleteExternal checks if we should delete the external resource Returns false if deletion policy is Orphan, true otherwise

func TestLogger added in v0.14.0

func TestLogger(t *testing.T) logging.Logger

TestLogger returns a test logger for use in tests

Types

type MockHarborClient added in v0.14.0

type MockHarborClient struct {
	GetProjectFn    func(ctx context.Context, projectName string) (*clients.ProjectStatus, error)
	CreateProjectFn func(ctx context.Context, spec *clients.ProjectSpec) (*clients.ProjectStatus, error)
	UpdateProjectFn func(ctx context.Context, projectName string, spec *clients.ProjectSpec) (*clients.ProjectStatus, error)
	DeleteProjectFn func(ctx context.Context, projectName string) error
	ListProjectsFn  func(ctx context.Context) ([]*clients.ProjectStatus, error)
	CloseFn         func() error
}

MockHarborClient is a mock implementation of HarborClient for testing

func (*MockHarborClient) Close added in v0.14.0

func (m *MockHarborClient) Close() error

func (*MockHarborClient) CreateProject added in v0.14.0

func (m *MockHarborClient) CreateProject(ctx context.Context, spec *clients.ProjectSpec) (*clients.ProjectStatus, error)

func (*MockHarborClient) DeleteProject added in v0.14.0

func (m *MockHarborClient) DeleteProject(ctx context.Context, projectName string) error

func (*MockHarborClient) GetProject added in v0.14.0

func (m *MockHarborClient) GetProject(ctx context.Context, projectName string) (*clients.ProjectStatus, error)

func (*MockHarborClient) ListProjects added in v0.14.0

func (m *MockHarborClient) ListProjects(ctx context.Context) ([]*clients.ProjectStatus, error)

func (*MockHarborClient) UpdateProject added in v0.14.0

func (m *MockHarborClient) UpdateProject(ctx context.Context, projectName string, spec *clients.ProjectSpec) (*clients.ProjectStatus, error)

type MockKubeClient added in v0.14.0

type MockKubeClient struct {
	GetFn    func(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error
	CreateFn func(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
	UpdateFn func(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
	DeleteFn func(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
}

MockKubeClient is a mock Kubernetes client for testing

func (*MockKubeClient) Create added in v0.14.0

func (m *MockKubeClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error

func (*MockKubeClient) Delete added in v0.14.0

func (m *MockKubeClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error

func (*MockKubeClient) Get added in v0.14.0

func (*MockKubeClient) Update added in v0.14.0

func (m *MockKubeClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

Jump to

Keyboard shortcuts

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