mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 03:53:33 +00:00
refactor: embed ServiceSpecResolver into Deployment to handle spec only there
This commit is contained in:
+8
-5
@@ -1,6 +1,7 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/distribution/reference"
|
||||
@@ -22,8 +23,10 @@ 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(image string, filter deploy.MachineFilter) (*deploy.Deployment, error) {
|
||||
latest, err := latestCaddyImage()
|
||||
func (cli *Client) NewCaddyDeployment(
|
||||
ctx context.Context, 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)
|
||||
}
|
||||
@@ -56,12 +59,12 @@ func (cli *Client) NewCaddyDeployment(image string, filter deploy.MachineFilter)
|
||||
},
|
||||
}
|
||||
|
||||
return cli.NewDeployment(spec, &deploy.RollingStrategy{MachineFilter: filter}), nil
|
||||
return cli.NewDeployment(ctx, spec, &deploy.RollingStrategy{MachineFilter: filter})
|
||||
}
|
||||
|
||||
// latestCaddyImage returns the latest image of the official Caddy Docker image on Docker Hub.
|
||||
// LatestCaddyImage returns the latest image of the official Caddy Docker image on Docker Hub.
|
||||
// The latest image is determined by the latest version tag 2.x.x.
|
||||
func latestCaddyImage() (reference.NamedTagged, error) {
|
||||
func LatestCaddyImage() (reference.NamedTagged, error) {
|
||||
repo, err := name.NewRepository(CaddyImage)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse image: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user