From 8f87c5d9938d64942f193a599a6d5472edeb15da Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Fri, 19 Apr 2024 00:40:12 +0300 Subject: [PATCH] cmd: Only validate config is proper JSON if config slice has data (#6250) * cmd: fix error when running without config * ci: add smoke test --- .github/workflows/ci.yml | 6 ++++++ cmd/main.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 309ef793..32da779b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,6 +101,12 @@ jobs: run: | 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 uses: actions/upload-artifact@v4 with: diff --git a/cmd/main.go b/cmd/main.go index ac9786fa..31a121aa 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -199,7 +199,7 @@ func loadConfigWithLogger(logger *zap.Logger, configFile, adapterName string) ([ zap.Int("line", warn.Line)) } config = adaptedConfig - } else { + } else if len(config) != 0 { // validate that the config is at least valid JSON err = json.Unmarshal(config, new(any)) if err != nil {