mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 03:53:33 +00:00
fix: skip validation for user-defined Caddy configs if caddy not running locally
This commit is contained in:
@@ -95,7 +95,11 @@ func NewCaddyfileGenerator(machineID string, validator CaddyfileValidator, log *
|
||||
// [service-a x-caddy]
|
||||
// ...
|
||||
// [service-z x-caddy]
|
||||
func (g *CaddyfileGenerator) Generate(ctx context.Context, records []store.ContainerRecord) (string, error) {
|
||||
//
|
||||
// If includeCustom is false, custom Caddy configs (x-caddy) are not included in the generated Caddyfile.
|
||||
func (g *CaddyfileGenerator) Generate(
|
||||
ctx context.Context, records []store.ContainerRecord, includeCustom bool,
|
||||
) (string, error) {
|
||||
containers := make([]api.ServiceContainer, len(records))
|
||||
for i, cr := range records {
|
||||
containers[i] = cr.Container
|
||||
@@ -113,6 +117,12 @@ func (g *CaddyfileGenerator) Generate(ctx context.Context, records []store.Conta
|
||||
return "", fmt.Errorf("generate base Caddyfile from service ports: %w", err)
|
||||
}
|
||||
|
||||
if !includeCustom {
|
||||
return fmt.Sprintf("%s\n%s\n"+
|
||||
"# NOTE: User-defined configs for services were skipped because Caddy is not running on this machine.\n",
|
||||
caddyfileHeader, caddyfile), nil
|
||||
}
|
||||
|
||||
upstreams := serviceUpstreams(containers)
|
||||
// Track validation errors for reporting.
|
||||
var configErrors []string
|
||||
|
||||
Reference in New Issue
Block a user