diff --git a/code/go/internal/validator/common_spec.go b/code/go/internal/validator/common_spec.go index 61eb649f6..14e40e074 100644 --- a/code/go/internal/validator/common_spec.go +++ b/code/go/internal/validator/common_spec.go @@ -13,6 +13,7 @@ type commonSpec struct { AdditionalContents bool `yaml:"additionalContents"` Content map[string]interface{} `yaml:"content"` Contents []folderItemSpec `yaml:"contents"` + DevelopmentFolder bool `yaml:"developmentFolder"` } func setDefaultValues(spec *commonSpec) error { diff --git a/code/go/internal/validator/folder_spec.go b/code/go/internal/validator/folder_spec.go index 5466919db..e1fe5ba25 100644 --- a/code/go/internal/validator/folder_spec.go +++ b/code/go/internal/validator/folder_spec.go @@ -85,7 +85,7 @@ func (s *folderSpec) validate(packageName string, folderPath string) ve.Validati if itemSpec == nil && s.AdditionalContents { // No spec found for current folder item but we do allow additional contents in folder. if file.IsDir() { - if strings.Contains(fileName, "-") { + if !s.DevelopmentFolder && strings.Contains(fileName, "-") { errs = append(errs, fmt.Errorf(`file "%s/%s" is invalid: directory name inside package %s contains -: %s`, folderPath, fileName, packageName, fileName)) @@ -135,6 +135,11 @@ func (s *folderSpec) validate(packageName string, folderPath string) ve.Validati } } + // Subfolders of development folders are also considered development folders. + if s.DevelopmentFolder { + subFolderSpec.DevelopmentFolder = true + } + subFolderPath := path.Join(folderPath, fileName) subErrs := subFolderSpec.validate(packageName, subFolderPath) if len(subErrs) > 0 { diff --git a/test/packages/deploy_docker/_dev/deploy/docker/docker-compose.d/hi.sh b/test/packages/deploy_docker/_dev/deploy/docker/docker-compose.d/hi.sh new file mode 100644 index 000000000..3c7fa7b8e --- /dev/null +++ b/test/packages/deploy_docker/_dev/deploy/docker/docker-compose.d/hi.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Hello!" diff --git a/test/packages/good/data_stream/foo/_dev/deploy/docker/docker-compose.d/hi.sh b/test/packages/good/data_stream/foo/_dev/deploy/docker/docker-compose.d/hi.sh new file mode 100644 index 000000000..3c7fa7b8e --- /dev/null +++ b/test/packages/good/data_stream/foo/_dev/deploy/docker/docker-compose.d/hi.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Hello!" diff --git a/test/packages/good/data_stream/foo/_dev/deploy/docker/docker-compose.yml b/test/packages/good/data_stream/foo/_dev/deploy/docker/docker-compose.yml new file mode 100644 index 000000000..65b87adfd --- /dev/null +++ b/test/packages/good/data_stream/foo/_dev/deploy/docker/docker-compose.yml @@ -0,0 +1,3 @@ +version: '2.3' +services: + hello_world: \ No newline at end of file diff --git a/versions/1/_dev/spec.yml b/versions/1/_dev/spec.yml index 9a4004123..050c743b9 100644 --- a/versions/1/_dev/spec.yml +++ b/versions/1/_dev/spec.yml @@ -1,5 +1,6 @@ spec: additionalContents: false + developmentFolder: true contents: - description: Folder containing resources related to building the package. type: folder @@ -10,4 +11,4 @@ spec: type: folder name: deploy required: false - $ref: "./deploy/spec.yml" \ No newline at end of file + $ref: "./deploy/spec.yml" diff --git a/versions/1/changelog.yml b/versions/1/changelog.yml index 44e35b5e6..9fd47c3a9 100644 --- a/versions/1/changelog.yml +++ b/versions/1/changelog.yml @@ -7,12 +7,15 @@ - description: ML model file name now matches the id of the model. type: enhancement link: https://github.com/elastic/package-spec/pull/268 - - description: Prepare for next version - type: enhancement - link: https://github.com/elastic/package-spec/pull/265 - description: Support auxiliary files in terraform deploy spec type: enhancement link: https://github.com/elastic/package-spec/pull/272 + - description: Add `developmentFolder` flag to mark directories with files intended for development. + type: enhancement + link: https://github.com/elastic/package-spec/pull/270 + - description: Allow directory names with hyphens inside _dev directories. + type: bugfix + link: https://github.com/elastic/package-spec/pull/270 - version: 1.4.0 changes: - description: Report error when a directory name inside a package contains hyphens (-). diff --git a/versions/1/data_stream/_dev/spec.yml b/versions/1/data_stream/_dev/spec.yml index 859081f56..a6b719238 100644 --- a/versions/1/data_stream/_dev/spec.yml +++ b/versions/1/data_stream/_dev/spec.yml @@ -1,5 +1,6 @@ spec: additionalContents: false + developmentFolder: true contents: - description: Folder containing test resources type: folder @@ -10,4 +11,4 @@ spec: type: folder name: deploy required: false - $ref: "./../../_dev/deploy/spec.yml" # Use "deploy" spec for package \ No newline at end of file + $ref: "./../../_dev/deploy/spec.yml" # Use "deploy" spec for package