Skip to content

Commit

Permalink
Allow directory names with hyphens in _dev directories (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano authored Feb 9, 2022
1 parent 5462c12 commit 8b005d3
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions code/go/internal/validator/common_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion code/go/internal/validator/folder_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "Hello!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "Hello!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: '2.3'
services:
hello_world:
3 changes: 2 additions & 1 deletion versions/1/_dev/spec.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
spec:
additionalContents: false
developmentFolder: true
contents:
- description: Folder containing resources related to building the package.
type: folder
Expand All @@ -10,4 +11,4 @@ spec:
type: folder
name: deploy
required: false
$ref: "./deploy/spec.yml"
$ref: "./deploy/spec.yml"
9 changes: 6 additions & 3 deletions versions/1/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 (-).
Expand Down
3 changes: 2 additions & 1 deletion versions/1/data_stream/_dev/spec.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
spec:
additionalContents: false
developmentFolder: true
contents:
- description: Folder containing test resources
type: folder
Expand All @@ -10,4 +11,4 @@ spec:
type: folder
name: deploy
required: false
$ref: "./../../_dev/deploy/spec.yml" # Use "deploy" spec for package
$ref: "./../../_dev/deploy/spec.yml" # Use "deploy" spec for package

0 comments on commit 8b005d3

Please sign in to comment.