Skip to content

Commit

Permalink
build(config): Update libsonnet
Browse files Browse the repository at this point in the history
  • Loading branch information
jshlbrd committed Dec 18, 2023
1 parent 81cc020 commit 52f1784
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions build/config/substation.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
or(settings={}): {
local default = {
object: $.config.object,
operand: null,
value: null,
},

type: 'number_bitwise_or',
Expand All @@ -54,7 +54,7 @@
xor(settings={}): {
local default = {
object: $.config.object,
operand: null,
value: null,
},

type: 'number_bitwise_xor',
Expand Down Expand Up @@ -761,6 +761,7 @@
local default = {
object: $.config.object,
pattern: null,
count: 0,
},

type: 'string_capture',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local sub = import '../../../../../../build/config/substation.libsonnet';
local domain_match = sub.cnd.all(
// After running the example, try changing this to "any" or "none" and see
// what happens.
sub.cnd.meta.for_each(settings={ type: 'all', inspector: sub.cnd.str.ends_with(settings={ string: '@brex.com' }) }),
sub.cnd.meta.for_each(settings={ type: 'all', inspector: sub.cnd.str.ends_with(settings={ value: '@brex.com' }) }),
);

{
Expand All @@ -17,7 +17,7 @@ local domain_match = sub.cnd.all(
// to summarize an array of values. For this example, the decision
// is represented as a boolean value and printed to stdout.
sub.tf.meta.switch(
settings={ switch: [
settings={ cases: [
{
condition: domain_match,
transform: sub.tf.obj.insert(settings={ object: { set_key: 'meta result' }, value: true }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ local sub = import '../../../../../../build/config/substation.libsonnet';
),
// A strict sample rate can be enforced by dropping any events that
// contain the `sample` key, but do not have a length of 10.
sub.tf.meta.switch(settings={ switch: [
sub.tf.meta.switch(settings={ cases: [
{
condition: sub.cnd.any(sub.cnd.num.len.eq(settings={ object: { key: 'sample' }, length: 10 })),
condition: sub.cnd.any(sub.cnd.num.len.eq(settings={ object: { key: 'sample' }, value: 10 })),
transform: sub.tf.object.copy(settings={ object: { key: 'sample.0' } }),
},
{
condition: sub.cnd.any(sub.cnd.num.len.gt(settings={ object: { key: 'sample' }, length: 0 })),
condition: sub.cnd.any(sub.cnd.num.len.gt(settings={ object: { key: 'sample' }, value: 0 })),
transform: sub.tf.util.drop(),
},
] }),
Expand Down
2 changes: 1 addition & 1 deletion examples/build/config/transform/array/group/config.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local files_key = 'files';
// [[name1, name2], [type1, type2], [size1, size2], [extension1, extension2]]
sub.tf.meta.for_each(settings={
object: { key: 'file_names', set_key: sub.helpers.key.append_array(files_key) },
transform: sub.tf.string.match.find(settings={ pattern: '\\.([^\\.]+)$' }),
transform: sub.tf.string.capture(settings={ pattern: '\\.([^\\.]+)$' }),
}),
sub.tf.send.stdout(),
// The array of arrays is transformed into an array of objects based on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local key = 'c';
// If there is no output from the transform, then an error is thrown to crash the program.
sub.tf.meta.switch(settings={ switch: [
{
condition: sub.cnd.any(sub.cnd.num.len.eq(settings={ object: { key: key }, length: 0 })),
condition: sub.cnd.any(sub.cnd.num.len.eq(settings={ object: { key: key }, value: 0 })),
transform: sub.tf.util.err(settings={ message: 'transform produced no output' }),
},
{ transform: sub.tf.send.stdout() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local sub = import '../../../../../../build/config/substation.libsonnet';
// `key` is the target of the transform that may not produce an output and is
// checked to determine if the transform was successful.
local key = 'c';
local key_is_empty = sub.cnd.num.len.eq(settings={ object: { key: key }, length: 0 });
local key_is_empty = sub.cnd.num.len.eq(settings={ object: { key: key }, value: 0 });

local cnd = sub.cnd.all([
key_is_empty,
Expand Down Expand Up @@ -39,7 +39,7 @@ local retries = ['0s', '1s', '2s', '4s'];
] + [
// If there is no output after all retry attempts, then an error is thrown to crash the program.
// This is the same technique from the build/config/transform/meta/crash_program example.
sub.tf.meta.switch(settings={ switch: [
sub.tf.meta.switch(settings={ cases: [
{
condition: sub.cnd.any(key_is_empty),
transform: sub.tf.util.err(settings={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local sub = import '../../../../../../../../build/config/substation.libsonnet';
),
// Appending a newline is required so that the S3 object is line delimited.
sub.tf.string.append(
settings={ string: '\n' }
settings={ suffix: '\n' }
),
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local sub = import '../../../../../../../../build/config/substation.libsonnet';
sub.pattern.tf.conditional(
condition=sub.cnd.all([
sub.cnd.number.length.greater_than(
settings={ object: { key: 'body' }, length: 0 }
settings={ object: { key: 'body' }, value: 0 }
),
]),
transform=sub.tf.object.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local sub = import '../../../../../../../../build/config/substation.libsonnet';
),
condition=sub.condition.all([
sub.condition.number.length.greater_than(
settings={ object: { key: 'body' }, length: 0 }
settings={ object: { key: 'body' }, value: 0 }
),
]),
),
Expand Down

0 comments on commit 52f1784

Please sign in to comment.