Documentation
¶
Index ¶
- Constants
- func AdapterObservedTime(as *api.AdapterStatus) time.Time
- func AggregateResourceStatus(ctx context.Context, in AggregateResourceStatusInput) (reconciled, lastKnownReconciled api.ResourceCondition, ...)
- func ValidateMandatoryConditions(conditions []api.AdapterCondition) (errorType, conditionName string)
- type AdapterStatusService
- type AggregateResourceStatusInput
- type ApplyInput
- type ConditionMapper
- type GenericService
- type ListArguments
- type ResourceService
Constants ¶
const (
ConditionValidationErrorMissing = "missing"
)
Condition validation error type
Variables ¶
This section is empty.
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 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)
}
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 ApplyInput ¶ added in v0.3.1
type ApplyInput struct {
AdapterStatuses api.AdapterStatusList
Resource interface{}
RefTime time.Time
// PrevConditions is the previous mapped conditions from resource.Conditions
// Used to preserve CreatedTime and LastTransitionTime (matching aggregation.go pattern)
PrevConditions []api.ResourceCondition
}
ApplyInput holds the input data for condition mapping
type ConditionMapper ¶ added in v0.3.1
type ConditionMapper struct {
// contains filtered or unexported fields
}
ConditionMapper evaluates CEL-based condition mapping rules
func NewConditionMapper ¶ added in v0.3.1
func NewConditionMapper(resourceKind string, rules []registry.ConditionMappingRule) (*ConditionMapper, error)
NewConditionMapper creates a new condition mapper with pre-compiled rules
func (*ConditionMapper) Apply ¶ added in v0.3.1
func (m *ConditionMapper) Apply(ctx context.Context, input ApplyInput) ([]api.ResourceCondition, error)
Apply evaluates mapping rules and returns mapped conditions. Returns error on CEL evaluation failure to trigger transaction rollback per design doc. This ensures timely retry (10s) instead of delayed retry (30min) that would occur if partial results were committed without mapped conditions.
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
RefType string
RefTargetID string
Preloads []string
Order []string
Fields []string
Size int64
Page int64
}
ListArguments are arguments relevant for listing objects. This struct is common to all service List funcs in this package
func NewListArguments ¶
func NewListArguments() *ListArguments
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, refs api.ReferenceMap) (*api.Resource, *errors.ServiceError) //nolint:lll
Patch(ctx context.Context, kind, id string, patch *api.ResourcePatch) (*api.Resource, *errors.ServiceError)
Delete(ctx context.Context, kind, id string) (*api.Resource, *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
ForceDelete(ctx context.Context, kind, id, reason string) *errors.ServiceError
GetByID(ctx context.Context, id string) (*api.Resource, *errors.ServiceError)
ListAll(ctx context.Context, args *ListArguments) (api.ResourceList, *api.PagingMeta, *errors.ServiceError)
ProcessAdapterStatus(ctx context.Context, kind, resourceID string, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError) // nolint:lll
}
func NewResourceService ¶ added in v0.3.0
func NewResourceService( resourceDao dao.ResourceDao, resourceLabelDao dao.ResourceLabelDao, adapterStatusDao dao.AdapterStatusDao, resourceConditionDao dao.ResourceConditionDao, generic GenericService, ) (ResourceService, error)