integrations

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAllocationDeletesInCloud

func ApplyAllocationDeletesInCloud(ctx context.Context, s store.Storer, conn *store.CloudConnection) error

ApplyAllocationDeletesInCloud deletes in the cloud any allocations that were soft-deleted in the app (IPAM conflict resolution). Must run before ApplyBlockDeletesInCloud so subnets are deleted before their VPC.

func ApplyBlockDeletesInCloud

func ApplyBlockDeletesInCloud(ctx context.Context, s store.Storer, conn *store.CloudConnection) error

ApplyBlockDeletesInCloud deletes in the cloud any blocks that were soft-deleted in the app (IPAM conflict resolution). Run after ApplyAllocationDeletesInCloud so subnets are deleted before their VPC.

func ApplyPoolDeletesInCloud

func ApplyPoolDeletesInCloud(ctx context.Context, s store.Storer, conn *store.CloudConnection) error

ApplyPoolDeletesInCloud deletes in the cloud any pools that were soft-deleted in the app (IPAM conflict resolution). After each successful cloud delete, the pool row is permanently removed from the store.

func List

func List() []string

List returns all registered provider IDs.

func PushAllocationsToCloud

func PushAllocationsToCloud(ctx context.Context, s store.Storer, conn *store.CloudConnection) error

PushAllocationsToCloud pushes app allocations (in synced blocks with no external_id yet) to the cloud for read-write connections.

func PushBlocksToCloud

func PushBlocksToCloud(ctx context.Context, s store.Storer, conn *store.CloudConnection) error

PushBlocksToCloud pushes app blocks (in synced pools with no external_id yet) to the cloud for read-write connections.

func PushPoolsToCloud

func PushPoolsToCloud(ctx context.Context, s store.Storer, conn *store.CloudConnection, targetEnvID uuid.UUID) error

PushPoolsToCloud pushes app pools (in targetEnvID with no external_id yet) to the cloud for read-write connections. targetEnvID is the connection's target environment (e.g. from provider config); pass uuid.Nil to skip.

func Register

func Register(p CloudProvider)

Register registers a cloud provider by its ProviderID(). It is typically called from init() of provider packages (e.g. internal/integrations/aws).

func SyncAllocations

func SyncAllocations(ctx context.Context, s store.Storer, connID uuid.UUID, syncedBlocks []*network.Block) error

SyncAllocations runs allocation sync for a connection when the provider supports it. syncedBlocks should be the list of blocks for this connection (e.g. VPCs) from the store.

func SyncBlocks

func SyncBlocks(ctx context.Context, s store.Storer, connID uuid.UUID) error

SyncBlocks runs block sync for a connection using its registered provider and applies diffs to the store.

func SyncPools

func SyncPools(ctx context.Context, s store.Storer, connID uuid.UUID) error

SyncPools runs pool sync for a connection using its registered provider and applies diffs to the store. Returns an error if the provider is not registered or sync fails.

Types

type AllocationSyncResult

type AllocationSyncResult struct {
	Create             []*network.Allocation
	Update             []*network.Allocation // must have Id set (existing app allocation)
	CurrentExternalIDs []string              // external IDs that exist in the cloud after this sync; allocations for this connection not in this set are cleared (IPAM) or deleted
}

AllocationSyncResult holds the result of an allocation sync: allocations to create or update, and the set of allocation external IDs still in the cloud (for pruning).

type BlockSyncResult

type BlockSyncResult struct {
	Create             []*network.Block
	Update             []*network.Block // must have ID set (existing app block)
	CurrentExternalIDs []string         // external IDs that exist in the cloud after this sync; blocks for this connection not in this set are deleted
}

BlockSyncResult holds the result of a block sync: blocks to create or update, and the set of block external IDs still present in the cloud (for pruning removed blocks).

type CloudProvider

type CloudProvider interface {
	// ProviderID returns the provider identifier, e.g. "aws", "azure", "gcp".
	ProviderID() string
	// SupportsPools returns true if this provider can sync pools (e.g. AWS IPAM pools).
	SupportsPools() bool
	// SupportsBlocks returns true if this provider can sync blocks (e.g. AWS allocations → blocks).
	SupportsBlocks() bool
	// SupportsAllocations returns true if this provider can sync allocations (e.g. AWS VPC subnets → app allocations).
	SupportsAllocations() bool
	// SyncPools discovers pools from the cloud and returns create/update diffs for the app store.
	SyncPools(ctx context.Context, conn *store.CloudConnection) (*PoolSyncResult, error)
	// SyncBlocks discovers allocations/resources from the cloud and returns create/update diffs for blocks.
	// Store is passed so providers can resolve cloud resource IDs to app pool/block IDs (e.g. AWS pool external_id -> app pool id).
	SyncBlocks(ctx context.Context, conn *store.CloudConnection, s store.Storer) (*BlockSyncResult, error)
	// SyncAllocations discovers subnets/resources from the cloud and returns create/update diffs for allocations.
	// syncedBlocks are the app blocks for this connection (e.g. VPCs) so the provider knows block names and external IDs.
	SyncAllocations(ctx context.Context, conn *store.CloudConnection, s store.Storer, syncedBlocks []*network.Block) (*AllocationSyncResult, error)
}

CloudProvider is the interface that cloud integrations (AWS, Azure, GCP) implement. Sync methods return diffs that the orchestrator applies to the store.

func Get

func Get(id string) CloudProvider

Get returns the provider for the given ID, or nil if not registered.

type ConnectionWithEnvMapping

type ConnectionWithEnvMapping interface {
	// EnvironmentIDForScope returns the app environment ID to use for the given cloud scope/region.
	// Returns uuid.Nil if not configured.
	EnvironmentIDForScope(conn *store.CloudConnection, scopeOrRegion string) uuid.UUID
}

ConnectionWithEnvMapping is optional: when a provider needs to map cloud scope/region to app environment.

type PoolSyncResult

type PoolSyncResult struct {
	Create             []*network.Pool
	Update             []*network.Pool // must have ID set (existing app pool)
	CurrentExternalIDs []string        // external IDs that exist in the cloud after this sync; pools for this connection not in this set are deleted
}

PoolSyncResult holds the result of a pool sync: pools to create or update, and the set of external IDs still present in the cloud (for pruning removed pools).

type PushProvider

type PushProvider interface {
	CloudProvider
	// SupportsPush returns true if this provider can push create/update to the cloud.
	SupportsPush() bool
	// CreatePoolInCloud creates a pool in the cloud and returns its external ID.
	// parentExternalID is the parent pool's external ID when creating a sub-pool; empty for top-level.
	CreatePoolInCloud(ctx context.Context, conn *store.CloudConnection, pool *network.Pool, parentExternalID string) (externalID string, err error)
	// DeletePoolInCloud deletes the pool in the cloud (e.g. when IPAM conflict resolution and user deleted the pool in the app).
	DeletePoolInCloud(ctx context.Context, conn *store.CloudConnection, externalID string) error
	// AllocateBlockInCloud allocates CIDR from the pool to a resource (e.g. VPC) and returns the block's external ID.
	AllocateBlockInCloud(ctx context.Context, conn *store.CloudConnection, poolExternalID string, block *network.Block) (externalID string, err error)
	// CreateAllocationInCloud creates a subnet/allocation in the cloud and returns its external ID.
	CreateAllocationInCloud(ctx context.Context, conn *store.CloudConnection, blockExternalID string, alloc *network.Allocation) (externalID string, err error)
	// DeleteBlockInCloud deletes the block in the cloud (e.g. VPC) when IPAM conflict resolution and user deleted the block in the app.
	DeleteBlockInCloud(ctx context.Context, conn *store.CloudConnection, externalID string) error
	// DeleteAllocationInCloud deletes the allocation in the cloud (e.g. subnet) when IPAM conflict resolution and user deleted the allocation in the app.
	DeleteAllocationInCloud(ctx context.Context, conn *store.CloudConnection, externalID string) error
}

PushProvider is optional: when a provider supports bi-directional sync (read_write mode). Used when connection.SyncMode == "read_write" to push app changes to the cloud.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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