deploymentsv1

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyReconciliationRequestPayload added in v0.2.0

type ApplyReconciliationRequestPayload struct {
	resolve.BlueprintDocumentInfo
	// ResourceActions specifies the actions to take for each resource.
	ResourceActions []ResourceReconcileActionPayload `json:"resourceActions,omitempty"`
	// LinkActions specifies the actions to take for each link.
	LinkActions []LinkReconcileActionPayload `json:"linkActions,omitempty"`
	// Config values for the reconciliation apply
	// that will be used in plugins.
	Config *types.BlueprintOperationConfig `json:"config" validate:"required"`
}

ApplyReconciliationRequestPayload represents the payload for applying reconciliation actions to a blueprint instance.

type AutoRollbackType added in v0.2.0

type AutoRollbackType int

AutoRollbackType specifies the type of automatic rollback to perform.

const (
	// AutoRollbackTypeNone indicates no auto-rollback should be performed.
	AutoRollbackTypeNone AutoRollbackType = iota
	// AutoRollbackTypeDestroy indicates the failed deployment should be rolled back
	// by destroying partially-created resources (used for DeployFailed).
	AutoRollbackTypeDestroy
	// AutoRollbackTypeRevert indicates the failed update/destroy should be rolled back
	// by reverting to the previous state using a reverse changeset.
	AutoRollbackTypeRevert
)

type BlueprintInstanceDestroyRequestPayload

type BlueprintInstanceDestroyRequestPayload struct {
	// The ID of the change set to use to destroy the blueprint instance.
	// When destroying a blueprint instance,
	// a change set is used instead of the destroy process re-computing the changes
	// that need to be applied.
	ChangeSetID string `json:"changeSetId" validate:"required"`
	// If true, destroying the blueprint instance will be treated as a rollback
	// for the initial deployment of the blueprint instance.
	// This will usually be set to true when rolling back a recent first time
	// deployment that needs to be rolled back due to failure in a parent
	// blueprint instance.
	AsRollback bool `json:"asRollback"`
	// Force continues the destroy operation even if individual resource/link/child
	// destruction fails, and removes the blueprint instance record from state
	// regardless of whether all resources were successfully destroyed.
	// This is useful for removing instances where underlying resources were manually
	// deleted or when a provider is unavailable.
	Force bool `json:"force"`
	// Config values for the destroy process
	// that will be used in plugins.
	Config *types.BlueprintOperationConfig `json:"config"`
}

BlueprintInstanceDestroyRequestPayload represents the payload for destroying a blueprint instance.

type BlueprintInstanceRequestPayload

type BlueprintInstanceRequestPayload struct {
	resolve.BlueprintDocumentInfo
	// The user-defined name for the blueprint instance.
	// This is required when creating a new blueprint instance and must be unique.
	// This should be left empty when updating an existing instance.
	InstanceName string `json:"instanceName"`
	// The ID of the change set to use to deploy the blueprint instance.
	// When deploying blueprint instances,
	// a change set is used instead of the deployment process re-computing the changes
	// that need to be applied.
	// The source blueprint document is still required in addition to a change set to finish
	// resolving substitutions that can only be resolved at deploy time and for deployment
	// orchestration.
	// The source blueprint document is not used to compute changes at the deployment stage.
	ChangeSetID string `json:"changeSetId" validate:"required"`
	// If true, and a new blueprint instance is being created,
	// the creation of the blueprint instance will be treated as a rollback operation
	// for a previously destroyed blueprint instance.
	// If true, and an existing blueprint instance is being updated,
	// the update will be treated as a rollback operation for the previous state.
	AsRollback bool `json:"asRollback"`
	// If true, the deployment will automatically rollback on failure.
	// Auto-rollback is supported for:
	//
	// - New deployments (DeployFailed): Destroys partially created resources,
	//   ensuring a clean state where users can fix issues and retry.
	//
	// - Updates (UpdateFailed): Reverts to the previous instance state by
	//   generating and deploying a reverse changeset that undoes the failed changes.
	//
	// - Destroys (DestroyFailed): Recreates destroyed resources from the previous
	//   instance state using a reverse changeset.
	//
	// Rollback operations have auto-rollback disabled to prevent infinite loops.
	AutoRollback bool `json:"autoRollback"`
	// Force bypasses state validation checks that prevent deployment when the instance
	// is already in an active state (e.g., Deploying, Updating).
	// This is an escape hatch for recovering from stuck states where the instance
	// is in an inconsistent state due to a crash or unexpected termination.
	Force bool `json:"force"`
	// Config values for the deployment process
	// that will be used in plugins and passed into the blueprint.
	Config *types.BlueprintOperationConfig `json:"config"`
}

BlueprintInstanceRequestPayload represents the payload for creating and updating blueprint instances which in turn starts the deployment process for new or existing blueprint instances.

type CheckReconciliationRequestPayload added in v0.2.0

type CheckReconciliationRequestPayload struct {
	resolve.BlueprintDocumentInfo
	// Scope controls which elements to check.
	// Valid values: "all" (default), "interrupted", "specific"
	Scope string `json:"scope"`
	// ResourceNames specifies which resources to check when Scope is "specific".
	// Ignored for other scopes.
	ResourceNames []string `json:"resourceNames,omitempty"`
	// LinkNames specifies which links to check when Scope is "specific".
	// Ignored for other scopes.
	LinkNames []string `json:"linkNames,omitempty"`
	// IncludeChildren controls whether to recursively check child blueprints.
	// If nil or not provided, defaults to true.
	IncludeChildren *bool `json:"includeChildren,omitempty"`
	// ChildPath limits the scope to resources/links within a specific child blueprint path.
	// Used when Scope is "specific".
	// Format: "childA" for first level, "childA.childB" for nested.
	ChildPath string `json:"childPath,omitempty"`
	// Config values for the reconciliation check
	// that will be used in plugins.
	Config *types.BlueprintOperationConfig `json:"config" validate:"required"`
}

CheckReconciliationRequestPayload represents the payload for checking reconciliation status of a blueprint instance.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller handles deployment-related HTTP requests including change staging and deployment events over Server-Sent Events (SSE).

func NewController

func NewController(
	changesetRetentionPeriod time.Duration,
	reconciliationResultsRetentionPeriod time.Duration,
	deploymentTimeout time.Duration,
	drainTimeout time.Duration,
	deps *typesv1.Dependencies,
) *Controller

NewController creates a new deployments Controller instance with the provided dependencies.

func (*Controller) ApplyReconciliationHandler added in v0.2.0

func (c *Controller) ApplyReconciliationHandler(
	w http.ResponseWriter,
	r *http.Request,
)

ApplyReconciliationHandler is the handler for the POST /deployments/instances/{id}/reconciliation/apply endpoint that applies reconciliation actions to resolve drift or interrupted state.

func (*Controller) CheckReconciliationHandler added in v0.2.0

func (c *Controller) CheckReconciliationHandler(
	w http.ResponseWriter,
	r *http.Request,
)

CheckReconciliationHandler is the handler for the POST /deployments/instances/{id}/reconciliation/check endpoint that checks for drift and interrupted state in a blueprint instance.

func (*Controller) CleanupChangesetsHandler

func (c *Controller) CleanupChangesetsHandler(
	w http.ResponseWriter,
	r *http.Request,
)

CleanupChangesetsHandler is the handler for the POST /deployments/changes/cleanup endpoint that cleans up change sets that are older than the configured retention period.

func (*Controller) CleanupReconciliationResultsHandler added in v0.2.0

func (c *Controller) CleanupReconciliationResultsHandler(
	w http.ResponseWriter,
	r *http.Request,
)

CleanupReconciliationResultsHandler is the handler for the POST /deployments/reconciliation-results/cleanup endpoint that cleans up reconciliation results that are older than the configured retention period.

func (*Controller) CreateBlueprintInstanceHandler

func (c *Controller) CreateBlueprintInstanceHandler(
	w http.ResponseWriter,
	r *http.Request,
)

CreateBlueprintInstanceHandler is the handler for the POST /deployments/instances endpoint that creates a new blueprint instance and begins the deployment process for the new blueprint instance.

func (*Controller) CreateChangesetHandler

func (c *Controller) CreateChangesetHandler(
	w http.ResponseWriter,
	r *http.Request,
)

CreateChangesetHandler is the handler for the POST /deployments/changes endpoint that creates a new change set and starts the change staging process.

func (*Controller) DestroyBlueprintInstanceHandler

func (c *Controller) DestroyBlueprintInstanceHandler(
	w http.ResponseWriter,
	r *http.Request,
)

DestroyBlueprintInstanceHandler is the handler for the POST /deployments/instances/{id}/destroy endpoint that destroys a blueprint instance. This is a `POST` request as the destroy operation relies on inputs including configuration values that need to be provided in the request body. The {id} path parameter can be either an instance ID or an instance name.

func (*Controller) GetBlueprintInstanceExportsHandler

func (c *Controller) GetBlueprintInstanceExportsHandler(
	w http.ResponseWriter,
	r *http.Request,
)

GetBlueprintInstanceExportsHandler is the handler for the GET /deployments/instances/{id}/exports endpoint that retrieves the exports of a blueprint instance. The {id} path parameter can be either an instance ID or an instance name.

func (*Controller) GetBlueprintInstanceHandler

func (c *Controller) GetBlueprintInstanceHandler(
	w http.ResponseWriter,
	r *http.Request,
)

GetBlueprintInstanceHandler is the handler for the GET /deployments/instances/{id} endpoint that retrieves the full state of a blueprint instance. The {id} path parameter can be either an instance ID or an instance name.

func (*Controller) GetChangesetHandler

func (c *Controller) GetChangesetHandler(
	w http.ResponseWriter,
	r *http.Request,
)

GetChangesetHandler is the handler for the GET /deployments/changes/{id} endpoint that retrieves a change set including its status and changes if available.

func (*Controller) GetChangesetsCleanupStatusHandler added in v0.3.0

func (c *Controller) GetChangesetsCleanupStatusHandler(
	w http.ResponseWriter,
	r *http.Request,
)

GetChangesetsCleanupStatusHandler is the handler for the GET /deployments/changes/cleanup/{id} endpoint that retrieves the status of a cleanup operation.

func (*Controller) GetReconciliationResultsCleanupStatusHandler added in v0.3.0

func (c *Controller) GetReconciliationResultsCleanupStatusHandler(
	w http.ResponseWriter,
	r *http.Request,
)

GetReconciliationResultsCleanupStatusHandler is the handler for the GET /deployments/reconciliation-results/cleanup/{id} endpoint that retrieves the status of a cleanup operation.

func (*Controller) ListBlueprintInstancesHandler added in v0.2.0

func (c *Controller) ListBlueprintInstancesHandler(
	w http.ResponseWriter,
	r *http.Request,
)

ListBlueprintInstancesHandler is the handler for the GET /deployments/instances endpoint that retrieves a paginated list of blueprint instances.

func (*Controller) Shutdown added in v0.6.0

func (c *Controller) Shutdown(ctx context.Context)

Shutdown cancels every in-flight deploy/destroy/rollback context and waits for each goroutine to exit. Cancelling each context drives the library's drain path, which persists a terminal *_FAILED instance status and releases the in-progress guard so subsequent deploys can proceed without Force. Returns when all registered ops have finished or when ctx is cancelled, whichever is first. Callers should pass a context with a deadline so a wedged goroutine cannot block process exit indefinitely.

func (*Controller) StreamChangesetEventsHandler

func (c *Controller) StreamChangesetEventsHandler(w http.ResponseWriter, r *http.Request)

StreamChangesetEventsHandler is the handler for the GET /deployments/changes/{id}/stream endpoint that streams change staging events to the client using Server-Sent Events (SSE).

func (*Controller) StreamDeploymentEventsHandler

func (c *Controller) StreamDeploymentEventsHandler(w http.ResponseWriter, r *http.Request)

StreamDeploymentEventsHandler is the handler for the GET /deployments/instances/{id}/stream endpoint that streams deployment events to the client using Server-Sent Events (SSE). The {id} path parameter can be either an instance ID or an instance name.

func (*Controller) UpdateBlueprintInstanceHandler

func (c *Controller) UpdateBlueprintInstanceHandler(
	w http.ResponseWriter,
	r *http.Request,
)

UpdateBlueprintInstanceHandler is the handler for the PATCH /deployments/instances/{id} endpoint that updates an existing blueprint instance and begins the deployment process for the updates described in the specified change set. The {id} path parameter can be either an instance ID or an instance name.

type CreateChangesetRequestPayload

type CreateChangesetRequestPayload struct {
	resolve.BlueprintDocumentInfo
	// The ID of an existing blueprint instance to stage changes for.
	// If this is not provided and an instance name is not provided,
	// a change set for a new blueprint instance deployment will be created.
	// This should be left empty if the `instanceName` field is provided.
	InstanceID string `json:"instanceId"`
	// The user-defined name of an existing blueprint instance to stage changes for.
	// If this is not provided an an instance ID is not provided, a change set for a new
	// blueprint instance deployment will be created.
	// This should be left empty if the `instanceId` field is provided.
	InstanceName string `json:"instanceName"`
	// If true, the change set will be created for a destroy operation.
	// This will only be used if the `instanceId` or `instanceName` fields are provided.
	// If this is not provided, the default value will be false.
	Destroy bool `json:"destroy"`
	// SkipDriftCheck, when true, skips drift detection during change staging.
	SkipDriftCheck bool `json:"skipDriftCheck"`
	// Config values for the change staging process
	// that will be used in plugins and passed into the blueprint.
	Config *types.BlueprintOperationConfig `json:"config"`
}

CreateChangesetRequestPayload represents the payload for creating a new change set and start a new change staging process.

type DriftBlockedResponse added in v0.2.0

type DriftBlockedResponse struct {
	// Message explains why the operation was blocked.
	Message string `json:"message"`
	// InstanceID is the ID of the blueprint instance.
	InstanceID string `json:"instanceId"`
	// ChangesetID is the ID of the changeset that detected drift (if applicable).
	ChangesetID string `json:"changesetId,omitempty"`
	// ReconciliationResult contains the full drift/interrupted state detection result.
	// This allows clients to see exactly what drifted without making a separate API call.
	ReconciliationResult *container.ReconciliationCheckResult `json:"reconciliationResult,omitempty"`
	// Hint provides guidance on how to proceed.
	Hint string `json:"hint"`
}

DriftBlockedResponse is returned when an operation is blocked due to drift detection.

type IntermediaryReconcileActionPayload added in v0.2.0

type IntermediaryReconcileActionPayload struct {
	// Action is the reconciliation action to apply.
	// Valid values: "accept_external", "update_status", "manual_cleanup_required"
	Action string `json:"action" validate:"required"`
	// ExternalState is required when Action is "accept_external".
	// This is the state that will be persisted.
	ExternalState *core.MappingNode `json:"externalState,omitempty"`
	// NewStatus is the status to set for the intermediary resource.
	NewStatus string `json:"newStatus" validate:"required"`
}

IntermediaryReconcileActionPayload specifies the action to take for an intermediary resource.

type LinkReconcileActionPayload added in v0.2.0

type LinkReconcileActionPayload struct {
	// LinkID is the unique identifier for the link.
	LinkID string `json:"linkId" validate:"required"`
	// ChildPath is the path to the child blueprint containing this link.
	// Empty for links in the parent blueprint.
	// Format: "childA" for first level, "childA.childB" for nested.
	ChildPath string `json:"childPath,omitempty"`
	// Action is the reconciliation action to apply.
	// Valid values: "accept_external", "update_status", "manual_cleanup_required"
	Action string `json:"action" validate:"required"`
	// NewStatus is the status to set for the link.
	NewStatus string `json:"newStatus" validate:"required"`
	// LinkDataUpdates contains updates to apply to link.Data when Action is
	// "accept_external". This is used to sync link.Data with
	// external resource state when drift is detected via ResourceDataMappings.
	// Key is the linkDataPath (e.g., "resourceA.handler"), value is the new external value.
	LinkDataUpdates map[string]*core.MappingNode `json:"linkDataUpdates,omitempty"`
	// IntermediaryActions specifies actions for each intermediary resource.
	// Key is the intermediary resource ID.
	IntermediaryActions map[string]*IntermediaryReconcileActionPayload `json:"intermediaryActions,omitempty"`
}

LinkReconcileActionPayload specifies the action to take for a link.

type ResourceReconcileActionPayload added in v0.2.0

type ResourceReconcileActionPayload struct {
	// ResourceID is the unique identifier for the resource.
	ResourceID string `json:"resourceId" validate:"required"`
	// ChildPath is the path to the child blueprint containing this resource.
	// Empty for resources in the parent blueprint.
	// Format: "childA" for first level, "childA.childB" for nested.
	ChildPath string `json:"childPath,omitempty"`
	// Action is the reconciliation action to apply.
	// Valid values: "accept_external", "update_status", "manual_cleanup_required"
	Action string `json:"action" validate:"required"`
	// ExternalState is required when Action is "accept_external".
	// This is the state that will be persisted.
	ExternalState *core.MappingNode `json:"externalState,omitempty"`
	// NewStatus is the status to set for the resource.
	NewStatus string `json:"newStatus" validate:"required"`
}

ResourceReconcileActionPayload specifies the action to take for a resource.

Jump to

Keyboard shortcuts

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