Documentation
¶
Index ¶
Constants ¶
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
Types ¶
type ActionState ¶ added in v0.19.850
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 Result ¶ added in v0.19.1102
type Result struct {
ComponentsScheduled []ComponentState `json:"components_scheduled,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
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 ¶
func (SyncAPIErr) Error ¶
func (s SyncAPIErr) Error() string
type SyncInternalErr ¶
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
// 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.