fix(token): fix rotate command failing to match tokens by numeric ID

What does this MR do and why?

Fixes glab token rotate silently failing to find a token when a numeric ID is provided instead of a name.

Root cause

strconv.Atoi returns int, but the GitLab API uses int64 for all token ID fields (PersonalAccessToken.ID, GroupAccessToken.ID, ProjectAccessToken.ID). In Go, interface equality requires an exact type match, so the comparison t.ID == o.name always returned false when an ID was given — the token was never found and the user got a misleading error:

no token found with the name '12345'

Fix

  • Use strconv.ParseInt(..., 10, 64) to store the ID as int64, matching the API type
  • Add a nameKind() helper to produce clearer error messages (ID vs name)
  • Extract cmd.Flags() into a local fl variable per project conventions
  • Add t.Parallel() to all tests and subtests
  • Add test cases covering ID-based lookup for personal, group, and project tokens

MR acceptance checklist

Closes #8248 (closed)

Merge request reports

Loading