operator

package
v0.0.774 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassifyTaskType

func ClassifyTaskType(task *types.Task) ecs.TaskType

ClassifyTaskType returns ecs.TaskTypeService if the task was launched by an ECS service, ecs.TaskTypeStandalone otherwise. AWS sets Task.Group="service:<name>" and Task.StartedBy="ecs-svc/<deployment-id>" for service-managed tasks; either match is sufficient.

func ComputeChecksum

func ComputeChecksum(payload []byte) string

ComputeChecksum computes a SHA-256 checksum of the payload for change detection

Types

type ChunkingInfo

type ChunkingInfo struct {
	ChunkID     string `json:"chunkId"`     // UUID identifying a chunked request (same for all chunks)
	ChunkIndex  int    `json:"chunkIndex"`  // 0-based index of this chunk
	TotalChunks int    `json:"totalChunks"` // Total number of chunks
}

ChunkingInfo represents pagination/chunking information for splitting large requests

type EcsClusterResource

type EcsClusterResource = EcsResource

EcsClusterResource represents a cluster resource (for operator events) It's a type alias to EcsResource for JSON compatibility

func NewClusterResource

func NewClusterResource(cluster types.Cluster) (EcsClusterResource, error)

NewClusterResource creates a EcsResource from an AWS ECS Cluster

func (*EcsClusterResource) Unmarshal

func (r *EcsClusterResource) Unmarshal() (*types.Cluster, error)

Unmarshal extracts the AWS Cluster from an EcsClusterResource payload It does not check ResourceType: EcsClusterResource is an alias of EcsResource, so callers must only invoke it on cluster payloads (OperatorKeepAliveEvent.Cluster).

type EcsResource

type EcsResource struct {
	ResourceARN  string              `json:"resourceArn"`
	ResourceType ecs.EcsResourceType `json:"resourceType"` // Service, Task, TaskDefinition
	Payload      json.RawMessage     `json:"payload"`      // Raw AWS SDK JSON
	Checksum     string              `json:"checksum"`
}

EcsResource represents information about an ECS resource (for operator events)

func NewServiceResource

func NewServiceResource(service types.Service) (EcsResource, error)

NewServiceResource creates an EcsResource from an AWS ECS Service

func NewTaskDefinitionResource

func NewTaskDefinitionResource(taskDef types.TaskDefinition) (EcsResource, error)

NewTaskDefinitionResource creates an EcsResource from an AWS ECS TaskDefinition

func NewTaskResource

func NewTaskResource(task types.Task) (EcsResource, error)

NewTaskResource creates an EcsResource from an AWS ECS Task

func (*EcsResource) UnmarshalService

func (r *EcsResource) UnmarshalService() (*types.Service, error)

UnmarshalService extracts the AWS Service from an EcsResource payload

func (*EcsResource) UnmarshalTask

func (r *EcsResource) UnmarshalTask() (*types.Task, error)

UnmarshalTask extracts the AWS Task from an EcsResource payload

func (*EcsResource) UnmarshalTaskDefinition

func (r *EcsResource) UnmarshalTaskDefinition() (*types.TaskDefinition, error)

UnmarshalTaskDefinition extracts the AWS TaskDefinition from an EcsResource payload

type ErrorCounts

type ErrorCounts struct {
	SyncErrors int `json:"syncErrors"`
	APIErrors  int `json:"apiErrors"`
}

ErrorCounts represents error counts in the last hour

type InventoryCounts

type InventoryCounts struct {
	Services        int `json:"services"`
	Tasks           int `json:"tasks"`
	TaskDefinitions int `json:"taskDefinitions"`
}

InventoryCounts represents counts of discovered resources

type OperatorEvent

type OperatorEvent struct {
	MessageID    string            `json:"messageId"`          // UUID for debugging and tracing
	EventType    OperatorEventType `json:"eventType"`          // keepalive, resources, reconcile
	ClusterName  string            `json:"clusterName"`        // Required for all events
	Region       string            `json:"region"`             // AWS region (e.g., us-east-1)
	AWSAccountID string            `json:"awsAccountId"`       // AWS account ID
	Payload      json.RawMessage   `json:"payload"`            // Event-specific payload
	Chunking     *ChunkingInfo     `json:"chunking,omitempty"` // Pagination/chunking support (for future use)
}

OperatorEvent represents a generic ECS operator event

type OperatorEventType

type OperatorEventType string

OperatorEventType represents the type of operator event

const (
	EventTypeKeepalive OperatorEventType = "keepalive"
	EventTypeResources OperatorEventType = "resources"
	EventTypeReconcile OperatorEventType = "reconcile"
)

type OperatorKeepAliveEvent

type OperatorKeepAliveEvent struct {
	Timestamp                time.Time           `json:"timestamp"`
	Version                  string              `json:"version"`
	Status                   Status              `json:"status"` // HEALTHY, DEGRADED, UNHEALTHY
	Uptime                   string              `json:"uptime"` // Duration as string (e.g., "1h30m")
	LastSyncTimestamp        *time.Time          `json:"lastSyncTimestamp,omitempty"`
	LastReconcileTimestamp   *time.Time          `json:"lastReconcileTimestamp,omitempty"`
	InventoryCounts          InventoryCounts     `json:"inventoryCounts"`
	Errors                   ErrorCounts         `json:"errors"`
	Cluster                  *EcsClusterResource `json:"cluster,omitempty"`        // (optional) cluster resource will be set only if it's the first event or if cluster has changed
	OperatorVersionUpdatedAt time.Time           `json:"operatorVersionUpdatedAt"` // Time when the operator version was deployed on ECS
}

OperatorKeepAliveEvent represents the heartbeat payload along with cluster resource if it's the first event or if cluster has changed

type OperatorReconcileEvent

type OperatorReconcileEvent struct {
	Services        []string `json:"services"`
	Tasks           []string `json:"tasks"`
	TaskDefinitions []string `json:"taskDefinitions"`
}

OperatorReconcileEvent represents a reconciliation event with all ARNs

type OperatorResourcesEvent

type OperatorResourcesEvent struct {
	Resources []EcsResource `json:"resources"`
}

OperatorResourcesEvent represents an event with resource information

type Status

type Status string

Status represents the status of an ECS operator

const (
	StatusPending      Status = "PENDING"
	StatusHealthy      Status = "HEALTHY"
	StatusDegraded     Status = "DEGRADED"
	StatusUnhealthy    Status = "UNHEALTHY"
	StatusDisconnected Status = "DISCONNECTED"
)

Jump to

Keyboard shortcuts

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