-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build/config): Self-Referential Jsonnet Function (#225)
- Loading branch information
Showing
8 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
examples/config/transform/enrich/kvstore_csv/config.jsonnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// This example shows how to use the `enrich_kv_store_item_get` transform | ||
// to lookup data in a KV store backed by a CSV file. | ||
local sub = import '../../../../../build/config/substation.libsonnet'; | ||
|
||
// This CSV file must be local to the Substation app. Absolute paths are | ||
// recommended. Files accessible over HTTPS and hosted in AWS S3 also work. | ||
// | ||
// The `column` parameter is required and specifies the column in the CSV file | ||
// that will be used to lookup the key in the KV store. | ||
local kv = sub.kv_store.csv_file({ file: 'kv.csv', column: 'product' }); | ||
|
||
{ | ||
transforms: [ | ||
// The CSV file KV store returns the entire row minus the key column. | ||
// For example, this returns {"price":"9.99","calories":"500"} for "churro". | ||
sub.tf.enrich.kv_store.item.get({ | ||
object: { source_key: 'product', target_key: 'info'}, | ||
kv_store: kv, | ||
}), | ||
sub.tf.send.stdout(), | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"product":"churro"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
product,price,calories | ||
churro,9.99,500 | ||
donut,1.99,300 | ||
eclair,2.99,400 |
17 changes: 17 additions & 0 deletions
17
examples/config/transform/enrich/kvstore_json/config.jsonnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This example shows how to use the `enrich_kv_store_item_get` transform | ||
// to lookup data in a KV store backed by a JSON file. | ||
local sub = import '../../../../../build/config/substation.libsonnet'; | ||
|
||
// This JSON file must be local to the Substation app. Absolute paths are | ||
// recommended. Files accessible over HTTPS and hosted in AWS S3 also work. | ||
local kv = sub.kv_store.json_file({ file: 'kv.json' }); | ||
|
||
{ | ||
transforms: [ | ||
sub.tf.enrich.kv_store.item.get({ | ||
object: { source_key: 'product', target_key: 'price'}, | ||
kv_store: kv, | ||
}), | ||
sub.tf.send.stdout(), | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"product":"churro"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"churro":9.99} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters