Two leaves of the daemon package that carry no back-references to Daemon move out: - internal/daemon/opstate: generic Registry[T AsyncOp]. The AsyncOp interface methods are capitalised (ID, IsDone, UpdatedAt, Cancel); vmCreateOperationState and imageBuildOperationState implement it. - internal/daemon/dmsnap: Create, Cleanup, Remove plus the Handles type for device-mapper snapshot lifecycle. Takes an explicit Runner interface. The daemon-package snapshot.go keeps thin forwarders and a type alias so existing call sites and tests are untouched. Skipped on purpose: tap_pool has too many Daemon-scoped dependencies (config, store, closing, createTap) for a clean extraction at this stage; nat.go is already a thin facade over internal/hostnat; dns_routing.go tests tightly couple to package internals, so extraction would be more churn than payoff. Each can be revisited when a subsystem-level refactor forces the boundary. All tests green. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
23 lines
703 B
Go
23 lines
703 B
Go
package daemon
|
|
|
|
import (
|
|
"context"
|
|
|
|
"banger/internal/daemon/dmsnap"
|
|
)
|
|
|
|
// dmSnapshotHandles is retained as a package-local alias for the subpackage
|
|
// type so existing call sites and tests read naturally.
|
|
type dmSnapshotHandles = dmsnap.Handles
|
|
|
|
func (d *Daemon) createDMSnapshot(ctx context.Context, rootfsPath, cowPath, dmName string) (dmSnapshotHandles, error) {
|
|
return dmsnap.Create(ctx, d.runner, rootfsPath, cowPath, dmName)
|
|
}
|
|
|
|
func (d *Daemon) cleanupDMSnapshot(ctx context.Context, handles dmSnapshotHandles) error {
|
|
return dmsnap.Cleanup(ctx, d.runner, handles)
|
|
}
|
|
|
|
func (d *Daemon) removeDMSnapshot(ctx context.Context, target string) error {
|
|
return dmsnap.Remove(ctx, d.runner, target)
|
|
}
|