Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing assets from datasets #146

Merged
merged 5 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions testdata/package/example-1.0.0/dataset/foo/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
title: Foo

# Needs to describe the type of this input
type: logs
ingest_pipline: pipeline-entry
13 changes: 7 additions & 6 deletions testdata/package/example-1.0.0/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@
"/package/example-1.0.0/docs/README.md",
"/package/example-1.0.0/img/icon.png",
"/package/example-1.0.0/img/kibana-envoyproxy.jpg",
"/package/example-1.0.0/elasticsearch/ingest-pipeline/pipeline-entry.json",
"/package/example-1.0.0/elasticsearch/ingest-pipeline/pipeline-http.json",
"/package/example-1.0.0/elasticsearch/ingest-pipeline/pipeline-json.json",
"/package/example-1.0.0/elasticsearch/ingest-pipeline/pipeline-plaintext.json",
"/package/example-1.0.0/elasticsearch/ingest-pipeline/pipeline-tcp.json",
"/package/example-1.0.0/dataset/foo/manifest.yml",
"/package/example-1.0.0/kibana/dashboard/0c610510-5cbd-11e9-8477-077ec9664dbd.json",
"/package/example-1.0.0/kibana/index-pattern/filebeat-*.json",
"/package/example-1.0.0/kibana/visualization/0a994af0-5c9d-11e9-8477-077ec9664dbd.json",
"/package/example-1.0.0/kibana/visualization/36f872a0-5c03-11e9-85b4-19d0072eb4f2.json",
"/package/example-1.0.0/kibana/visualization/38f96190-5c99-11e9-8477-077ec9664dbd.json",
"/package/example-1.0.0/kibana/visualization/7e4084e0-5c99-11e9-8477-077ec9664dbd.json",
"/package/example-1.0.0/kibana/visualization/80844540-5c97-11e9-8477-077ec9664dbd.json",
"/package/example-1.0.0/kibana/visualization/ab48c3f0-5ca6-11e9-8477-077ec9664dbd.json"
"/package/example-1.0.0/kibana/visualization/ab48c3f0-5ca6-11e9-8477-077ec9664dbd.json",
"/package/example-1.0.0/dataset/foo/elasticsearch/ingest-pipeline/pipeline-entry.json",
"/package/example-1.0.0/dataset/foo/elasticsearch/ingest-pipeline/pipeline-http.json",
"/package/example-1.0.0/dataset/foo/elasticsearch/ingest-pipeline/pipeline-json.json",
"/package/example-1.0.0/dataset/foo/elasticsearch/ingest-pipeline/pipeline-plaintext.json",
"/package/example-1.0.0/dataset/foo/elasticsearch/ingest-pipeline/pipeline-tcp.json"
]
}
27 changes: 12 additions & 15 deletions util/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,19 @@ func (p *Package) LoadAssets(packagePath string) (err error) {
return err
}

assets, err := filepath.Glob("*")
if err != nil {
return err
}

a, err := filepath.Glob("*/*")
if err != nil {
return err
}
assets = append(assets, a...)

a, err = filepath.Glob("*/*/*")
if err != nil {
return err
var assets []string
var pattern = "*"
// Iterates 6 levels deep through the tree to find assets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be a time when 6 levels aren't deep enough? Is there a way to solve this recursively once and for all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure it will happen. There is a library that does it but I was hesitant to include it here: https://github.com/bmatcuk/doublestar I'm just thinking of an alternative recursive implementation now that I mention it which "should" always work. Will update.

// If we need more complex matching a library like https://github.com/bmatcuk/doublestar
// could be used but the below works and is pretty simple.
for n := 0; n <= 6; n++ {
a, err := filepath.Glob(pattern)
if err != nil {
return err
}
assets = append(assets, a...)
pattern = pattern + "/*"
}
assets = append(assets, a...)

for _, a := range assets {
// Unfortunately these files keep sneaking in
Expand Down