Skip to content

Commit fd1131b

Browse files
authored
fix: set-secrets automatically switches agent to selective mode (#3)
1 parent 4ca6956 commit fd1131b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmd/onecli/agents.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,20 @@ func (c *AgentsSetSecretsCmd) Run(out *output.Writer) error {
211211
}
212212
}
213213
if c.DryRun {
214-
return out.WriteDryRun("Would set agent secrets", map[string]any{"id": c.ID, "secret_ids": ids})
214+
return out.WriteDryRun("Would set agent secrets and switch to selective mode", map[string]any{"id": c.ID, "secret_ids": ids})
215215
}
216216
client, err := newClient()
217217
if err != nil {
218218
return err
219219
}
220-
if err := client.SetAgentSecrets(newContext(), c.ID, api.SetAgentSecretsInput{SecretIDs: ids}); err != nil {
220+
ctx := newContext()
221+
if err := client.SetAgentSecrets(ctx, c.ID, api.SetAgentSecretsInput{SecretIDs: ids}); err != nil {
221222
return err
222223
}
223-
return out.Write(map[string]any{"status": "updated", "id": c.ID, "secret_ids": ids})
224+
if err := client.SetAgentSecretMode(ctx, c.ID, api.SetSecretModeInput{Mode: "selective"}); err != nil {
225+
return err
226+
}
227+
return out.Write(map[string]any{"status": "updated", "id": c.ID, "secret_ids": ids, "secret_mode": "selective"})
224228
}
225229

226230
// AgentsSetSecretModeCmd is `onecli agents set-secret-mode`.

0 commit comments

Comments
 (0)