Skip to content

Commit fe6e232

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 ad73ec7 commit fe6e232

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
@@ -80,6 +80,7 @@ complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcomma
8080
complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from config' -f -l help -s h -d 'show help'
8181
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'
8282
complete -x -c lk -n '__fish_seen_subcommand_from agent a; and not __fish_seen_subcommand_from init create dockerfile config deploy status update restart rollback logs tail delete destroy versions list secrets update-secrets private-link start dev console simulate help h' -a 'deploy' -d 'Deploy a new version of the agent'
83+
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.'
8384
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.'
8485
complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from deploy' -l secrets-file -r -d '`FILE` containing secret KEY=VALUE pairs, one per line. These will be injected as environment variables into the agent.'
8586
complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from deploy' -f -l secret-mount -r -d 'Local path to a secret file to be mounted on agent environment'

cmd/lk/agent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ var (
221221
Before: createAgentClient,
222222
Action: deployAgent,
223223
Flags: []cli.Flag{
224+
idFlag(false),
224225
secretsFlag,
225226
secretsFileFlag,
226227
secretsMountFlag,

cmd/lk/agent_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,21 @@ func TestRequireSecrets_QuietSuppressesStatus(t *testing.T) {
456456
})
457457
}
458458
}
459+
460+
// TestAgentDeployRegistersIDFlag is a regression test for #830: `lk agent deploy`
461+
// resolves the agent via getAgentID, which reads cmd.String("id"). The deploy
462+
// subcommand must therefore register the --id flag; it previously omitted it, so
463+
// `lk agent deploy --id ...` failed at flag-parse time with "flag provided but not defined".
464+
func TestAgentDeployRegistersIDFlag(t *testing.T) {
465+
agentCmd := findCommandByName(AgentCommands, "agent")
466+
require.NotNil(t, agentCmd, "top-level 'agent' command must exist")
467+
468+
deployCmd := findCommandByName(agentCmd.Commands, "deploy")
469+
require.NotNil(t, deployCmd, "'agent deploy' command must exist")
470+
471+
var names []string
472+
for _, f := range deployCmd.Flags {
473+
names = append(names, f.Names()...)
474+
}
475+
require.Contains(t, names, "id", "'agent deploy' must register the --id flag")
476+
}

0 commit comments

Comments
 (0)