Skip to content

Commit

Permalink
strengthen tile metadata file regexp matcher
Browse files Browse the repository at this point in the history
Some tile zips contain the `metadata/` folder as a separate "file"
as well. This gets caught in the current `metadata/.*` matcher for the
metadata file.

Add this empty directory to our test, and modify the regexp to more
strongly match the expected metadata yml file.

[fixes #239]

[#160019619] pivotal-cf/om #239: tile-metadata throws EOFs on many tiles
  • Loading branch information
Chris Hendrix committed Aug 27, 2018
1 parent 8227e57 commit dc032ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion commands/tile_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (t TileMetadata) Execute(args []string) error {
defer file.Close()

for _, f := range file.File {
matched, err := regexp.MatchString("metadata/.*", f.Name)
matched, err := regexp.MatchString("metadata/.+\\.yml", f.Name)
if err != nil {
return fmt.Errorf("failed to match file name regex: %s", err)
}
Expand Down
7 changes: 7 additions & 0 deletions commands/tile_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ var _ = Describe("TileMetadata", func() {
productFile, err = ioutil.TempFile("", "fake-tile")
z := zip.NewWriter(productFile)

// https://github.com/pivotal-cf/om/issues/239
// writing a "directory" as well, because some tiles seem to
// have this as a separate file in the zip, which influences the regexp
// needed to capture the metadata file
_, err := z.Create("metadata/")
Expect(err).NotTo(HaveOccurred())

f, err := z.Create("metadata/fake-tile.yml")
Expect(err).NotTo(HaveOccurred())

Expand Down

0 comments on commit dc032ad

Please sign in to comment.