Commit a8606a2a authored by Max Woolf's avatar Max Woolf

Merge branch 'pedropombeiro/332193/add-back-is-shared-to-api' into 'master'

Add is_shared and runner_type to hooks and API responses

See merge request gitlab-org/gitlab!62942
parents dd31c189 342cd36c
...@@ -5,10 +5,10 @@ module Types ...@@ -5,10 +5,10 @@ module Types
class RunnerTypeEnum < BaseEnum class RunnerTypeEnum < BaseEnum
graphql_name 'CiRunnerType' graphql_name 'CiRunnerType'
::Ci::Runner.runner_types.keys.each do |type| ::Ci::Runner::AVAILABLE_TYPES.each do |runner_type|
value type.upcase, value runner_type.upcase,
description: "A runner that is #{type.tr('_', ' ')}.", description: "A runner that is #{runner_type.tr('_', ' ')}.",
value: type value: runner_type
end end
end end
end end
......
...@@ -62,8 +62,9 @@ Example response: ...@@ -62,8 +62,9 @@ Example response:
"active": true, "active": true,
"description": "test-1-20150125", "description": "test-1-20150125",
"id": 6, "id": 6,
"is_shared": false,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": false,
"runner_type": "project_type",
"name": null, "name": null,
"online": true, "online": true,
"status": "online" "status": "online"
...@@ -74,6 +75,7 @@ Example response: ...@@ -74,6 +75,7 @@ Example response:
"id": 8, "id": 8,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": false, "is_shared": false,
"runner_type": "group_type",
"name": null, "name": null,
"online": false, "online": false,
"status": "offline" "status": "offline"
...@@ -115,6 +117,7 @@ Example response: ...@@ -115,6 +117,7 @@ Example response:
"id": 1, "id": 1,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": true, "is_shared": true,
"runner_type": "instance_type",
"name": null, "name": null,
"online": true, "online": true,
"status": "online" "status": "online"
...@@ -125,6 +128,7 @@ Example response: ...@@ -125,6 +128,7 @@ Example response:
"id": 3, "id": 3,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": true, "is_shared": true,
"runner_type": "instance_type",
"name": null, "name": null,
"online": false, "online": false,
"status": "offline" "status": "offline"
...@@ -135,6 +139,7 @@ Example response: ...@@ -135,6 +139,7 @@ Example response:
"id": 6, "id": 6,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": false, "is_shared": false,
"runner_type": "project_type",
"name": null, "name": null,
"online": true, "online": true,
"status": "paused" "status": "paused"
...@@ -145,6 +150,7 @@ Example response: ...@@ -145,6 +150,7 @@ Example response:
"id": 8, "id": 8,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": false, "is_shared": false,
"runner_type": "group_type",
"name": null, "name": null,
"online": false, "online": false,
"status": "offline" "status": "offline"
...@@ -187,6 +193,7 @@ Example response: ...@@ -187,6 +193,7 @@ Example response:
"id": 6, "id": 6,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": false, "is_shared": false,
"runner_type": "project_type",
"contacted_at": "2016-01-25T16:39:48.066Z", "contacted_at": "2016-01-25T16:39:48.066Z",
"name": null, "name": null,
"online": true, "online": true,
...@@ -250,6 +257,7 @@ Example response: ...@@ -250,6 +257,7 @@ Example response:
"id": 6, "id": 6,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": false, "is_shared": false,
"runner_type": "group_type",
"contacted_at": "2016-01-25T16:39:48.066Z", "contacted_at": "2016-01-25T16:39:48.066Z",
"name": null, "name": null,
"online": true, "online": true,
...@@ -420,6 +428,7 @@ Example response: ...@@ -420,6 +428,7 @@ Example response:
"id": 8, "id": 8,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": false, "is_shared": false,
"runner_type": "project_type",
"name": null, "name": null,
"online": false, "online": false,
"status": "offline" "status": "offline"
...@@ -430,6 +439,7 @@ Example response: ...@@ -430,6 +439,7 @@ Example response:
"id": 5, "id": 5,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": true, "is_shared": true,
"runner_type": "instance_type",
"name": null, "name": null,
"online": true, "online": true,
"status": "paused" "status": "paused"
...@@ -464,6 +474,7 @@ Example response: ...@@ -464,6 +474,7 @@ Example response:
"id": 9, "id": 9,
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"is_shared": false, "is_shared": false,
"runner_type": "project_type",
"name": null, "name": null,
"online": true, "online": true,
"status": "online" "status": "online"
...@@ -522,6 +533,7 @@ Example response: ...@@ -522,6 +533,7 @@ Example response:
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"active": true, "active": true,
"is_shared": true, "is_shared": true,
"runner_type": "instance_type",
"name": "gitlab-runner", "name": "gitlab-runner",
"online": null, "online": null,
"status": "not_connected" "status": "not_connected"
...@@ -532,6 +544,7 @@ Example response: ...@@ -532,6 +544,7 @@ Example response:
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"active": true, "active": true,
"is_shared": true, "is_shared": true,
"runner_type": "instance_type",
"name": "gitlab-runner", "name": "gitlab-runner",
"online": false, "online": false,
"status": "offline" "status": "offline"
...@@ -542,6 +555,7 @@ Example response: ...@@ -542,6 +555,7 @@ Example response:
"ip_address": "127.0.0.1", "ip_address": "127.0.0.1",
"active": true, "active": true,
"is_shared": false, "is_shared": false,
"runner_type": "group_type",
"name": "gitlab-runner", "name": "gitlab-runner",
"online": null, "online": null,
"status": "not_connected" "status": "not_connected"
......
...@@ -1161,6 +1161,7 @@ X-Gitlab-Event: Pipeline Hook ...@@ -1161,6 +1161,7 @@ X-Gitlab-Event: Pipeline Hook
"id": 380987, "id": 380987,
"description": "shared-runners-manager-6.gitlab.com", "description": "shared-runners-manager-6.gitlab.com",
"active": true, "active": true,
"runner_type": "instance_type",
"is_shared": true, "is_shared": true,
"tags": [ "tags": [
"linux", "linux",
...@@ -1196,7 +1197,8 @@ X-Gitlab-Event: Pipeline Hook ...@@ -1196,7 +1197,8 @@ X-Gitlab-Event: Pipeline Hook
"id":380987, "id":380987,
"description":"shared-runners-manager-6.gitlab.com", "description":"shared-runners-manager-6.gitlab.com",
"active":true, "active":true,
"is_shared":true, "runner_type": "instance_type",
"is_shared": true,
"tags": [ "tags": [
"linux", "linux",
"docker" "docker"
...@@ -1230,6 +1232,7 @@ X-Gitlab-Event: Pipeline Hook ...@@ -1230,6 +1232,7 @@ X-Gitlab-Event: Pipeline Hook
"id": 380987, "id": 380987,
"description": "shared-runners-manager-6.gitlab.com", "description": "shared-runners-manager-6.gitlab.com",
"active": true, "active": true,
"runner_type": "instance_type",
"is_shared": true, "is_shared": true,
"tags": [ "tags": [
"linux", "linux",
...@@ -1333,6 +1336,7 @@ X-Gitlab-Event: Job Hook ...@@ -1333,6 +1336,7 @@ X-Gitlab-Event: Job Hook
}, },
"runner": { "runner": {
"active": true, "active": true,
"runner_type": "project_type",
"is_shared": false, "is_shared": false,
"id": 380987, "id": 380987,
"description": "shared-runners-manager-6.gitlab.com", "description": "shared-runners-manager-6.gitlab.com",
......
...@@ -8,6 +8,7 @@ module API ...@@ -8,6 +8,7 @@ module API
expose :ip_address expose :ip_address
expose :active expose :active
expose :instance_type?, as: :is_shared expose :instance_type?, as: :is_shared
expose :runner_type
expose :name expose :name
expose :online?, as: :online expose :online?, as: :online
expose :status expose :status
......
...@@ -83,7 +83,9 @@ module Gitlab ...@@ -83,7 +83,9 @@ module Gitlab
{ {
id: runner.id, id: runner.id,
description: runner.description, description: runner.description,
runner_type: runner.runner_type,
active: runner.active?, active: runner.active?,
is_shared: runner.instance_type?,
tags: runner.tags&.map(&:name) tags: runner.tags&.map(&:name)
} }
end end
......
...@@ -79,7 +79,9 @@ module Gitlab ...@@ -79,7 +79,9 @@ module Gitlab
{ {
id: runner.id, id: runner.id,
description: runner.description, description: runner.description,
runner_type: runner.runner_type,
active: runner.active?, active: runner.active?,
is_shared: runner.instance_type?,
tags: runner.tags&.map(&:name) tags: runner.tags&.map(&:name)
} }
end end
......
...@@ -47,6 +47,8 @@ RSpec.describe Gitlab::DataBuilder::Build do ...@@ -47,6 +47,8 @@ RSpec.describe Gitlab::DataBuilder::Build do
it { expect(data[:runner][:id]).to eq(build.runner.id) } it { expect(data[:runner][:id]).to eq(build.runner.id) }
it { expect(data[:runner][:tags]).to match_array(tag_names) } it { expect(data[:runner][:tags]).to match_array(tag_names) }
it { expect(data[:runner][:description]).to eq(build.runner.description) } it { expect(data[:runner][:description]).to eq(build.runner.description) }
it { expect(data[:runner][:runner_type]).to eq(build.runner.runner_type) }
it { expect(data[:runner][:is_shared]).to eq(build.runner.instance_type?) }
it { expect(data[:environment]).to be_nil } it { expect(data[:environment]).to be_nil }
context 'commit author_url' do context 'commit author_url' do
......
...@@ -58,8 +58,10 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do ...@@ -58,8 +58,10 @@ RSpec.describe Gitlab::DataBuilder::Pipeline do
it 'has runner attributes', :aggregate_failures do it 'has runner attributes', :aggregate_failures do
expect(runner_data[:id]).to eq(ci_runner.id) expect(runner_data[:id]).to eq(ci_runner.id)
expect(runner_data[:description]).to eq(ci_runner.description) expect(runner_data[:description]).to eq(ci_runner.description)
expect(runner_data[:runner_type]).to eq(ci_runner.runner_type)
expect(runner_data[:active]).to eq(ci_runner.active) expect(runner_data[:active]).to eq(ci_runner.active)
expect(runner_data[:tags]).to match_array(tag_names) expect(runner_data[:tags]).to match_array(tag_names)
expect(runner_data[:is_shared]).to eq(ci_runner.instance_type?)
end end
end end
......
...@@ -137,11 +137,11 @@ RSpec.describe API::Ci::Runners do ...@@ -137,11 +137,11 @@ RSpec.describe API::Ci::Runners do
get api('/runners/all', admin) get api('/runners/all', admin)
expect(json_response).to match_array [ expect(json_response).to match_array [
a_hash_including('description' => 'Project runner'), a_hash_including('description' => 'Project runner', 'is_shared' => false, 'runner_type' => 'project_type'),
a_hash_including('description' => 'Two projects runner'), a_hash_including('description' => 'Two projects runner', 'is_shared' => false, 'runner_type' => 'project_type'),
a_hash_including('description' => 'Group runner A'), a_hash_including('description' => 'Group runner A', 'is_shared' => false, 'runner_type' => 'group_type'),
a_hash_including('description' => 'Group runner B'), a_hash_including('description' => 'Group runner B', 'is_shared' => false, 'runner_type' => 'group_type'),
a_hash_including('description' => 'Shared runner') a_hash_including('description' => 'Shared runner', 'is_shared' => true, 'runner_type' => 'instance_type')
] ]
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