cmd: Only validate config is proper JSON if config slice has data (#6250)

* cmd: fix error when running without config

* ci: add smoke test
This commit is contained in:
Mohammed Al Sahaf 2024-04-19 00:40:12 +03:00 committed by GitHub
parent c6673ad4d8
commit 8f87c5d993
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -101,6 +101,12 @@ jobs:
run: | run: |
go build -tags nobdger -trimpath -ldflags="-w -s" -v go build -tags nobdger -trimpath -ldflags="-w -s" -v
- name: Smoke test Caddy
working-directory: ./cmd/caddy
run: |
./caddy start
./caddy stop
- name: Publish Build Artifact - name: Publish Build Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:

View file

@ -199,7 +199,7 @@ func loadConfigWithLogger(logger *zap.Logger, configFile, adapterName string) ([
zap.Int("line", warn.Line)) zap.Int("line", warn.Line))
} }
config = adaptedConfig config = adaptedConfig
} else { } else if len(config) != 0 {
// validate that the config is at least valid JSON // validate that the config is at least valid JSON
err = json.Unmarshal(config, new(any)) err = json.Unmarshal(config, new(any))
if err != nil { if err != nil {