clusterresource

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

Package clusterresource is a generated GoMock package.

Package clusterresource is a generated GoMock package.

Package clusterresource is a generated GoMock package.

Index

Constants

View Source
const (
	DefaultLogStreamBufferSize     = 1000
	DefaultStreamTimeoutDuration   = 20 * time.Minute
	DefaultLogStreamRateLimit      = 200 * time.Millisecond
	DefaultLogStreamRateLimitBurst = 100
	MaxLogStreamErrors             = 50
)
View Source
const (
	MetricsServerPollingInterval = 15 * time.Second

	StackResourceTargetType = "stack_resource"
	StackTargetType         = "stack"
)

Variables

View Source
var ErrBuildPodNotFound = stderrors.New("no build pod found")

ErrBuildPodNotFound is returned by GetLogsForBuildPod when no pod matches the build Job — the build has not started yet or its pod has been pruned.

View Source
var ErrBuildPodNotReady = stderrors.New("build pod not ready")

ErrBuildPodNotReady is returned by GetLogsForBuildPod when the build pod exists but has not started yet — logs are not available until it runs.

View Source
var ErrNoWorkload = stderrors.New("no workload found")

ErrNoWorkload is returned when none of the requested resources has a pod to read logs from — never scheduled, or already gone. Callers map it to a 404.

Functions

func WrapErrAsServiceError

func WrapErrAsServiceError(err error) *errors.ServiceError

Types

type BackgroundJobEnqueuerDep

type BackgroundJobEnqueuerDep struct {
	BackgroundJobEnqueuer workermanager.BackgroundJobEnqueuer
}

func (*BackgroundJobEnqueuerDep) InjectBackgroundJobEnqueuer

func (s *BackgroundJobEnqueuerDep) InjectBackgroundJobEnqueuer(dep BackgroundJobEnqueuerDep)

type BackgroundJobEnqueuerInjectable

type BackgroundJobEnqueuerInjectable interface {
	InjectBackgroundJobEnqueuer(dep BackgroundJobEnqueuerDep)
}

type ClusterImageRegistryService

type ClusterImageRegistryService interface {
	EnsureImageRegistryInCluster(ctx context.Context, registry *models.ClusterImageRegistry) *ClusterResourceError
	DeleteImageRegistryInCluster(ctx context.Context, registry *models.ClusterImageRegistry) (bool, *ClusterResourceError)
}

type ClusterImageRegistryServiceSpec

type ClusterImageRegistryServiceSpec struct {
	ClusterManager clustermanager.ClusterManager
	Logger         logger.Logger
}

type ClusterLoggingService

type ClusterLoggingService interface {
	// GetLogsForResources retrieves logs for the specified resources in the cluster.
	GetLogsForResources(ctx context.Context, orgID string, resources []*models.StackResource, options LoggingParams) (interfaces.ServerSideStreamable, error)
	// GetLogsForBuildPod streams logs from the build pod of the named ImageBuild.
	GetLogsForBuildPod(ctx context.Context, orgID string, namespace string, buildName string, options LoggingParams) (interfaces.ServerSideStreamable, error)
}

func NewLoggingService

func NewLoggingService(spec LoggingServiceSpec) ClusterLoggingService

type ClusterMetricsService

type ClusterMetricsService interface {
	GetMetricsForResource(ctx context.Context, orgID string, stackResource *models.StackResource) (*models.ResourceMetrics, error)
	GetMetricsForStack(ctx context.Context, orgID string, stack *models.Stack) (*models.ResourceMetrics, error)
	StreamMetricsForResource(ctx context.Context, orgID string, stackResource *models.StackResource) (interfaces.ServerSideStreamable, error)
	StreamMetricsForStack(ctx context.Context, orgID string, stack *models.Stack) (interfaces.ServerSideStreamable, error)
}

type ClusterMetricsServiceSpec

type ClusterMetricsServiceSpec struct {
	ClusterService DBClusterService
	ClusterManager clustermanager.ClusterManager
	Logger         logger.Logger
}

type ClusterResourceError

type ClusterResourceError struct {
	Message string
	Err     error
}

func (*ClusterResourceError) Error

func (e *ClusterResourceError) Error() string

type ClusterResourceServiceDeps

type ClusterResourceServiceDeps struct {
	ClusterNamespaceService NamespaceClusterResourceService
	ClusterVolumeService    VolumeClusterResourceService
	ClusterLoggingService   ClusterLoggingService
	ClusterMetricsService   ClusterMetricsService
}

ClusterResourceServiceDeps is embedded in services that require cluster resource service dependencies.

func (*ClusterResourceServiceDeps) InjectClusterResourceServiceDeps

func (s *ClusterResourceServiceDeps) InjectClusterResourceServiceDeps(deps ClusterResourceServiceDeps)

type ClusterResourceServiceInjectable

type ClusterResourceServiceInjectable interface {
	InjectClusterResourceServiceDeps(deps ClusterResourceServiceDeps)
}

ClusterResourceServiceInjectable is implemented (by embedding ClusterResourceServiceDeps) by services that need cluster resource service dependencies injected. It lives in this leaf package — not pkg/services — so that mocks of services interfaces embedding it (pkg/mocks) never import pkg/services, which would close an import cycle through the in-package tests of pkg/services and its dependents.

type DBClusterService

type DBClusterService interface {
	GetClusterForOrg(ctx context.Context, orgID string) (*models.Cluster, *errors.ServiceError)
}

type DBOrganisationService

type DBOrganisationService interface {
	Get(ctx context.Context, ID string) (*models.Organisation, *errors.ServiceError)
}

type DBSecretService

type DBSecretService interface {
	InternalGetByID(ctx context.Context, secretID string) (*models.Secret, *errors.ServiceError)
}

type DBStackResourceService

type DBStackResourceService interface {
	GetByStackResourceID(ctx context.Context, stackResourceID string) (*models.StackResource, *errors.ServiceError)
	GetByStackID(ctx context.Context, stackID string) ([]*models.StackResource, *errors.ServiceError)
}

type KubernetesClientFactory

type KubernetesClientFactory func(clients.KubernetesClientSpec) (clients.KubernetesClient, error)

KubernetesClientFactory constructs a Kubernetes client from a spec. Tests inject a factory returning a mock; production uses clients.NewKubernetesClient.

type LogStreamConfig

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

func (*LogStreamConfig) Follow

func (s *LogStreamConfig) Follow() bool

func (*LogStreamConfig) MaxErrors

func (s *LogStreamConfig) MaxErrors() int

func (*LogStreamConfig) Previous

func (s *LogStreamConfig) Previous() bool

func (*LogStreamConfig) Since

func (s *LogStreamConfig) Since() string

func (*LogStreamConfig) TailLines

func (s *LogStreamConfig) TailLines() int

type LogStreamer

type LogStreamer struct {
	Logger logger.Logger
	// contains filtered or unexported fields
}

func (*LogStreamer) Stream

func (s *LogStreamer) Stream(ctx context.Context) (<-chan interfaces.StreamObject, error)

type LoggingParams

type LoggingParams interface {
	// Follow indicates whether to follow the log stream.
	Follow() bool
	// TailLines specifies the number of lines to tail from the end of the log.
	TailLines() int
	// Since specifies the time from which to start streaming logs.
	Since() string
}

type LoggingServiceSpec

type LoggingServiceSpec struct {
	ClusterService DBClusterService
	ClusterManager clustermanager.ClusterManager
	Logger         logger.Logger
	// NewK8sClient overrides the Kubernetes client constructor; nil uses the real client.
	NewK8sClient KubernetesClientFactory
}

type MockClusterManager

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

MockClusterManager is a mock of ClusterManager interface.

func NewMockClusterManager

func NewMockClusterManager(ctrl *gomock.Controller) *MockClusterManager

NewMockClusterManager creates a new mock instance.

func (*MockClusterManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClusterManager) GetClient

func (m *MockClusterManager) GetClient(clusterID string) (client.Client, error)

GetClient mocks base method.

func (*MockClusterManager) GetRestConfig

func (m *MockClusterManager) GetRestConfig(clusterID string) (*rest.Config, error)

GetRestConfig mocks base method.

func (*MockClusterManager) IsClusterRegistered

func (m *MockClusterManager) IsClusterRegistered(clusterID string) bool

IsClusterRegistered mocks base method.

func (*MockClusterManager) IsRunning

func (m *MockClusterManager) IsRunning() bool

IsRunning mocks base method.

func (*MockClusterManager) ReRegisterCluster

func (m *MockClusterManager) ReRegisterCluster(cluster *models.Cluster) error

ReRegisterCluster mocks base method.

func (*MockClusterManager) RegisterCluster

func (m *MockClusterManager) RegisterCluster(cluster *models.Cluster) error

RegisterCluster mocks base method.

func (*MockClusterManager) Start

func (m *MockClusterManager) Start(ctx context.Context)

Start mocks base method.

func (*MockClusterManager) Stop

func (m *MockClusterManager) Stop(ctx context.Context) error

Stop mocks base method.

func (*MockClusterManager) UnregisterCluster

func (m *MockClusterManager) UnregisterCluster(clusterID string) error

UnregisterCluster mocks base method.

type MockClusterManagerMockRecorder

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

MockClusterManagerMockRecorder is the mock recorder for MockClusterManager.

func (*MockClusterManagerMockRecorder) GetClient

func (mr *MockClusterManagerMockRecorder) GetClient(clusterID any) *gomock.Call

GetClient indicates an expected call of GetClient.

func (*MockClusterManagerMockRecorder) GetRestConfig

func (mr *MockClusterManagerMockRecorder) GetRestConfig(clusterID any) *gomock.Call

GetRestConfig indicates an expected call of GetRestConfig.

func (*MockClusterManagerMockRecorder) IsClusterRegistered

func (mr *MockClusterManagerMockRecorder) IsClusterRegistered(clusterID any) *gomock.Call

IsClusterRegistered indicates an expected call of IsClusterRegistered.

func (*MockClusterManagerMockRecorder) IsRunning

func (mr *MockClusterManagerMockRecorder) IsRunning() *gomock.Call

IsRunning indicates an expected call of IsRunning.

func (*MockClusterManagerMockRecorder) ReRegisterCluster

func (mr *MockClusterManagerMockRecorder) ReRegisterCluster(cluster any) *gomock.Call

ReRegisterCluster indicates an expected call of ReRegisterCluster.

func (*MockClusterManagerMockRecorder) RegisterCluster

func (mr *MockClusterManagerMockRecorder) RegisterCluster(cluster any) *gomock.Call

RegisterCluster indicates an expected call of RegisterCluster.

func (*MockClusterManagerMockRecorder) Start

Start indicates an expected call of Start.

func (*MockClusterManagerMockRecorder) Stop

Stop indicates an expected call of Stop.

func (*MockClusterManagerMockRecorder) UnregisterCluster

func (mr *MockClusterManagerMockRecorder) UnregisterCluster(clusterID any) *gomock.Call

UnregisterCluster indicates an expected call of UnregisterCluster.

type MockDBClusterService

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

MockDBClusterService is a mock of DBClusterService interface.

func NewMockDBClusterService

func NewMockDBClusterService(ctrl *gomock.Controller) *MockDBClusterService

NewMockDBClusterService creates a new mock instance.

func (*MockDBClusterService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDBClusterService) GetClusterForOrg

func (m *MockDBClusterService) GetClusterForOrg(ctx context.Context, orgID string) (*models.Cluster, *errors.ServiceError)

GetClusterForOrg mocks base method.

type MockDBClusterServiceMockRecorder

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

MockDBClusterServiceMockRecorder is the mock recorder for MockDBClusterService.

func (*MockDBClusterServiceMockRecorder) GetClusterForOrg

func (mr *MockDBClusterServiceMockRecorder) GetClusterForOrg(ctx, orgID any) *gomock.Call

GetClusterForOrg indicates an expected call of GetClusterForOrg.

type MockKubernetesClient

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

MockKubernetesClient is a mock of KubernetesClient interface.

func NewMockKubernetesClient

func NewMockKubernetesClient(ctrl *gomock.Controller) *MockKubernetesClient

NewMockKubernetesClient creates a new mock instance.

func (*MockKubernetesClient) AttachablePodFromService

func (m *MockKubernetesClient) AttachablePodFromService(ctx context.Context, svcKey types.NamespacedName) (*v1.Pod, error)

AttachablePodFromService mocks base method.

func (*MockKubernetesClient) BuildPodForJob

func (m *MockKubernetesClient) BuildPodForJob(ctx context.Context, namespace, jobName string) (*v1.Pod, error)

BuildPodForJob mocks base method.

func (*MockKubernetesClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockKubernetesClient) GetNamespaceMetrics

func (m *MockKubernetesClient) GetNamespaceMetrics(ctx context.Context, namespace string) (*clients.MetricsStreamObject, error)

GetNamespaceMetrics mocks base method.

func (*MockKubernetesClient) StreamNamespaceMetrics

func (m *MockKubernetesClient) StreamNamespaceMetrics(ctx context.Context, namespace string, metricsStreamOpts clients.MetricsStreamOptions) (<-chan *clients.MetricsStreamObject, error)

StreamNamespaceMetrics mocks base method.

func (*MockKubernetesClient) StreamPodLogs

func (m *MockKubernetesClient) StreamPodLogs(ctx context.Context, pod *v1.Pod, logOpts clients.PodLogStreamOptions) (<-chan *clients.LogStreamObject, error)

StreamPodLogs mocks base method.

type MockKubernetesClientMockRecorder

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

MockKubernetesClientMockRecorder is the mock recorder for MockKubernetesClient.

func (*MockKubernetesClientMockRecorder) AttachablePodFromService

func (mr *MockKubernetesClientMockRecorder) AttachablePodFromService(ctx, svcKey any) *gomock.Call

AttachablePodFromService indicates an expected call of AttachablePodFromService.

func (*MockKubernetesClientMockRecorder) BuildPodForJob

func (mr *MockKubernetesClientMockRecorder) BuildPodForJob(ctx, namespace, jobName any) *gomock.Call

BuildPodForJob indicates an expected call of BuildPodForJob.

func (*MockKubernetesClientMockRecorder) GetNamespaceMetrics

func (mr *MockKubernetesClientMockRecorder) GetNamespaceMetrics(ctx, namespace any) *gomock.Call

GetNamespaceMetrics indicates an expected call of GetNamespaceMetrics.

func (*MockKubernetesClientMockRecorder) StreamNamespaceMetrics

func (mr *MockKubernetesClientMockRecorder) StreamNamespaceMetrics(ctx, namespace, metricsStreamOpts any) *gomock.Call

StreamNamespaceMetrics indicates an expected call of StreamNamespaceMetrics.

func (*MockKubernetesClientMockRecorder) StreamPodLogs

func (mr *MockKubernetesClientMockRecorder) StreamPodLogs(ctx, pod, logOpts any) *gomock.Call

StreamPodLogs indicates an expected call of StreamPodLogs.

type NamespaceClusterResourceService

type NamespaceClusterResourceService interface {
	CreateNamespaceInCluster(ctx context.Context, ns *models.Namespace) *ClusterResourceError
	DeleteNamespaceInCluster(ctx context.Context, ns *models.Namespace) *ClusterResourceError
}

NamespaceClusterResourceService is an interface for managing namespace resources in a cluster.

func NewNamespaceClusterResourceService

func NewNamespaceClusterResourceService(spec NamespaceClusterResourceServiceSpec) NamespaceClusterResourceService

NewNamespaceClusterResourceService creates a new NamespaceClusterResourceService

type NamespaceClusterResourceServiceSpec

type NamespaceClusterResourceServiceSpec struct {
	ClusterService DBClusterService
	ClusterManager clustermanager.ClusterManager
	Logger         logger.Logger
}

type ResourceError

type ResourceError struct {
	ResourceName string
	Error        error
}

type StackStorageClusterResourceService

type StackStorageClusterResourceService interface {
	UpsertStorageInCluster(ctx context.Context, stackStorage *models.StackStorage) *ClusterResourceError
	DeleteStorageInCluster(ctx context.Context, stackStorage *models.StackStorage) *ClusterResourceError
}

type StreamedLog

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

func (*StreamedLog) Data

func (s *StreamedLog) Data() string

func (*StreamedLog) Error

func (s *StreamedLog) Error() error

type StreamedMetrics

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

func (*StreamedMetrics) Data

func (s *StreamedMetrics) Data() string

func (*StreamedMetrics) Error

func (s *StreamedMetrics) Error() error

type VolumeClusterResourceService

type VolumeClusterResourceService interface {
	UpdateVolumeRemoteDirRevisionInCluster(ctx context.Context, volume *models.Volume) *ClusterResourceError
	UpdateVolumeGitRevisionInCluster(ctx context.Context, volume *models.Volume) *ClusterResourceError
	CreateVolumeInCluster(ctx context.Context, volume *models.Volume) *ClusterResourceError
	DeleteVolumeInCluster(ctx context.Context, volume *models.Volume) *ClusterResourceError
}

VolumeClusterResourceService is an interface for managing volume resources in a cluster.

type VolumeClusterResourceServiceSpec

type VolumeClusterResourceServiceSpec struct {
	ClusterService DBClusterService
	ClusterManager clustermanager.ClusterManager
	Logger         logger.Logger
}

Jump to

Keyboard shortcuts

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