diff --git a/autocomplete/fish_autocomplete b/autocomplete/fish_autocomplete index 13ccd2e8..9988c16a 100644 --- a/autocomplete/fish_autocomplete +++ b/autocomplete/fish_autocomplete @@ -80,6 +80,7 @@ complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcomma complete -c lk -n '__fish_seen_subcommand_from agent a; and __fish_seen_subcommand_from config' -f -l help -s h -d 'show help' 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' 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' +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.' 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.' 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.' 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' diff --git a/cmd/lk/agent.go b/cmd/lk/agent.go index a61f6cb5..fc9cc38a 100644 --- a/cmd/lk/agent.go +++ b/cmd/lk/agent.go @@ -221,6 +221,7 @@ var ( Before: createAgentClient, Action: deployAgent, Flags: []cli.Flag{ + idFlag(false), secretsFlag, secretsFileFlag, secretsMountFlag, diff --git a/cmd/lk/agent_test.go b/cmd/lk/agent_test.go index 1d2551f6..4c54085e 100644 --- a/cmd/lk/agent_test.go +++ b/cmd/lk/agent_test.go @@ -456,3 +456,21 @@ func TestRequireSecrets_QuietSuppressesStatus(t *testing.T) { }) } } + +// TestAgentDeployRegistersIDFlag is a regression test for #830: `lk agent deploy` +// resolves the agent via getAgentID, which reads cmd.String("id"). The deploy +// subcommand must therefore register the --id flag; it previously omitted it, so +// `lk agent deploy --id ...` failed at flag-parse time with "flag provided but not defined". +func TestAgentDeployRegistersIDFlag(t *testing.T) { + agentCmd := findCommandByName(AgentCommands, "agent") + require.NotNil(t, agentCmd, "top-level 'agent' command must exist") + + deployCmd := findCommandByName(agentCmd.Commands, "deploy") + require.NotNil(t, deployCmd, "'agent deploy' command must exist") + + var names []string + for _, f := range deployCmd.Flags { + names = append(names, f.Names()...) + } + require.Contains(t, names, "id", "'agent deploy' must register the --id flag") +}