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 stream fields to each dataset #296

Merged
merged 2 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Allow to set cache times through config. [#271](https://github.com/elastic/integrations-registry/pull/271)
* Make README.md file a required file for a package. [#287](https://github.com/elastic/integrations-registry/pull/287)
* Add stream fields to each dataset [#296](https://github.com/elastic/integrations-registry/pull/296)

### Deprecated

Expand Down
33 changes: 33 additions & 0 deletions dev/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ var (

const (
packageDirName = "package"
streamFields = `
- name: stream.type
type: constant_keyword
description: >
Stream type
- name: stream.dataset
type: constant_keyword
description: >
Stream dataset.
- name: stream.namespace
type: constant_keyword
description: >
Stream namespace.
`
)

func main() {
Expand Down Expand Up @@ -122,6 +136,25 @@ func buildPackage(packagesBasePath string, p util.Package) error {

p.BasePath = filepath.Join(currentPath, packagesBasePath, p.GetPath())

datasets, err := p.GetDatasets()
if err != nil {
return err
}

// Add stream.yml to all dataset with the basic stream fields
for _, dataset := range datasets {
dirPath := filepath.Join(p.BasePath, "dataset", dataset, "fields")
err := os.MkdirAll(dirPath, 0755)
if err != nil {
return err
}

err = ioutil.WriteFile(filepath.Join(dirPath, "stream.yml"), []byte(streamFields), 0644)
if err != nil {
return err
}
}

err = p.LoadAssets(p.GetPath())
if err != nil {
return err
Expand Down