Skip to content

Commit

Permalink
feat: add support for parsing comma-separated list environment variab…
Browse files Browse the repository at this point in the history
…les (#2765)

We're planning to add a new environment variable, `ACTOR_BUILD_TAGS`, to
the Actor runtime, which will contain the list of build tags of the
currently running Actor build. The environment variable will be a
comma-separated list, but I think it would be easier to work with if it
was already parsed to an array in the `Configuration` instance.

This adds support for parsing comma-separated list environment variables
to arrays. In the SDK, I'll then just override the
`COMMA_SEPARATED_LIST_VARS` list to include the environment variable I
want to have parsed.
  • Loading branch information
fnesveda authored Dec 11, 2024
1 parent 214997e commit 4e50c47
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/core/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ export class Configuration {

protected static INTEGER_VARS = ['memoryMbytes', 'persistStateIntervalMillis', 'systemInfoIntervalMillis'];

protected static COMMA_SEPARATED_LIST_VARS: string[] = [];

protected static DEFAULTS: Dictionary = {
defaultKeyValueStoreId: 'default',
defaultDatasetId: 'default',
Expand Down Expand Up @@ -344,6 +346,13 @@ export class Configuration {
return !['0', 'false', ''].includes(String(value).toLowerCase());
}

if (Configuration.COMMA_SEPARATED_LIST_VARS.includes(key)) {
if (!value) return [];
return String(value)
.split(',')
.map((v) => v.trim());
}

return value;
}

Expand Down

0 comments on commit 4e50c47

Please sign in to comment.