refactor: update deployment plan structure to use typed volume and service operations

This commit is contained in:
Pasha Sviderski
2026-03-16 17:54:01 +10:00
parent 940732e91c
commit 838839a7e5
6 changed files with 74 additions and 49 deletions
+6 -9
View File
@@ -14,7 +14,6 @@ import (
"github.com/psviderski/uncloud/pkg/client"
"github.com/psviderski/uncloud/pkg/client/compose"
"github.com/psviderski/uncloud/pkg/client/deploy"
"github.com/psviderski/uncloud/pkg/client/deploy/operation"
"github.com/spf13/cobra"
)
@@ -170,7 +169,7 @@ func runDeploy(ctx context.Context, uncli *cli.CLI, opts deployOptions) error {
return fmt.Errorf("plan deployment: %w", err)
}
if len(plan.Operations) == 0 {
if plan.IsEmpty() {
fmt.Println("Services are up to date.")
return nil
}
@@ -206,14 +205,12 @@ func runDeploy(ctx context.Context, uncli *cli.CLI, opts deployOptions) error {
}, uncli.ProgressOut(), "Deploying services")
}
func printPlan(ctx context.Context, cli *client.Client, plan operation.SequenceOperation) error {
for _, op := range plan.Operations {
svcPlan, ok := op.(*deploy.Plan)
if !ok {
fmt.Println("- " + op.Format(nil))
continue
}
func printPlan(ctx context.Context, cli *client.Client, plan compose.Plan) error {
for _, op := range plan.Volumes {
fmt.Println("- " + op.Format(nil))
}
for _, svcPlan := range plan.Services {
svc, err := cli.InspectService(ctx, svcPlan.ServiceID)
if err != nil && !errors.Is(err, api.ErrNotFound) {
return fmt.Errorf("inspect service: %w", err)