chore: caddy client to get caddy config

This commit is contained in:
Pasha Sviderski
2025-08-22 15:58:21 +10:00
parent 75fdbaf2f4
commit 3cda5cc564
6 changed files with 55 additions and 7 deletions
+7 -1
View File
@@ -23,7 +23,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(image string, placement api.Placement) (*deploy.Deployment, error) {
func (cli *Client) NewCaddyDeployment(image, config string, placement api.Placement) (*deploy.Deployment, error) {
if image == "" {
latest, err := LatestCaddyImage()
if err != nil {
@@ -72,6 +72,12 @@ func (cli *Client) NewCaddyDeployment(image string, placement api.Placement) (*d
},
}
if config != "" {
spec.Caddy = &api.CaddySpec{
Config: config,
}
}
return cli.NewDeployment(spec, nil), nil
}
+2
View File
@@ -23,6 +23,7 @@ type Client struct {
// Methods such as Reset or Inspect are ambiguous in the context of a machine+cluster client.
pb.MachineClient
pb.ClusterClient
Caddy pb.CaddyClient
// Docker is a namespaced client for the Docker service to distinguish Uncloud-specific service container operations
// from generic Docker operations.
Docker *docker.Client
@@ -50,6 +51,7 @@ func New(ctx context.Context, connector Connector) (*Client, error) {
c.MachineClient = pb.NewMachineClient(c.conn)
c.ClusterClient = pb.NewClusterClient(c.conn)
c.Caddy = pb.NewCaddyClient(c.conn)
c.Docker = docker.NewClient(c.conn)
return c, nil
}