diff --git a/docs/manual.md b/docs/manual.md index 33b1a8e61..40705829a 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -529,11 +529,12 @@ file: ### gossfile -Import other gossfiles from this one. This is the best way to maintain a large mumber of tests, and/or create profiles. See [render](#render-r---render-gossfile-after-importing-all-referenced-gossfiles) for more examples. +Import other gossfiles from this one. This is the best way to maintain a large mumber of tests, and/or create profiles. See [render](#render-r---render-gossfile-after-importing-all-referenced-gossfiles) for more examples. Glob patterns can be also be used to specify matching gossfiles. ```yaml gossfile: goss_httpd.yaml: {} + /etc/goss.d/*.yaml: {} ``` diff --git a/integration-tests/goss/alpine3/goss.yaml b/integration-tests/goss/alpine3/goss.yaml index 377f610a8..6c91c7968 100644 --- a/integration-tests/goss/alpine3/goss.yaml +++ b/integration-tests/goss/alpine3/goss.yaml @@ -24,5 +24,4 @@ port: ip: - "::" gossfile: - "../goss-shared.yaml": {} - "../goss-service.yaml": {} + "../goss-s*.yaml": {} diff --git a/integration-tests/goss/centos7/goss.yaml b/integration-tests/goss/centos7/goss.yaml index 300a6fa4a..254b7b75f 100644 --- a/integration-tests/goss/centos7/goss.yaml +++ b/integration-tests/goss/centos7/goss.yaml @@ -24,5 +24,4 @@ port: ip: - "::" gossfile: - "../goss-shared.yaml": {} - "../goss-service.yaml": {} + "../goss-s*.yaml": {} diff --git a/integration-tests/goss/precise/goss.yaml b/integration-tests/goss/precise/goss.yaml index a4566b776..5c7aba63d 100644 --- a/integration-tests/goss/precise/goss.yaml +++ b/integration-tests/goss/precise/goss.yaml @@ -24,5 +24,4 @@ port: ip: - 0.0.0.0 gossfile: - "../goss-shared.yaml": {} - "../goss-service.yaml": {} + "../goss-s*.yaml": {} diff --git a/integration-tests/goss/wheezy/goss.yaml b/integration-tests/goss/wheezy/goss.yaml index 8ceb0e3d2..2292f2689 100644 --- a/integration-tests/goss/wheezy/goss.yaml +++ b/integration-tests/goss/wheezy/goss.yaml @@ -24,5 +24,4 @@ port: ip: - "::" gossfile: - "../goss-shared.yaml": {} - "../goss-service.yaml": {} + "../goss-s*.yaml": {} diff --git a/store.go b/store.go index 7dfafbaf8..4f4e2b336 100644 --- a/store.go +++ b/store.go @@ -158,9 +158,16 @@ func mergeJSONData(gossConfig GossConfig, depth int, path string) GossConfig { } else { fpath = filepath.Join(path, g.ID()) } - fdir := filepath.Dir(fpath) - j := mergeJSONData(ReadJSON(fpath), depth, fdir) - ret = mergeGoss(ret, j) + matches, err := filepath.Glob(fpath) + if err != nil { + fmt.Printf("Error in expanding glob pattern: \"%s\"\n", err.Error()) + os.Exit(1) + } + for _, match := range matches { + fdir := filepath.Dir(match) + j := mergeJSONData(ReadJSON(match), depth, fdir) + ret = mergeGoss(ret, j) + } } return ret }