refactor: embed ServiceSpecResolver into Deployment to handle spec only there

This commit is contained in:
Pavel Sviderski
2025-03-24 20:10:28 +10:00
parent 7a9d0cf9db
commit 3910101a88
17 changed files with 191 additions and 148 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ func runDeploy(ctx context.Context, uncli *cli.CLI, opts deployOptions) error {
filter = machineFilter(machines)
}
d, err := clusterClient.NewCaddyDeployment(opts.image, filter)
d, err := clusterClient.NewCaddyDeployment(ctx, opts.image, filter)
if err != nil {
return fmt.Errorf("create caddy deployment: %w", err)
}
+1 -1
View File
@@ -40,7 +40,7 @@ func NewDeployCommand() *cobra.Command {
}
cmd.Flags().StringSliceVarP(&opts.files, "file", "f", nil,
"One or more Compose files to deploy services from. (default compose.yaml)")
"One or more Compose files to deploy services from. (default compose-ports-long.yaml)")
cmd.Flags().StringVarP(&opts.cluster, "cluster", "c", "",
"Name of the cluster to deploy to (default is the current cluster)")
+1 -1
View File
@@ -136,7 +136,7 @@ func add(ctx context.Context, uncli *cli.CLI, remoteMachine cli.RemoteMachine, o
}
}
d, err := machineClient.NewCaddyDeployment(caddyImage, filter)
d, err := machineClient.NewCaddyDeployment(ctx, caddyImage, filter)
if err != nil {
return fmt.Errorf("create caddy deployment: %w", err)
}
+3 -3
View File
@@ -4,14 +4,14 @@ import (
"context"
"fmt"
"github.com/docker/compose/v2/pkg/progress"
"github.com/spf13/cobra"
"net/netip"
"github.com/psviderski/uncloud/cmd/uncloud/caddy"
"github.com/psviderski/uncloud/cmd/uncloud/dns"
"github.com/psviderski/uncloud/internal/cli"
"github.com/psviderski/uncloud/internal/cli/config"
"github.com/psviderski/uncloud/internal/machine/api/pb"
"github.com/psviderski/uncloud/internal/machine/cluster"
"github.com/spf13/cobra"
"net/netip"
)
type initOptions struct {
@@ -132,7 +132,7 @@ func initCluster(ctx context.Context, uncli *cli.CLI, remoteMachine *cli.RemoteM
}
if !opts.noCaddy {
d, err := client.NewCaddyDeployment("", nil)
d, err := client.NewCaddyDeployment(ctx, "", nil)
if err != nil {
return fmt.Errorf("create caddy deployment: %w", err)
}
+5 -1
View File
@@ -89,7 +89,11 @@ func scale(ctx context.Context, uncli *cli.CLI, opts scaleOptions) error {
spec.Replicas = opts.replicas
deployment := clusterClient.NewDeployment(spec, nil)
deployment, err := clusterClient.NewDeployment(ctx, spec, nil)
if err != nil {
return fmt.Errorf("create deployment: %w", err)
}
plan, err := deployment.Plan(ctx)
if err != nil {
return fmt.Errorf("plan deployment: %w", err)