Skip to content

Use AgentTokensFinder in AgentTokensResolver

Pam Artiaga requested to merge pam/agent-tokens-finder-in-resolver into master

What does this MR do and why?

The AgentTokensFinder was introduced in !103170 (merged) and !104038 (merged). This finder is used in the Cluster Agent Tokens REST API endpoints. (See also !103292 (merged) & !103300 (merged))

As discussed in the related issue (#363119 (comment 1158908371)), we'd also like to use the AgentTokensFinder in the AgentTokensResolver. This MR implements said change.

Issue: #363119 (closed)

Screenshots or screen recordings

Setup

Project

project

Agent and tokens

project_agent_tokens_psql

project_agent_tokens_ui

Test

Querying project.clusterAgent.tokens

test_list_tokens

How to set up and validate locally

Setup

  1. Create a project (or use an existing one)
  2. Set up an agent in that project
    • This will register an agent and create one agent token
  3. Create more agent tokens:
    1. Go to project Infrastructure -> Kubernetes clusters page
    2. Go to the agent's page
    3. Select the Access tokens tab
    4. Click the Create token button

Validate

Query project.clusterAgent.tokens in the GitLab GraphQL API. See the Getting Started Guide for a quick how-to on querying the GraphQL API.

curl "<local-gitlab-url>/api/graphql" \
-k -X POST \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Content-Type: application/json" \
--data "{\"query\": \"query {project(fullPath: \\\"<full-path-to-the-project>\\\") {name clusterAgent(name: \\\"<agent-name>\\\") {name tokens {nodes {id name status}}}}}\"}"

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by João Alexandre Cunha

Merge request reports