Commit 1d5447b9 authored by Markus Koller's avatar Markus Koller

Merge branch 'mc/backstage/graphql-runner-installation-be' into 'master'

GraphQL runner platforms resolver

See merge request gitlab-org/gitlab!45073
parents 513045ee 72b1e653
# frozen_string_literal: true
module Resolvers
module Ci
class RunnerPlatformsResolver < BaseResolver
type Types::Ci::RunnerPlatformType, null: false
def resolve(**args)
runner_instructions.map do |platform, data|
{
name: platform, human_readable_name: data[:human_readable_name],
architectures: parse_architectures(data[:download_locations])
}
end
end
private
def runner_instructions
Gitlab::Ci::RunnerInstructions::OS.merge(Gitlab::Ci::RunnerInstructions::OTHER_ENVIRONMENTS)
end
def parse_architectures(download_locations)
download_locations&.map do |architecture, download_location|
{ name: architecture, download_location: download_location }
end
end
end
end
end
# frozen_string_literal: true
module Types
module Ci
# rubocop: disable Graphql/AuthorizeTypes
class RunnerArchitectureType < BaseObject
graphql_name 'RunnerArchitecture'
field :name, GraphQL::STRING_TYPE, null: false,
description: 'Name of the runner platform architecture'
field :download_location, GraphQL::STRING_TYPE, null: false,
description: 'Download location for the runner for the platform architecture'
end
end
end
# frozen_string_literal: true
module Types
module Ci
# rubocop: disable Graphql/AuthorizeTypes
class RunnerPlatformType < BaseObject
graphql_name 'RunnerPlatform'
field :name, GraphQL::STRING_TYPE, null: false,
description: 'Name slug of the runner platform'
field :human_readable_name, GraphQL::STRING_TYPE, null: false,
description: 'Human readable name of the runner platform'
field :architectures, Types::Ci::RunnerArchitectureType.connection_type, null: true,
description: 'Runner architectures supported for the platform'
end
end
end
......@@ -80,6 +80,10 @@ module Types
description: 'Get statistics on the instance',
resolver: Resolvers::Admin::Analytics::InstanceStatistics::MeasurementsResolver
field :runner_platforms, Types::Ci::RunnerPlatformType.connection_type,
null: true, description: 'Supported runner platforms',
resolver: Resolvers::Ci::RunnerPlatformsResolver
def design_management
DesignManagementObject.new(nil)
end
......
......@@ -15538,6 +15538,31 @@ type Query {
sort: String
): ProjectConnection
"""
Supported runner platforms
"""
runnerPlatforms(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): RunnerPlatformConnection
"""
Find Snippets visible to the current user
"""
......@@ -16712,6 +16737,125 @@ type RunDASTScanPayload {
pipelineUrl: String
}
type RunnerArchitecture {
"""
Download location for the runner for the platform architecture
"""
downloadLocation: String!
"""
Name of the runner platform architecture
"""
name: String!
}
"""
The connection type for RunnerArchitecture.
"""
type RunnerArchitectureConnection {
"""
A list of edges.
"""
edges: [RunnerArchitectureEdge]
"""
A list of nodes.
"""
nodes: [RunnerArchitecture]
"""
Information to aid in pagination.
"""
pageInfo: PageInfo!
}
"""
An edge in a connection.
"""
type RunnerArchitectureEdge {
"""
A cursor for use in pagination.
"""
cursor: String!
"""
The item at the end of the edge.
"""
node: RunnerArchitecture
}
type RunnerPlatform {
"""
Runner architectures supported for the platform
"""
architectures(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): RunnerArchitectureConnection
"""
Human readable name of the runner platform
"""
humanReadableName: String!
"""
Name slug of the runner platform
"""
name: String!
}
"""
The connection type for RunnerPlatform.
"""
type RunnerPlatformConnection {
"""
A list of edges.
"""
edges: [RunnerPlatformEdge]
"""
A list of nodes.
"""
nodes: [RunnerPlatform]
"""
Information to aid in pagination.
"""
pageInfo: PageInfo!
}
"""
An edge in a connection.
"""
type RunnerPlatformEdge {
"""
A cursor for use in pagination.
"""
cursor: String!
"""
The item at the end of the edge.
"""
node: RunnerPlatform
}
"""
Represents a CI configuration of SAST
"""
......
......@@ -44968,6 +44968,59 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "runnerPlatforms",
"description": "Supported runner platforms",
"args": [
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "RunnerPlatformConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "snippets",
"description": "Find Snippets visible to the current user",
......@@ -48213,6 +48266,381 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "RunnerArchitecture",
"description": null,
"fields": [
{
"name": "downloadLocation",
"description": "Download location for the runner for the platform architecture",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "name",
"description": "Name of the runner platform architecture",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "RunnerArchitectureConnection",
"description": "The connection type for RunnerArchitecture.",
"fields": [
{
"name": "edges",
"description": "A list of edges.",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "RunnerArchitectureEdge",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "nodes",
"description": "A list of nodes.",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "RunnerArchitecture",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pageInfo",
"description": "Information to aid in pagination.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PageInfo",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "RunnerArchitectureEdge",
"description": "An edge in a connection.",
"fields": [
{
"name": "cursor",
"description": "A cursor for use in pagination.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "node",
"description": "The item at the end of the edge.",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "RunnerArchitecture",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "RunnerPlatform",
"description": null,
"fields": [
{
"name": "architectures",
"description": "Runner architectures supported for the platform",
"args": [
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "RunnerArchitectureConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "humanReadableName",
"description": "Human readable name of the runner platform",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "name",
"description": "Name slug of the runner platform",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "RunnerPlatformConnection",
"description": "The connection type for RunnerPlatform.",
"fields": [
{
"name": "edges",
"description": "A list of edges.",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "RunnerPlatformEdge",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "nodes",
"description": "A list of nodes.",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "RunnerPlatform",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "pageInfo",
"description": "Information to aid in pagination.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "PageInfo",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "RunnerPlatformEdge",
"description": "An edge in a connection.",
"fields": [
{
"name": "cursor",
"description": "A cursor for use in pagination.",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "node",
"description": "The item at the end of the edge.",
"args": [
],
"type": {
"kind": "OBJECT",
"name": "RunnerPlatform",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "SastCiConfiguration",
......@@ -2252,6 +2252,20 @@ Autogenerated return type of RunDASTScan.
| `errors` | String! => Array | Errors encountered during execution of the mutation. |
| `pipelineUrl` | String | URL of the pipeline that was created. |
### RunnerArchitecture
| Field | Type | Description |
| ----- | ---- | ----------- |
| `downloadLocation` | String! | Download location for the runner for the platform architecture |
| `name` | String! | Name of the runner platform architecture |
### RunnerPlatform
| Field | Type | Description |
| ----- | ---- | ----------- |
| `humanReadableName` | String! | Human readable name of the runner platform |
| `name` | String! | Name slug of the runner platform |
### SastCiConfigurationAnalyzersEntity
Represents an analyzer entity in SAST CI configuration.
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Resolvers::Ci::RunnerPlatformsResolver do
include GraphqlHelpers
describe '#resolve' do
subject(:resolve_subject) { resolve(described_class) }
it 'returns all possible runner platforms' do
expect(resolve_subject).to include(
hash_including(name: :linux), hash_including(name: :osx),
hash_including(name: :windows), hash_including(name: :docker),
hash_including(name: :kubernetes)
)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Types::Ci::RunnerArchitectureType do
specify { expect(described_class.graphql_name).to eq('RunnerArchitecture') }
it 'exposes the expected fields' do
expected_fields = %i[
name
download_location
]
expect(described_class).to have_graphql_fields(*expected_fields)
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Types::Ci::RunnerPlatformType do
specify { expect(described_class.graphql_name).to eq('RunnerPlatform') }
it 'exposes the expected fields' do
expected_fields = %i[
name
human_readable_name
architectures
]
expect(described_class).to have_graphql_fields(*expected_fields)
end
end
......@@ -22,6 +22,7 @@ RSpec.describe GitlabSchema.types['Query'] do
users
issue
instance_statistics_measurements
runner_platforms
]
expect(described_class).to have_graphql_fields(*expected_fields).at_least
......@@ -67,8 +68,16 @@ RSpec.describe GitlabSchema.types['Query'] do
describe 'instance_statistics_measurements field' do
subject { described_class.fields['instanceStatisticsMeasurements'] }
it 'returns issue' do
it 'returns instance statistics measurements' do
is_expected.to have_graphql_type(Types::Admin::Analytics::InstanceStatistics::MeasurementType.connection_type)
end
end
describe 'runner_platforms field' do
subject { described_class.fields['runnerPlatforms'] }
it 'returns runner platforms' do
is_expected.to have_graphql_type(Types::Ci::RunnerPlatformType.connection_type)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment