refactor: postpone spec resolver initialisation when creating Deployment

This commit is contained in:
Pavel Sviderski
2025-03-24 21:56:30 +10:00
parent 2d923380a3
commit 58b51b974c
10 changed files with 48 additions and 90 deletions
+2 -5
View File
@@ -1,7 +1,6 @@
package client
import (
"context"
"fmt"
"github.com/Masterminds/semver"
"github.com/distribution/reference"
@@ -23,9 +22,7 @@ var caddyImageTagRegex = regexp.MustCompile(`^2\.\d+\.\d+$`)
// NewCaddyDeployment creates a new deployment for a Caddy reverse proxy service.
// The service is deployed in global mode to all machines in the cluster. If the image is not provided, the latest
// version of the official Caddy Docker image is used.
func (cli *Client) NewCaddyDeployment(
ctx context.Context, image string, filter deploy.MachineFilter,
) (*deploy.Deployment, error) {
func (cli *Client) NewCaddyDeployment(image string, filter deploy.MachineFilter) (*deploy.Deployment, error) {
latest, err := LatestCaddyImage()
if err != nil {
return nil, fmt.Errorf("look up latest Caddy image: %w", err)
@@ -59,7 +56,7 @@ func (cli *Client) NewCaddyDeployment(
},
}
return cli.NewDeployment(ctx, spec, &deploy.RollingStrategy{MachineFilter: filter})
return cli.NewDeployment(spec, &deploy.RollingStrategy{MachineFilter: filter}), nil
}
// LatestCaddyImage returns the latest image of the official Caddy Docker image on Docker Hub.