@@ -26,43 +26,43 @@ const (
2626 DeploymentFailure
2727)
2828
29- // DeploymentManager controls the versioned lifecycle of deployment operations.
30- //
31- // DMS semantics: CreateVersion atomically succeeds only if no other deployment
32- // is in progress and the returned version is exactly +1 to the latest closed
33- // version, providing serialized optimistic concurrency control. CompleteVersion
34- // records the outcome.
35- //
36- // Workspace-filesystem semantics: CreateVersion acquires the workspace lock
37- // file; CompleteVersion releases it. The returned version number is a placeholder
38- // (the lock file does not track a monotonic counter today).
39- type DeploymentManager interface {
40- // CreateVersion begins a new deployment for the given goal.
41- // Returns the version number assigned by the backend.
42- CreateVersion (ctx context.Context , goal Goal ) (int64 , error )
43-
44- // CompleteVersion finalizes the deployment version created by CreateVersion.
45- CompleteVersion (ctx context.Context , version int64 , status DeploymentStatus ) error
29+ // DeploymentLock manages the lifecycle of a bundle deployment.
30+ // The workspace-filesystem lock serializes concurrent deployments.
31+ // DMS version tracking will be added additively — see deployment_metadata_service.go.
32+ type DeploymentLock struct {
33+ wfs workspaceFilesystemLock
4634}
4735
48- // NewDeploymentManager returns a DeploymentManager backed by the workspace
49- // filesystem. Captures everything it needs from the bundle at construction time
50- // so the implementation does not retain a *bundle.Bundle reference. The
51- // workspace client is only initialized when locking is enabled to match the
52- // original lazy-init behavior.
53- func NewDeploymentManager (ctx context.Context , b * bundle.Bundle ) DeploymentManager {
36+ // NewDeploymentLock returns a DeploymentLock for the bundle.
37+ // Captures everything it needs from the bundle at construction time
38+ // so the lock does not retain a *bundle.Bundle reference. The
39+ // workspace client is only initialized when locking is enabled.
40+ func NewDeploymentLock (ctx context.Context , b * bundle.Bundle , goal Goal ) * DeploymentLock {
5441 enabled := b .Config .Bundle .Deployment .Lock .IsEnabled ()
55- l := & workspaceFilesystemLock {
56- user : b .Config .Workspace .CurrentUser .UserName ,
57- statePath : b .Config .Workspace .StatePath ,
58- enabled : enabled ,
59- force : b .Config .Bundle .Deployment .Lock .Force ,
60- reportPermissionError : func (ctx context.Context , path string ) diag.Diagnostics {
61- return permissions .ReportPossiblePermissionDenied (ctx , b , path )
42+ l := & DeploymentLock {
43+ wfs : workspaceFilesystemLock {
44+ user : b .Config .Workspace .CurrentUser .UserName ,
45+ statePath : b .Config .Workspace .StatePath ,
46+ enabled : enabled ,
47+ force : b .Config .Bundle .Deployment .Lock .Force ,
48+ goal : goal ,
49+ reportPermissionError : func (ctx context.Context , path string ) diag.Diagnostics {
50+ return permissions .ReportPossiblePermissionDenied (ctx , b , path )
51+ },
6252 },
6353 }
6454 if enabled {
65- l .client = b .WorkspaceClient (ctx )
55+ l .wfs . client = b .WorkspaceClient (ctx )
6656 }
6757 return l
6858}
59+
60+ // Acquire acquires the deployment lock.
61+ func (l * DeploymentLock ) Acquire (ctx context.Context ) error {
62+ return l .wfs .acquire (ctx )
63+ }
64+
65+ // Release releases the deployment lock.
66+ func (l * DeploymentLock ) Release (ctx context.Context , status DeploymentStatus ) error {
67+ return l .wfs .release (ctx , status )
68+ }
0 commit comments