GetTokenIdentity gets the identity information of an agent token.
(ctx context.Context)
| 85 | |
| 86 | // GetTokenIdentity gets the identity information of an agent token. |
| 87 | func (c *AgentTokenClient) GetTokenIdentity(ctx context.Context) (result *AgentTokenIdentity, retryAfter time.Duration, err error) { |
| 88 | u := c.endpoint.JoinPath("token") |
| 89 | |
| 90 | req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) |
| 91 | if err != nil { |
| 92 | return nil, 0, fmt.Errorf("creating token request: %w", err) |
| 93 | } |
| 94 | |
| 95 | req.Header.Set("Authorization", fmt.Sprintf("Token %s", c.token)) |
| 96 | req.Header.Set("User-Agent", fmt.Sprintf("buildkite/agent-stack-k8s %s", version.Version())) |
| 97 | |
| 98 | resp, err := c.httpClient.Do(req) |
| 99 | if err != nil { |
| 100 | return nil, 0, err |
| 101 | } |
| 102 | defer resp.Body.Close() |
| 103 | |
| 104 | return decodeResponse[AgentTokenIdentity](resp) |
| 105 | } |