sync

package
v0.19.1139 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultStateVersion is the current version of the state format
	DefaultStateVersion string = "v1"
)

Variables

This section is empty.

Functions

func RejectDockerBuildComponentsForFeature added in v0.19.1043

func RejectDockerBuildComponentsForFeature(cfg *config.AppConfig) error

Types

type ActionState added in v0.19.850

type ActionState struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

ActionState represents an action in the sync state

type ComponentState

type ComponentState struct {
	Name     string                  `json:"name"`
	ID       string                  `json:"id"`
	ConfigID string                  `json:"config_id"`
	Type     models.AppComponentType `json:"type"`
	Checksum string                  `json:"checksum"`
}

ComponentState represents the synchronized state of a component. This is stored in the app config's state field as JSON to track what was synced in each config version.

type InstallSyncResult added in v0.19.1091

type InstallSyncResult struct {
	InstallID   string     `json:"install_id"`
	InstallName string     `json:"install_name"`
	Created     bool       `json:"created"`
	Changed     bool       `json:"changed"`
	Diff        *diff.Diff `json:"diff,omitempty"`
}

type Result added in v0.19.1102

type Result struct {
	ComponentsScheduled []ComponentState `json:"components_scheduled,omitempty"`

	// Queue provisioning is deferred to the caller so no Temporal workflow starts pre-commit.
	ComponentsCreated []string `json:"components_created,omitempty"`

	// Queue provisioning is deferred to the caller so no Temporal workflow starts pre-commit.
	AppBranchesCreated []string `json:"app_branches_created,omitempty"`

	// Orphaned* map name to ID for resources dropped since the previous config.
	OrphanedComponents map[string]string `json:"orphaned_components,omitempty"`
	OrphanedActions    map[string]string `json:"orphaned_actions,omitempty"`
	OrphanedRunbooks   map[string]string `json:"orphaned_runbooks,omitempty"`
}

Result carries sync outcomes persisted in the state so a client polling the app config can report scheduled builds and orphaned resources.

type RunbookState added in v0.19.974

type RunbookState struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

RunbookState represents a runbook in the sync state

type State added in v0.19.850

type State struct {
	Version string `json:"version"`

	CfgID           string           `json:"config_id"`
	AppID           string           `json:"app_id"`
	InstallerID     string           `json:"installer_id"`
	RunnerConfigID  string           `json:"runner_config_id"`
	SandboxConfigID string           `json:"sandbox_config_id"`
	InputConfigID   string           `json:"input_config_id"`
	Components      []ComponentState `json:"components"`
	Actions         []ActionState    `json:"actions"`
	Runbooks        []RunbookState   `json:"runbooks"`

	Result *Result `json:"result,omitempty"`
}

State represents the synchronized state of an app config. This is stored as JSON in the app_configs.state column to track what was synced in each config version.

type SyncAPIErr

type SyncAPIErr struct {
	Resource string
	Err      error
}

func (SyncAPIErr) Error

func (s SyncAPIErr) Error() string

type SyncErr

type SyncErr struct {
	Resource    string
	Description string
}

func (SyncErr) Error

func (s SyncErr) Error() string

type SyncInternalErr

type SyncInternalErr struct {
	Description string
	Err         error
}

func (SyncInternalErr) Error

func (s SyncInternalErr) Error() string

type Syncer added in v0.19.850

type Syncer interface {
	// Sync performs the full synchronization operation, creating or updating
	// app configs, components, and their configurations.
	//
	// The context must contain org and account information set via cctx.SetOrgContext()
	// and cctx.SetAccountContext() before calling this method.
	//
	// Returns an error if the sync operation fails at any step.
	Sync(ctx context.Context) error

	// GetAppConfigID returns the ID of the app config that was created or updated
	// during the most recent sync operation.
	//
	// This should only be called after a successful Sync() operation.
	GetAppConfigID() string

	// GetComponentStateIds returns the IDs of all components that were synced
	// during the most recent sync operation.
	//
	// This should only be called after a successful Sync() operation.
	GetComponentStateIds() []string

	// GetActionStateIds returns the IDs of all actions that were synced
	// during the most recent sync operation.
	//
	// This should only be called after a successful Sync() operation.
	GetActionStateIds() []string

	// GetComponentsScheduled returns the components that need a build as a
	// result of the most recent sync — those whose config changed. It is empty
	// unless the sync was configured to own build scheduling.
	//
	// The set is persisted in State.Result so the CLI, which only sees the app
	// config it polls, can wait on those builds.
	// This should only be called after a successful Sync() operation.
	GetComponentsScheduled() []ComponentState

	GetComponentsCreated() []string

	GetAppBranchesCreated() []string

	// OrphanedComponents returns a map of component names to IDs for components
	// that existed in the previous config but are no longer in the current config.
	//
	// This allows consumers to notify users about removed components.
	// This should only be called after a successful Sync() operation.
	OrphanedComponents() map[string]string

	// OrphanedActions returns a map of action names to IDs for actions that
	// existed in the previous config but are no longer in the current config.
	//
	// This allows consumers to notify users about removed actions.
	// This should only be called after a successful Sync() operation.
	OrphanedActions() map[string]string

	// GetRunbookStateIds returns the IDs of all runbooks that were synced
	// during the most recent sync operation.
	//
	// This should only be called after a successful Sync() operation.
	GetRunbookStateIds() []string

	// OrphanedRunbooks returns a map of runbook names to IDs for runbooks that
	// existed in the previous config but are no longer in the current config.
	//
	// This allows consumers to notify users about removed runbooks.
	// This should only be called after a successful Sync() operation.
	OrphanedRunbooks() map[string]string

	// SyncInstall syncs a single install config to the database.
	// If the install does not exist, it is created. If it exists and has
	// changed, it is updated (inputs, labels, config, component toggles).
	SyncInstall(ctx context.Context, install *config.Install) (*InstallSyncResult, error)
}

Syncer defines the interface for syncing app configurations to a backing store.

The only implementation is the database-backed syncer in services/ctl-api/internal/pkg/config/syncer. Clients do not sync directly: they push a config to the API in its intermediate form and ask the API to apply it. This interface lives here because the state and error types it works with are shared with those clients.

Jump to

Keyboard shortcuts

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