Skip to content

Commit

Permalink
Add stream fields to each dataset
Browse files Browse the repository at this point in the history
During the generation of the datasets, a stream.yml file is created with the stream fields inside. These are required for each dataset.
  • Loading branch information
ruflin committed Mar 25, 2020
1 parent 293443e commit 02583e0
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions dev/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"io/ioutil"
"log"
"os"
"path"
"path/filepath"

"github.com/magefile/mage/sh"
Expand All @@ -25,6 +26,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 +137,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 := path.Join(p.BasePath, "dataset", dataset, "fields")
err := os.MkdirAll(dirPath, 0755)
if err != nil {
return err
}

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

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

0 comments on commit 02583e0

Please sign in to comment.