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 ...@@ -80,6 +80,10 @@ module Types
description: 'Get statistics on the instance', description: 'Get statistics on the instance',
resolver: Resolvers::Admin::Analytics::InstanceStatistics::MeasurementsResolver 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 def design_management
DesignManagementObject.new(nil) DesignManagementObject.new(nil)
end end
......
...@@ -15538,6 +15538,31 @@ type Query { ...@@ -15538,6 +15538,31 @@ type Query {
sort: String sort: String
): ProjectConnection ): 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 Find Snippets visible to the current user
""" """
...@@ -16712,6 +16737,125 @@ type RunDASTScanPayload { ...@@ -16712,6 +16737,125 @@ type RunDASTScanPayload {
pipelineUrl: String 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 Represents a CI configuration of SAST
""" """
......
...@@ -2252,6 +2252,20 @@ Autogenerated return type of RunDASTScan. ...@@ -2252,6 +2252,20 @@ Autogenerated return type of RunDASTScan.
| `errors` | String! => Array | Errors encountered during execution of the mutation. | | `errors` | String! => Array | Errors encountered during execution of the mutation. |
| `pipelineUrl` | String | URL of the pipeline that was created. | | `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 ### SastCiConfigurationAnalyzersEntity
Represents an analyzer entity in SAST CI configuration. 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 ...@@ -22,6 +22,7 @@ RSpec.describe GitlabSchema.types['Query'] do
users users
issue issue
instance_statistics_measurements instance_statistics_measurements
runner_platforms
] ]
expect(described_class).to have_graphql_fields(*expected_fields).at_least expect(described_class).to have_graphql_fields(*expected_fields).at_least
...@@ -67,8 +68,16 @@ RSpec.describe GitlabSchema.types['Query'] do ...@@ -67,8 +68,16 @@ RSpec.describe GitlabSchema.types['Query'] do
describe 'instance_statistics_measurements field' do describe 'instance_statistics_measurements field' do
subject { described_class.fields['instanceStatisticsMeasurements'] } 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) is_expected.to have_graphql_type(Types::Admin::Analytics::InstanceStatistics::MeasurementType.connection_type)
end end
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 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