services

package
v0.0.0-...-145cf54 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

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{
		"Cluster": {
			"spec": "spec",
		},
		"NodePool": {
			"spec": "spec",
		},
	}
)

Functions

func ComputePhase

func ComputePhase(ctx context.Context, adapterStatuses api.AdapterStatusList, requiredAdapters []string, resourceGeneration int32) string

ComputePhase calculates the overall phase for a resource based on adapter statuses

MVP Phase Logic (per architecture/hyperfleet/docs/status-guide.md): - "Ready": All required adapters have Available=True for current generation - "NotReady": Otherwise (any adapter has Available=False or hasn't reported yet)

An adapter is considered "available" when: 1. Available condition status == "True" 2. observed_generation == resource.generation (only checked if resourceGeneration > 0)

Note: Post-MVP will add more phases (Pending, Provisioning, Failed, Degraded) based on Health condition and Applied condition states.

func MapAdapterToConditionType

func MapAdapterToConditionType(adapterName string) string

MapAdapterToConditionType converts an adapter name to a semantic condition type by converting the adapter name to PascalCase and appending a suffix.

Current behavior: All adapters → {AdapterName}Successful Examples:

  • "validator" → "ValidatorSuccessful"
  • "dns" → "DnsSuccessful"
  • "gcp-provisioner" → "GcpProvisionerSuccessful"

Future customization: Override suffix in adapterConditionSuffixMap

adapterConditionSuffixMap["dns"] = "Ready" → "DnsReady"

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)
	Replace(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 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)
	Replace(ctx context.Context, cluster *api.Cluster) (*api.Cluster, *errors.ServiceError)
	Delete(ctx context.Context, id string) *errors.ServiceError
	All(ctx context.Context) (api.ClusterList, *errors.ServiceError)

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

	// Status aggregation
	UpdateClusterStatusFromAdapters(ctx context.Context, clusterID string) (*api.Cluster, *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, adapterStatusDao dao.AdapterStatusDao) ClusterService

type GenericService

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

func NewGenericService

func NewGenericService(genericDao dao.GenericDao) GenericService

type ListArguments

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

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)
	Replace(ctx context.Context, nodePool *api.NodePool) (*api.NodePool, *errors.ServiceError)
	Delete(ctx context.Context, id string) *errors.ServiceError
	All(ctx context.Context) (api.NodePoolList, *errors.ServiceError)

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

	// Status aggregation
	UpdateNodePoolStatusFromAdapters(ctx context.Context, nodePoolID string) (*api.NodePool, *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 NewNodePoolService

func NewNodePoolService(nodePoolDao dao.NodePoolDao, adapterStatusDao dao.AdapterStatusDao) NodePoolService

Jump to

Keyboard shortcuts

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