mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
fix: skip validation for user-defined Caddy configs if caddy not running locally
This commit is contained in:
@@ -109,12 +109,20 @@ func filterHealthyContainers(containers []store.ContainerRecord) []store.Contain
|
||||
}
|
||||
|
||||
func (c *Controller) generateAndLoadCaddyfile(ctx context.Context, containers []store.ContainerRecord) {
|
||||
caddyfile, err := c.generateCaddyfile(ctx, containers)
|
||||
// Check if Caddy is available before attempting to generate and load config.
|
||||
caddyAvailable := c.client.IsAvailable(ctx)
|
||||
|
||||
caddyfile, err := c.generateCaddyfile(ctx, containers, caddyAvailable)
|
||||
if err != nil {
|
||||
c.log.Error("Failed to generate Caddyfile configuration.", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
if !caddyAvailable {
|
||||
c.log.Debug("Caddy is not running on this machine, skipping configuration load.", "path", c.caddyfilePath)
|
||||
return
|
||||
}
|
||||
|
||||
if err = c.client.Load(ctx, caddyfile); err != nil {
|
||||
c.log.Error("Failed to load new Caddy configuration into local Caddy instance.",
|
||||
"err", err, "path", c.caddyfilePath)
|
||||
@@ -123,8 +131,10 @@ func (c *Controller) generateAndLoadCaddyfile(ctx context.Context, containers []
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Controller) generateCaddyfile(ctx context.Context, containers []store.ContainerRecord) (string, error) {
|
||||
caddyfile, err := c.generator.Generate(ctx, containers)
|
||||
func (c *Controller) generateCaddyfile(
|
||||
ctx context.Context, containers []store.ContainerRecord, caddyAvailable bool,
|
||||
) (string, error) {
|
||||
caddyfile, err := c.generator.Generate(ctx, containers, caddyAvailable)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("generate Caddyfile: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user