Make agentpr's Vault gitea creds path selectable #8
Reference in New Issue
Block a user
Delete Branch "benvin/agentpr-creds-path"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
agentprreadgitea/creds/unkin-agentfrom a bare const with no override, so a service like repospawner could not run it as its own Gitea identity — every PR it opened was attributed tounkin-agent.AGENT_LOGINexisted but only fed watchpr's self-comment filter and agentws's git identity.How
GiteaCredsPathbecomes a function:GITEA_CREDS_PATHwhen set, otherwisegitea/creds/<AGENT_LOGIN>. With neither set it resolves togitea/creds/unkin-agentexactly as before, so nothing existing changes.fetchGiteaToken/readGiteaCredsrather than read from a package const, and it now appears in the Vault error messages.agentpr's Short/Long/whoami help text is login-agnostic; README and AGENTS.md document both variables.So
AGENT_LOGIN=repospawner agentpr pr create ...readsgitea/creds/repospawnerand posts as repospawner.Tests
New
internal/agent/token_test.go: table test over default /AGENT_LOGIN-derived /GITEA_CREDS_PATHprecedence / trimming, plus httptest-backed tests asserting the exact Vault path read and that whoami and PR creation then run as the selected identity.go test -race, gofmt,go vet, golangci-lint and pre-commit all clean.