api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

This file defines a set of experimental aliases for the purpose of getting a feel for the best naming conventions for the SDK.

Index

Constants

View Source
const (
	// EventWorker is the event type for worker-level events.
	EventWorker = "WorkerEvent"

	// EventBridgeWorker is the event type for bridge worker-level events.
	EventBridgeWorker = "BridgeWorkerEvent"

	// EventFunctionWorker is the event type for function worker-level events.
	EventFunctionWorker = "FunctionWorkerEvent"
)

SSE event types

View Source
const MaxActionResultMessageLength = 1024
View Source
const MaxConfigDataLength = 64 * 1024 * 1024 // 64MB
View Source
const MaxParametersLength = 16384

Max size of marshaled parameters

View Source
const MaxProviderTypeLength = 128

Max length for 3P providers

Variables

Functions

func GenerateTargetName

func GenerateTargetName(workerSlug string, provider ProviderType, toolchain workerapi.ToolchainType, suffix string) string

func IsSupportedProvider

func IsSupportedProvider(provider ProviderType) bool

func ValidateActionResultBaseMeta

func ValidateActionResultBaseMeta(arbm *ActionResultBaseMeta) error

func ValidateActionResultData

func ValidateActionResultData(ar *ActionResult) error

func ValidateActionResultMeta

func ValidateActionResultMeta(ar *ActionResult) error

Types

type Action

type Action = ActionType

Action and result aliases

type ActionResult

type ActionResult struct {
	UnitID  uuid.UUID `description:"UUID of the Unit on which the action is performed"`
	SpaceID uuid.UUID `description:"UUID of the Space of the Unit on which the action is performed"`
	// OrganizationID comes from the worker
	// QueuedOperationID links this result back to the original operation request.
	QueuedOperationID uuid.UUID `description:"UUID of the operation corresponding to the action request"`
	ActionResultBaseMeta
	Data      []byte `` /* 130-byte string literal not displayed */
	LiveData  []byte `` /* 138-byte string literal not displayed */
	LiveState []byte `` /* 130-byte string literal not displayed */
	// ResourceStatuses contains per-resource sync and readiness status.
	// Key format: "apiVersion/kind#namespace/name" (e.g., "apps/v1/Deployment#default/my-app")
	ResourceStatuses ResourceStatusMap `json:",omitempty" description:"Per-resource sync and readiness status"`
}

ActionResult is a result of action from the Bridgeworker

type ActionResultBaseMeta

type ActionResultBaseMeta struct {
	RevisionNum  int64
	Action       ActionType       `bun:",notnull" swaggertype:"string"`
	Result       ActionResultType `bun:",notnull,default:'None'" swaggertype:"string"`
	Status       ActionStatusType `bun:",notnull,default:'None'" swaggertype:"string"`
	Message      string           `bun:"type:text"`
	StartedAt    time.Time        `json:",omitempty" bun:"type:timestamptz"`
	TerminatedAt *time.Time       `json:",omitempty" bun:"type:timestamptz"`
}

type ActionResultMeta

type ActionResultMeta = ActionResultBaseMeta

type ActionResultType

type ActionResultType string
const (
	ActionResultNone              ActionResultType = "None"
	ActionResultApplyCompleted    ActionResultType = "ApplyCompleted"
	ActionResultApplySynced       ActionResultType = "ApplySynced" // Config pushed to target, waiting for resources to be ready
	ActionResultApplyFailed       ActionResultType = "ApplyFailed"
	ActionResultApplyWaitFailed   ActionResultType = "ApplyWaitFailed"
	ActionResultDestroyCompleted  ActionResultType = "DestroyCompleted"
	ActionResultDestroyFailed     ActionResultType = "DestroyFailed"
	ActionResultDestroyWaitFailed ActionResultType = "DestroyWaitFailed"
	ActionResultRefreshFailed     ActionResultType = "RefreshFailed"
	ActionResultRefreshAndDrifted ActionResultType = "RefreshAndDrifted"
	ActionResultRefreshAndNoDrift ActionResultType = "RefreshAndNoDrift"
	ActionResultImportCompleted   ActionResultType = "ImportCompleted"
	ActionResultImportFailed      ActionResultType = "ImportFailed"

	ActionResultFunctionInvocationCompleted ActionResultType = "FunctionInvocationCompleted"
	ActionResultFunctionInvocationFailed    ActionResultType = "FunctionInvocationFailed"
)

Drift values

type ActionStatus

type ActionStatus = ActionStatusType

type ActionStatusType

type ActionStatusType string
const (
	ActionStatusNone        ActionStatusType = "None"
	ActionStatusPending     ActionStatusType = "Pending"
	ActionStatusSubmitted   ActionStatusType = "Submitted"
	ActionStatusProgressing ActionStatusType = "Progressing"
	ActionStatusCompleted   ActionStatusType = "Completed"
	ActionStatusFailed      ActionStatusType = "Failed"
	ActionStatusCanceled    ActionStatusType = "Canceled"
	ActionStatusAborted     ActionStatusType = "Aborted" // Operation superseded by a newer one
)

Status values

type ActionType

type ActionType string
const (
	ActionNA        ActionType = "N/A"
	ActionApply     ActionType = "Apply"
	ActionDestroy   ActionType = "Destroy"
	ActionRefresh   ActionType = "Refresh"
	ActionImport    ActionType = "Import"
	ActionFinalize  ActionType = "Finalize"
	ActionHeartbeat ActionType = "Heartbeat"
	ActionCancel    ActionType = "Cancel"

	ActionInvokeFunctions ActionType = "InvokeFunctions"
	ActionListFunctions   ActionType = "ListFunctions"
)

Action values

type Bridge

type Bridge = BridgeWorker

Core interface aliases

type BridgeContext

type BridgeContext = BridgeWorkerContext

type BridgeInfo

type BridgeInfo = BridgeWorkerInfo

Information and options aliases

type BridgePayload

type BridgePayload = BridgeWorkerPayload

type BridgeWorkerContext

type BridgeWorkerContext interface {
	Context() context.Context
	GetServerURL() string
	GetWorkerID() string
	SendStatus(*ActionResult) error
}

type BridgeWorkerEventRequest

type BridgeWorkerEventRequest struct {
	Action  ActionType `description:"The action requested"`
	Payload BridgeWorkerPayload
}

type BridgeWorkerInfo

type BridgeWorkerInfo struct {
	SupportedConfigTypes []*ConfigType `json:",omitempty" description:"Configuration types of the bridges supported by the worker"`
}

type BridgeWorkerPayload

type BridgeWorkerPayload struct {
	QueuedOperationID uuid.UUID               `description:"UUID of the operation corresponding to the requested action"`
	ToolchainType     workerapi.ToolchainType `description:"ToolchainType of the Unit on which the action was performed"`
	ProviderType      ProviderType            `description:"ProviderType of the Target attached to the Unit on which the action was performed"`

	// Keep relatively consistent with FunctionContext
	UnitSlug         string            `description:"Slug of the Unit on which the action was performed"`
	UnitID           uuid.UUID         `description:"UUID of the Unit on which the action was performed"`
	UnitLabels       map[string]string `description:"Labels of the Unit on which the action was performed"`
	UnitAnnotations  map[string]string `description:"Annotations of the Unit on which the action was performed"`
	SpaceSlug        string            `description:"Slug of the Space of the Unit on which the action was performed"`
	SpaceID          uuid.UUID         `description:"UUID of the Space of the Unit on which the action was performed"`
	SpaceLabels      map[string]string `description:"Labels of the Space of the Unit on which the action was performed"`
	SpaceAnnotations map[string]string `description:"Annotations of the Space of the Unit on which the action was performed"`
	OrganizationID   uuid.UUID         `description:"UUID of the Organization of the Unit on which the action was performed"`
	TargetID         uuid.UUID         `description:"UUID of the Target attached to the Unit on which the action was performed"`

	DryRun          bool   `description:"Whether the action is a dry run"`
	Data            []byte `swaggertype:"string" format:"byte" description:"Configuration data of the Unit on which the action was performed"`
	LiveData        []byte `swaggertype:"string" format:"byte" description:"Live Data corresponding to the Unit"`
	LiveState       []byte `swaggertype:"string" format:"byte" description:"Live State corresponding to the Unit"`
	TargetParams    []byte `` /* 128-byte string literal not displayed */
	ExtraParams     []byte `swaggertype:"string" format:"byte" description:"Additional parameters associated with the action sent to the worker"`
	RevisionNum     int64  `description:"Sequence number of the revision of the Unit on which the action was performed"`
	LiveRevisionNum int64  `description:"Sequence number of the current live revision of the Unit on which the action was performed"`
}

BridgeWorkerPayload is an input for the Bridgeworker

type ConfigType

type ConfigType struct {
	ProviderType     ProviderType            `swaggertype:"string" description:"Type identifying a bridge implementation supported by the worker"`
	ToolchainType    workerapi.ToolchainType `swaggertype:"string" description:"Configuration toolchain and format implemented by this bridge of the worker"`
	LiveStateType    workerapi.ToolchainType `` /* 172-byte string literal not displayed */
	AvailableTargets []Target                `json:",omitempty" description:"Targets known by the BridgeWorker"`
}

type EventMessage

type EventMessage struct {
	Event string
	Data  interface{}
}

type FunctionWorkerContext

type FunctionWorkerContext interface {
	Context() context.Context
}

type FunctionWorkerEventRequest

type FunctionWorkerEventRequest struct {
	// Action defines the operation the function worker should perform.
	Action ActionType `description:"Action defines the operation the function worker should perform."`

	// Payload contains the data required for the action, primarily the function invocation details.
	Payload FunctionWorkerPayload `description:"Payload contains the data required for the action, primarily the function invocation details."`
}

FunctionWorkerEventRequest encapsulates a request destined for the function worker plugin. It specifies the action to be performed and includes the necessary payload.

type FunctionWorkerInfo

type FunctionWorkerInfo struct {
	ToolchainTypes     []workerapi.ToolchainType                                        `description:"Supported ToolchainTypes"`
	SupportedFunctions map[workerapi.ToolchainType]map[string]funcApi.FunctionSignature `description:"Signatures of supported functions by ToolchainType"`
}

type FunctionWorkerPayload

type FunctionWorkerPayload struct {
	// QueuedOperationID is the identifier of the original queued operation request.
	QueuedOperationID uuid.UUID `description:"QueuedOperationID is the identifier of the original queued operation request."`

	// InvocationRequest encapsulates the full request for invoking one or more functions,
	// including context, configuration data, function calls, and execution options.
	// This structure is defined in the functions plugin's API package.
	InvocationRequest funcApi.FunctionInvocationRequest `` /* 175-byte string literal not displayed */
}

FunctionWorkerPayload holds the specific data for a function worker request.

type InfoOptions

type InfoOptions struct {
	WorkerSlug string
}

type ProviderType

type ProviderType string
const (
	ProviderConfigHub      ProviderType = "ConfigHub"
	ProviderKubernetes     ProviderType = "Kubernetes"
	ProviderFluxOCIWriter  ProviderType = "FluxOCIWriter"
	ProviderFluxRenderer   ProviderType = "FluxRenderer"
	ProviderConfigMap      ProviderType = "ConfigMap"
	ProviderOpenTofuAWS    ProviderType = "OpenTofu/AWS"
	ProviderArgoCDRenderer ProviderType = "ArgoCDRenderer"
)

ProviderType corresponds to the service API and client implementation TODO: Revisit whether this makes sense

type RefreshParams

type RefreshParams struct {
	BaseRevisionData []byte `description:"Data to diff with the live state for refresh"`
}

type ResourceInfo

type ResourceInfo struct {
	ResourceName string `` /* 206-byte string literal not displayed */
	ResourceType string `` /* 214-byte string literal not displayed */
}

TODO unify this API with the function API package. This struct is redundant with that of function API.

type ResourceReadinessType

type ResourceReadinessType string

ResourceReadinessType represents the readiness status of an individual resource. Readiness status is derived from kstatus polling and indicates whether the resource has reached a ready/healthy state in the target system.

const (
	// ResourceReadinessReady indicates the resource is ready/healthy
	ResourceReadinessReady ResourceReadinessType = "Ready"
	// ResourceReadinessInProgress indicates the resource is progressing towards ready state
	ResourceReadinessInProgress ResourceReadinessType = "InProgress"
	// ResourceReadinessFailed indicates the resource failed to reach ready state
	ResourceReadinessFailed ResourceReadinessType = "Failed"
	// ResourceReadinessTerminating indicates the resource is being deleted
	ResourceReadinessTerminating ResourceReadinessType = "Terminating"
	// ResourceReadinessUnknown indicates the resource readiness cannot be determined
	ResourceReadinessUnknown ResourceReadinessType = "Unknown"
)

type ResourceStatus

type ResourceStatus struct {
	// SyncStatus indicates whether config was pushed to the target
	SyncStatus ResourceSyncStatusType `json:",omitempty" description:"Whether config was pushed to the target (Synced or NotSynced)"`
	// Readiness indicates the health/ready state from kstatus
	Readiness ResourceReadinessType `json:",omitempty" description:"Health state from kstatus (Ready, InProgress, Failed, Unknown)"`
	// Message provides human-readable status details
	Message string `json:",omitempty" description:"Human-readable status details or error message"`
	// UpdatedAt is the timestamp when this resource status was last updated
	UpdatedAt time.Time `json:",omitempty" description:"Timestamp when this resource status was last updated"`
}

ResourceStatus represents the sync and readiness status of a single resource. It tracks both whether configuration was pushed (SyncStatus) and whether the resource has become healthy/ready (Readiness), along with a timestamp for tracking progress duration.

type ResourceStatusMap

type ResourceStatusMap map[funcApi.ResourceTypeAndName]ResourceStatus

ResourceStatusMap maps ResourceTypeAndName to ResourceStatus. Key format: "apiVersion/kind#namespace/name" following K8sResourceProviderType conventions Examples: "apps/v1/Deployment#default/my-app", "v1/ConfigMap#/my-config" This format includes namespace to distinguish resources with the same name in different namespaces.

type ResourceSyncStatusType

type ResourceSyncStatusType string

ResourceSyncStatusType represents the sync status of an individual resource. Sync status indicates whether the configuration has been pushed to the target.

const (
	// ResourceSyncStatusSynced indicates the config was successfully pushed to the target
	ResourceSyncStatusSynced ResourceSyncStatusType = "Synced"
	// ResourceSyncStatusPending indicates the resource is waiting to be synced
	ResourceSyncStatusPending ResourceSyncStatusType = "Pending"
	// ResourceSyncStatusFailed indicates the sync operation failed
	ResourceSyncStatusFailed ResourceSyncStatusType = "Failed"
)

type Target

type Target struct {
	Name string `json:",omitempty" description:"Used to set the Slug and DisplayName of the Target created in ConfigHub"`
	// TODO: this should be perhaps some version of OCIParams like in the FluxOCIParams struct
	Params map[string]interface{} `json:",omitempty" description:"Used to set the Parameters of the Target created in ConfigHub"`
}

type Toolchain

type Toolchain = workerapi.ToolchainType

Configuration type aliases

type WatchableWorker

type WatchableWorker interface {
	WatchForApply(BridgeWorkerContext, BridgeWorkerPayload) error
	WatchForDestroy(BridgeWorkerContext, BridgeWorkerPayload) error
}

type WorkerEventRequest

type WorkerEventRequest struct {
	Action  ActionType `description:"The action requested"`
	Payload WorkerPayload
}

type WorkerInfo

type WorkerInfo struct {
	BridgeWorkerInfo   BridgeWorkerInfo   `description:"BridgeWorker capabilities"`
	FunctionWorkerInfo FunctionWorkerInfo `description:"FunctionWorker capabilities"`
}

type WorkerPayload

type WorkerPayload struct {
	Timestamp int64 `description:"Time the action was requested"`
}

Jump to

Keyboard shortcuts

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