Skip to content

Add user permissions for runners in GraphQL API

Miguel Rincon requested to merge 337438-add-userpermissions-to-runner into master

What does this MR do and why?

This change adds a "userPermissions" field in the CiRunners type in our GraphQL API. This field communicates to the client what kind of access does the current user has to the runner.

Screenshots or screen recordings

Fields in GraphiQL:

Screen_Shot_2021-09-21_at_4.18.03_PM

How to set up and validate locally

  1. Log in as a group Owner or an Instance admin.
  2. Register some runners to your group
  3. Run the following query in the GraphQL explorer (http://gdk.test:3000/-/graphql-explorer)
Click to expand
fragment RunnerNode on CiRunner {
  id
  description
  runnerType
  shortSha
  version
  revision
  ipAddress
  active
  locked
  tagList
  contactedAt
  jobCount
  projectCount
}

fragment PageInfo on PageInfo {
  hasNextPage
  hasPreviousPage
  startCursor
  endCursor
}

query getGroupRunners(
  $groupFullPath: ID!
  $before: String
  $after: String
  $first: Int
  $last: Int
  $status: CiRunnerStatus
  $type: CiRunnerType
  $search: String
  $sort: CiRunnerSort
) {
  group(fullPath: $groupFullPath) {
    runners(
      membership: DESCENDANTS
      before: $before
      after: $after
      first: $first
      last: $last
      status: $status
      type: $type
      search: $search
      sort: $sort
    ) {
      edges {
        node {
          ...RunnerNode
          userPermissions {
            readRunner
            updateRunner
            deleteRunner
          }
        }
      }
      pageInfo {
        ...PageInfo
      }
    }
  }
}

MR acceptance checklist

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

Related to #337438 (closed)

Edited by Michael Kozono

Merge request reports