services

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ConditionValidationErrorMissing = "missing"
)

Condition validation error type

View Source
const MaxListSize = 65500

~65500 is the maximum number of parameters that can be provided to a postgres WHERE IN clause Use it as a sane max

Variables

View Source
var (
	SearchDisallowedFields = map[string]map[string]string{
		api.ResourceTypeCluster: {
			"spec": "spec",
		},
		api.ResourceTypeNodePool: {
			"spec": "spec",
		},
	}
)

Functions

func AdapterObservedTime added in v0.2.0

func AdapterObservedTime(as *api.AdapterStatus) time.Time

AdapterObservedTime returns the adapter-reported observation instant used for ordering and aggregation.

func AggregateResourceStatus added in v0.2.0

func AggregateResourceStatus(ctx context.Context, in AggregateResourceStatusInput) (
	reconciled, lastKnownReconciled api.ResourceCondition, adapterConditions []api.ResourceCondition,
)

AggregateResourceStatus computes Reconciled, LastKnownReconciled, and per-adapter conditions from stored adapter rows and previous conditions. It does not use wall clock.

The returned adapterConditions slice contains one entry per required adapter that has reported, with a type derived from the adapter name (e.g. "adapter1" → "Adapter1Successful").

func MapAdapterToConditionType

func MapAdapterToConditionType(adapterName string) string

MapAdapterToConditionType converts an adapter name to a semantic condition type (PascalCase + suffix). Used to derive the type name for per-adapter conditions mirrored into resource status (e.g. "adapter1" → "Adapter1Successful", "my-adapter" → "MyAdapterSuccessful").

func ValidateMandatoryConditions added in v0.1.1

func ValidateMandatoryConditions(conditions []api.AdapterCondition) (errorType, conditionName string)

ValidateMandatoryConditions checks if all mandatory conditions are present. Format validation (empty type, duplicates, invalid status) is done in the Handler layer.

Types

type AdapterStatusService

type AdapterStatusService interface {
	Get(ctx context.Context, id string) (*api.AdapterStatus, *errors.ServiceError)
	Create(ctx context.Context, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError)
	Upsert(ctx context.Context, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError)
	Delete(ctx context.Context, id string) *errors.ServiceError
	FindByResource(
		ctx context.Context, resourceType, resourceID string,
	) (api.AdapterStatusList, *errors.ServiceError)
	FindByResourcePaginated(
		ctx context.Context, resourceType, resourceID string, listArgs *ListArguments,
	) (api.AdapterStatusList, int64, *errors.ServiceError)
	FindByResourceAndAdapter(
		ctx context.Context, resourceType, resourceID, adapter string,
	) (*api.AdapterStatus, *errors.ServiceError)
	All(ctx context.Context) (api.AdapterStatusList, *errors.ServiceError)
}

func NewAdapterStatusService

func NewAdapterStatusService(adapterStatusDao dao.AdapterStatusDao) AdapterStatusService

type AggregateResourceStatusInput added in v0.2.0

type AggregateResourceStatusInput struct {
	ResourceGeneration int32
	RefTime            time.Time
	DeletedTime        *time.Time
	PrevConditionsJSON []byte
	RequiredAdapters   []string
	AdapterStatuses    api.AdapterStatusList
	HasChildResources  bool
}

AggregateResourceStatusInput carries everything needed to compute deterministic conditions. RefTime must be resource.updated_time (never time.Now) so results are reproducible.

type ClusterService

type ClusterService interface {
	Get(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError)
	Create(ctx context.Context, cluster *api.Cluster) (*api.Cluster, *errors.ServiceError)
	Patch(ctx context.Context, id string, patch *api.ClusterPatchRequest) (*api.Cluster, *errors.ServiceError)
	SoftDelete(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError)
	All(ctx context.Context) (api.ClusterList, *errors.ServiceError)
	FindByIDs(ctx context.Context, ids []string) (api.ClusterList, *errors.ServiceError)
	UpdateClusterStatusFromAdapters(ctx context.Context, clusterID string) (*api.Cluster, *errors.ServiceError)
	ProcessAdapterStatus(ctx context.Context, clusterID string, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError) // nolint:lll
	ForceDelete(ctx context.Context, id, reason string) *errors.ServiceError

	// idempotent functions for the control plane, but can also be called synchronously by any actor
	OnUpsert(ctx context.Context, id string) error
	OnDelete(ctx context.Context, id string) error
}

func NewClusterService

func NewClusterService(
	clusterDao dao.ClusterDao,
	nodePoolDao dao.NodePoolDao,
	nodePoolService NodePoolService,
	adapterStatusDao dao.AdapterStatusDao,
	adapterConfig *config.AdapterRequirementsConfig,
) ClusterService

type GenericService

type GenericService interface {
	List(
		ctx context.Context, args *ListArguments, resourceList interface{},
	) (*api.PagingMeta, *errors.ServiceError)
}

func NewGenericService

func NewGenericService(genericDao dao.GenericDao) GenericService

type ListArguments

type ListArguments struct {
	Search   string
	Preloads []string
	OrderBy  []string
	Fields   []string
	Page     int
	Size     int64
}

ListArguments are arguments relevant for listing objects. This struct is common to all service List funcs in this package

func NewListArguments

func NewListArguments(params url.Values) *ListArguments

NewListArguments Create ListArguments from url query parameters with sane defaults

type NodePoolService

type NodePoolService interface {
	Get(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError)
	Create(ctx context.Context, nodePool *api.NodePool) (*api.NodePool, *errors.ServiceError)
	Patch(ctx context.Context, id string, patch *api.NodePoolPatchRequest) (*api.NodePool, *errors.ServiceError)
	GetByIDAndOwner(ctx context.Context, id string, ownerID string) (*api.NodePool, *errors.ServiceError)
	ListByCluster(
		ctx context.Context, clusterID string, args *ListArguments,
	) (api.NodePoolList, *api.PagingMeta, *errors.ServiceError)
	SoftDelete(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError)
	CascadeSoftDelete(
		ctx context.Context, nodePools api.NodePoolList, deletedBy string, deletedTime time.Time,
	) *errors.ServiceError
	Delete(ctx context.Context, id string) *errors.ServiceError
	ForceDelete(ctx context.Context, id string, reason string) *errors.ServiceError
	All(ctx context.Context) (api.NodePoolList, *errors.ServiceError)

	FindByIDs(ctx context.Context, ids []string) (api.NodePoolList, *errors.ServiceError)

	UpdateNodePoolStatusFromAdapters(ctx context.Context, nodePoolID string) (*api.NodePool, *errors.ServiceError)

	ProcessAdapterStatus(
		ctx context.Context, nodePoolID string, adapterStatus *api.AdapterStatus,
	) (*api.AdapterStatus, *errors.ServiceError)

	OnUpsert(ctx context.Context, id string) error
	OnDelete(ctx context.Context, id string) error
}

func NewNodePoolService

func NewNodePoolService(
	nodePoolDao dao.NodePoolDao,
	clusterDao dao.ClusterDao,
	adapterStatusDao dao.AdapterStatusDao,
	adapterConfig *config.AdapterRequirementsConfig,
	generic GenericService,
) NodePoolService

type ResourceService added in v0.3.0

type ResourceService interface {
	Get(ctx context.Context, kind, id string) (*api.Resource, *errors.ServiceError)
	Create(ctx context.Context, kind string, resource *api.Resource) (*api.Resource, *errors.ServiceError)
	Patch(ctx context.Context, kind, id string, patch *api.ResourcePatchRequest) (*api.Resource, *errors.ServiceError)
	Delete(ctx context.Context, kind, id string) (*api.Resource, *errors.ServiceError)
	FindByIDs(ctx context.Context, kind string, ids []string) (api.ResourceList, *errors.ServiceError)
	List(ctx context.Context, kind string, args *ListArguments) (api.ResourceList, *api.PagingMeta, *errors.ServiceError)
	GetByOwner(ctx context.Context, kind, id, ownerID string) (*api.Resource, *errors.ServiceError)
	ListByOwner(ctx context.Context, kind, ownerID string, args *ListArguments) (api.ResourceList, *api.PagingMeta, *errors.ServiceError) // nolint:lll
}

func NewResourceService added in v0.3.0

func NewResourceService(resourceDao dao.ResourceDao, generic GenericService) ResourceService

Jump to

Keyboard shortcuts

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