Skip to content

Commit 188bd00

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 188bd00

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

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)