Skip to content

Commit 7ef392b

Browse files
authored
Merge branch 'main' into dc/user_timestamp_flag
2 parents 417c168 + b1b0369 commit 7ef392b

File tree

13 files changed

+480
-19
lines changed

13 files changed

+480
-19
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ lk perf agent-load-test \
425425
--agent-name test-agent \
426426
--echo-speech-delay 10s \
427427
--duration 5m
428+
--attribute key1=value1
428429
```
429430

430431
The above simulates 5 concurrent rooms, where each room has:

autocomplete/fish_autocomplete

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ complete -c lk -n '__fish_seen_subcommand_from create' -f -l identity -s i -r -d
296296
complete -c lk -n '__fish_seen_subcommand_from create' -f -l name -s n -r -d '`NAME` of the participant, used with --join. defaults to identity'
297297
complete -c lk -n '__fish_seen_subcommand_from create' -f -l room -s r -r -d '`NAME` of the room to join'
298298
complete -c lk -n '__fish_seen_subcommand_from create' -f -l metadata -r -d '`JSON` metadata to encode in the token, will be passed to participant'
299+
complete -c lk -n '__fish_seen_subcommand_from create' -f -l attribute -r -d 'set attributes in key=value format, can be used multiple times'
300+
complete -c lk -n '__fish_seen_subcommand_from create' -l attribute-file -r -d 'read attributes from a `JSON` file'
299301
complete -c lk -n '__fish_seen_subcommand_from create' -f -l valid-for -r -d '`TIME` that the token is valid for, e.g. "5m", "1h10m" (s: seconds, m: minutes, h: hours)'
300302
complete -c lk -n '__fish_seen_subcommand_from create' -f -l grant -r -d 'Additional `VIDEO_GRANT` fields. It\'ll be merged with other arguments (JSON formatted)'
301303
complete -c lk -n '__fish_seen_subcommand_from create' -f -l help -s h -d 'show help'
@@ -315,6 +317,8 @@ complete -c lk -n '__fish_seen_subcommand_from create-token' -f -l name -s n -r
315317
complete -c lk -n '__fish_seen_subcommand_from create-token' -f -l room -s r -r -d '`NAME` of the room to join'
316318
complete -c lk -n '__fish_seen_subcommand_from create-token' -f -l room-configuration -r -d 'name of the room configuration to use when creating a room'
317319
complete -c lk -n '__fish_seen_subcommand_from create-token' -f -l metadata -r -d '`JSON` metadata to encode in the token, will be passed to participant'
320+
complete -c lk -n '__fish_seen_subcommand_from create-token' -f -l attribute -r -d 'set attributes in key=value format, can be used multiple times'
321+
complete -c lk -n '__fish_seen_subcommand_from create-token' -l attribute-file -r -d 'read attributes from a `JSON` file'
318322
complete -c lk -n '__fish_seen_subcommand_from create-token' -f -l valid-for -r -d 'Amount of `TIME` that the token is valid for. i.e. "5m", "1h10m" (s: seconds, m: minutes, h: hours)'
319323
complete -c lk -n '__fish_seen_subcommand_from create-token' -f -l grant -r -d 'Additional `VIDEO_GRANT` fields. It\'ll be merged with other arguments (JSON formatted)'
320324
complete -c lk -n '__fish_seen_subcommand_from create-token' -f -l help -s h -d 'show help'

cmd/lk/agent.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ var (
7777
Required: false,
7878
}
7979

80+
ignoreEmptySecretsFlag = &cli.BoolFlag{
81+
Name: "ignore-empty-secrets",
82+
Usage: "If set, will skip environment variables with empty values from secrets files instead of failing",
83+
Required: false,
84+
Value: false,
85+
}
86+
8087
logTypeFlag = &cli.StringFlag{
8188
Name: "log-type",
8289
Usage: "Type of logs to retrieve. Valid values are 'deploy' and 'build'",
@@ -156,6 +163,7 @@ var (
156163
secretsFlag,
157164
secretsFileFlag,
158165
secretsMountFlag,
166+
ignoreEmptySecretsFlag,
159167
silentFlag,
160168
regionFlag,
161169
skipSDKCheckFlag,
@@ -200,6 +208,8 @@ var (
200208
secretsFlag,
201209
secretsFileFlag,
202210
secretsMountFlag,
211+
silentFlag,
212+
ignoreEmptySecretsFlag,
203213
skipSDKCheckFlag,
204214
},
205215
// NOTE: since secrets may contain commas, or indeed any special character we might want to treat as a flag separator,
@@ -226,6 +236,7 @@ var (
226236
secretsFlag,
227237
secretsFileFlag,
228238
secretsMountFlag,
239+
ignoreEmptySecretsFlag,
229240
},
230241
// NOTE: since secrets may contain commas, or indeed any special character we might want to treat as a flag separator,
231242
// we disable it entirely here and require multiple --secrets flags to be used.
@@ -320,6 +331,7 @@ var (
320331
secretsFlag,
321332
secretsFileFlag,
322333
secretsMountFlag,
334+
ignoreEmptySecretsFlag,
323335
idFlag(false),
324336
&cli.BoolFlag{
325337
Name: "overwrite",
@@ -1284,13 +1296,20 @@ func requireSecrets(_ context.Context, cmd *cli.Command, required, lazy bool) ([
12841296
fmt.Printf("Using secrets file [%s]\n", util.Accented(file))
12851297
}
12861298

1299+
ignoreEmpty := cmd.Bool("ignore-empty-secrets")
1300+
var skippedEmpty []string
1301+
12871302
for k, v := range env {
12881303
if _, exists := secrets[k]; exists {
12891304
continue
12901305
}
12911306

12921307
if v == "" {
1293-
return nil, fmt.Errorf("failed to parse secrets file: secret %s is empty, either remove it or provide a value", k)
1308+
if ignoreEmpty {
1309+
skippedEmpty = append(skippedEmpty, k)
1310+
continue
1311+
}
1312+
return nil, fmt.Errorf("failed to parse secrets file: secret %s is empty, either remove it or provide a value, or use --ignore-empty-secrets to skip empty values", k)
12941313
}
12951314

12961315
secret := &lkproto.AgentSecret{
@@ -1300,6 +1319,12 @@ func requireSecrets(_ context.Context, cmd *cli.Command, required, lazy bool) ([
13001319
}
13011320
secrets[k] = secret
13021321
}
1322+
1323+
// Log skipped secrets if any (unless silent)
1324+
if len(skippedEmpty) > 0 && !silent {
1325+
skippedNames := strings.Join(skippedEmpty, ", ")
1326+
fmt.Printf("Skipped %d empty secret(s): %s\n", len(skippedEmpty), util.Dimmed(skippedNames))
1327+
}
13031328
}
13041329

13051330
var secretsSlice []*lkproto.AgentSecret

0 commit comments

Comments
 (0)