Skip to content

Commit 2577456

Browse files
committed
fix(agent): register --id flag on agent deploy
deployAgent resolves the agent via getAgentID, which reads cmd.String("id"), but the deploy subcommand never registered the --id flag (unlike config, status, restart, rollback). As a result `lk agent deploy --id CA_XXX` failed at parse time with "flag provided but not defined: --id". Add idFlag(false) to the deploy command's flags, matching the other subcommands. Fixes #830
1 parent de2017e commit 2577456

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

autocomplete/fish_autocomplete

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcomma
8181
complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from config' -f -l help -s h -d 'show help'
8282
complete -x -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from config; and not __fish_seen_subcommand_from help h' -a 'help' -d 'Shows a list of commands or help for one command'
8383
complete -x -c lk -n '__fish_seen_subcommand_from agent a; and not __fish_seen_subcommand_from init create dockerfile config deploy promote status update restart rollback logs tail delete destroy versions list secrets update-secrets private-link start dev console daemon simulate help h' -a 'deploy' -d 'Deploy a new version of the agent'
84+
complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from deploy' -f -l id -r -d '`ID` of the agent. If unset, and the livekit.toml file is present, will use the id found there.'
8485
complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from deploy' -f -l attributes -r -d '`JSON` literal or file path containing an object of string key-value pairs. Use "-" to read from stdin.'
8586
complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from deploy' -f -l attribute -r -d '`KEY=VALUE` attribute pair, may be repeated. Merged with --attributes, taking precedence on conflicting keys.'
8687
complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from deploy' -f -l secrets -r -d 'KEY=VALUE comma separated secrets. These will be injected as environment variables into the agent. These take precedence over secrets-file.'

cmd/lk/agent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ var (
243243
Before: createAgentClient,
244244
Action: deployAgent,
245245
Flags: []cli.Flag{
246+
idFlag(false),
246247
attributesFlag,
247248
attributeFlag,
248249
secretsFlag,

cmd/lk/agent_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,3 +602,21 @@ func TestResolveAttributes(t *testing.T) {
602602
})
603603
}
604604
}
605+
606+
// TestAgentDeployRegistersIDFlag is a regression test for #830: `lk agent deploy`
607+
// resolves the agent via getAgentID, which reads cmd.String("id"). The deploy
608+
// subcommand must therefore register the --id flag; it previously omitted it, so
609+
// `lk agent deploy --id ...` failed at flag-parse time with "flag provided but not defined".
610+
func TestAgentDeployRegistersIDFlag(t *testing.T) {
611+
agentCmd := findCommandByName(AgentCommands, "agent")
612+
require.NotNil(t, agentCmd, "top-level 'agent' command must exist")
613+
614+
deployCmd := findCommandByName(agentCmd.Commands, "deploy")
615+
require.NotNil(t, deployCmd, "'agent deploy' command must exist")
616+
617+
var names []string
618+
for _, f := range deployCmd.Flags {
619+
names = append(names, f.Names()...)
620+
}
621+
require.Contains(t, names, "id", "'agent deploy' must register the --id flag")
622+
}

0 commit comments

Comments
 (0)