Documentation
¶
Index ¶
- Constants
- Variables
- func BuildSyntheticConditions(existingConditionsJSON []byte, adapterStatuses api.AdapterStatusList, ...) (api.ResourceCondition, api.ResourceCondition)
- func ComputeAvailableCondition(adapterStatuses api.AdapterStatusList, requiredAdapters []string) (bool, int32)
- func ComputeReadyCondition(adapterStatuses api.AdapterStatusList, requiredAdapters []string, ...) bool
- func MapAdapterToConditionType(adapterName string) string
- type AdapterStatusService
- type ClusterService
- type GenericService
- type ListArguments
- type NodePoolService
Constants ¶
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 ¶
var (
SearchDisallowedFields = map[string]map[string]string{
"Cluster": {
"spec": "spec",
},
"NodePool": {
"spec": "spec",
},
}
)
Functions ¶
func BuildSyntheticConditions ¶
func BuildSyntheticConditions( existingConditionsJSON []byte, adapterStatuses api.AdapterStatusList, requiredAdapters []string, resourceGeneration int32, now time.Time, ) (api.ResourceCondition, api.ResourceCondition)
func ComputeAvailableCondition ¶
func ComputeAvailableCondition(adapterStatuses api.AdapterStatusList, requiredAdapters []string) (bool, int32)
ComputeAvailableCondition checks if all required adapters have Available=True at ANY generation. Returns: (isAvailable bool, minObservedGeneration int32) "Available" means the system is running at some known good configuration (last known good config). The minObservedGeneration is the lowest generation across all required adapters.
func ComputeReadyCondition ¶
func ComputeReadyCondition( adapterStatuses api.AdapterStatusList, requiredAdapters []string, resourceGeneration int32, ) bool
ComputeReadyCondition checks if all required adapters have Available=True at the CURRENT generation. "Ready" means the system is running at the latest spec generation.
func MapAdapterToConditionType ¶
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)
// ProcessAdapterStatus handles the business logic for adapter status:
// - If Available condition is "Unknown": returns (nil, nil) indicating no-op
// - Otherwise: upserts the status and triggers aggregation
ProcessAdapterStatus(
ctx context.Context, clusterID string, adapterStatus *api.AdapterStatus,
) (*api.AdapterStatus, *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, adapterConfig *config.AdapterRequirementsConfig, ) 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)
// ProcessAdapterStatus handles the business logic for adapter status:
// - If Available condition is "Unknown": returns (nil, nil) indicating no-op
// - Otherwise: upserts the status and triggers aggregation
ProcessAdapterStatus(
ctx context.Context, nodePoolID string, adapterStatus *api.AdapterStatus,
) (*api.AdapterStatus, *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, adapterConfig *config.AdapterRequirementsConfig, ) NodePoolService