Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5fb63a55
Commit
5fb63a55
authored
Sep 30, 2020
by
Jose Ivan Vargas
Committed by
Kerri Miller
Sep 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add runner setup controllers
Add runner setup controllers
parent
185b5541
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
159 additions
and
1 deletion
+159
-1
app/controllers/admin/runners_controller.rb
app/controllers/admin/runners_controller.rb
+7
-1
app/controllers/concerns/runner_setup_scripts.rb
app/controllers/concerns/runner_setup_scripts.rb
+25
-0
app/controllers/groups/settings/ci_cd_controller.rb
app/controllers/groups/settings/ci_cd_controller.rb
+6
-0
app/controllers/projects/settings/ci_cd_controller.rb
app/controllers/projects/settings/ci_cd_controller.rb
+6
-0
app/controllers/runner_setup_controller.rb
app/controllers/runner_setup_controller.rb
+7
-0
changelogs/unreleased/jivanvl-runner-guided-install-backend.yml
...logs/unreleased/jivanvl-runner-guided-install-backend.yml
+5
-0
config/routes.rb
config/routes.rb
+2
-0
config/routes/admin.rb
config/routes/admin.rb
+1
-0
config/routes/group.rb
config/routes/group.rb
+1
-0
config/routes/project.rb
config/routes/project.rb
+1
-0
spec/controllers/admin/runners_controller_spec.rb
spec/controllers/admin/runners_controller_spec.rb
+17
-0
spec/controllers/groups/settings/ci_cd_controller_spec.rb
spec/controllers/groups/settings/ci_cd_controller_spec.rb
+21
-0
spec/controllers/projects/settings/ci_cd_controller_spec.rb
spec/controllers/projects/settings/ci_cd_controller_spec.rb
+17
-0
spec/controllers/runner_setup_controller_spec.rb
spec/controllers/runner_setup_controller_spec.rb
+21
-0
spec/routing/admin_routing_spec.rb
spec/routing/admin_routing_spec.rb
+6
-0
spec/routing/group_routing_spec.rb
spec/routing/group_routing_spec.rb
+4
-0
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+6
-0
spec/routing/routing_spec.rb
spec/routing/routing_spec.rb
+6
-0
No files found.
app/controllers/admin/runners_controller.rb
View file @
5fb63a55
# frozen_string_literal: true
class
Admin::RunnersController
<
Admin
::
ApplicationController
before_action
:runner
,
except:
[
:index
,
:tag_list
]
include
RunnerSetupScripts
before_action
:runner
,
except:
[
:index
,
:tag_list
,
:runner_setup_scripts
]
def
index
finder
=
Ci
::
RunnersFinder
.
new
(
current_user:
current_user
,
params:
params
)
...
...
@@ -53,6 +55,10 @@ class Admin::RunnersController < Admin::ApplicationController
render
json:
ActsAsTaggableOn
::
TagSerializer
.
new
.
represent
(
tags
)
end
def
runner_setup_scripts
private_runner_setup_scripts
end
private
def
runner
...
...
app/controllers/concerns/runner_setup_scripts.rb
0 → 100644
View file @
5fb63a55
# frozen_string_literal: true
module
RunnerSetupScripts
extend
ActiveSupport
::
Concern
private
def
private_runner_setup_scripts
(
**
kwargs
)
instructions
=
Gitlab
::
Ci
::
RunnerInstructions
.
new
(
current_user:
current_user
,
os:
script_params
[
:os
],
arch:
script_params
[
:arch
],
**
kwargs
)
output
=
{
install:
instructions
.
install_script
,
register:
instructions
.
register_command
}
if
instructions
.
errors
.
any?
render
json:
{
errors:
instructions
.
errors
},
status: :bad_request
else
render
json:
output
end
end
def
script_params
params
.
permit
(
:os
,
:arch
)
end
end
app/controllers/groups/settings/ci_cd_controller.rb
View file @
5fb63a55
...
...
@@ -3,6 +3,8 @@
module
Groups
module
Settings
class
CiCdController
<
Groups
::
ApplicationController
include
RunnerSetupScripts
skip_cross_project_access_check
:show
before_action
:authorize_admin_group!
before_action
:authorize_update_max_artifacts_size!
,
only:
[
:update
]
...
...
@@ -49,6 +51,10 @@ module Groups
redirect_to
group_settings_ci_cd_path
end
def
runner_setup_scripts
private_runner_setup_scripts
(
group:
group
)
end
private
def
define_variables
...
...
app/controllers/projects/settings/ci_cd_controller.rb
View file @
5fb63a55
...
...
@@ -3,6 +3,8 @@
module
Projects
module
Settings
class
CiCdController
<
Projects
::
ApplicationController
include
RunnerSetupScripts
before_action
:authorize_admin_pipeline!
before_action
:define_variables
before_action
do
...
...
@@ -52,6 +54,10 @@ module Projects
redirect_to
namespace_project_settings_ci_cd_path
end
def
runner_setup_scripts
private_runner_setup_scripts
(
project:
@project
)
end
private
def
update_params
...
...
app/controllers/runner_setup_controller.rb
0 → 100644
View file @
5fb63a55
# frozen_string_literal: true
class
RunnerSetupController
<
ApplicationController
def
platforms
render
json:
Gitlab
::
Ci
::
RunnerInstructions
::
OS
.
merge
(
Gitlab
::
Ci
::
RunnerInstructions
::
OTHER_ENVIRONMENTS
)
end
end
changelogs/unreleased/jivanvl-runner-guided-install-backend.yml
0 → 100644
View file @
5fb63a55
---
title
:
Add runner setup methods
merge_request
:
42878
author
:
type
:
added
config/routes.rb
View file @
5fb63a55
...
...
@@ -89,6 +89,8 @@ Rails.application.routes.draw do
resources
:metrics
,
only:
[
:index
]
mount
Peek
::
Railtie
=>
'/peek'
,
as:
'peek_routes'
get
'runner_setup/platforms'
=>
'runner_setup#platforms'
# Boards resources shared between group and projects
resources
:boards
,
only:
[]
do
resources
:lists
,
module: :boards
,
only:
[
:index
,
:create
,
:update
,
:destroy
]
do
...
...
config/routes/admin.rb
View file @
5fb63a55
...
...
@@ -151,6 +151,7 @@ namespace :admin do
collection
do
get
:tag_list
,
format: :json
get
:runner_setup_scripts
,
format: :json
end
end
...
...
config/routes/group.rb
View file @
5fb63a55
...
...
@@ -35,6 +35,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
put
:reset_registration_token
patch
:update_auto_devops
post
:create_deploy_token
,
path:
'deploy_token/create'
,
to:
'repository#create_deploy_token'
get
:runner_setup_scripts
,
format: :json
end
resource
:repository
,
only:
[
:show
],
controller:
'repository'
do
...
...
config/routes/project.rb
View file @
5fb63a55
...
...
@@ -93,6 +93,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post
:reset_cache
put
:reset_registration_token
post
:create_deploy_token
,
path:
'deploy_token/create'
,
to:
'repository#create_deploy_token'
get
:runner_setup_scripts
,
format: :json
end
resource
:operations
,
only:
[
:show
,
:update
]
do
...
...
spec/controllers/admin/runners_controller_spec.rb
View file @
5fb63a55
...
...
@@ -151,4 +151,21 @@ RSpec.describe Admin::RunnersController do
expect
(
runner
.
active
).
to
eq
(
false
)
end
end
describe
'GET #runner_setup_scripts'
do
it
'renders the setup scripts'
do
get
:runner_setup_scripts
,
params:
{
os:
'linux'
,
arch:
'amd64'
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
have_key
(
"install"
)
expect
(
json_response
).
to
have_key
(
"register"
)
end
it
'renders errors if they occur'
do
get
:runner_setup_scripts
,
params:
{
os:
'foo'
,
arch:
'bar'
}
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
have_key
(
"errors"
)
end
end
end
spec/controllers/groups/settings/ci_cd_controller_spec.rb
View file @
5fb63a55
...
...
@@ -225,4 +225,25 @@ RSpec.describe Groups::Settings::CiCdController do
end
end
end
describe
'GET #runner_setup_scripts'
do
before
do
group
.
add_owner
(
user
)
end
it
'renders the setup scripts'
do
get
:runner_setup_scripts
,
params:
{
os:
'linux'
,
arch:
'amd64'
,
group_id:
group
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
have_key
(
"install"
)
expect
(
json_response
).
to
have_key
(
"register"
)
end
it
'renders errors if they occur'
do
get
:runner_setup_scripts
,
params:
{
os:
'foo'
,
arch:
'bar'
,
group_id:
group
}
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
have_key
(
"errors"
)
end
end
end
spec/controllers/projects/settings/ci_cd_controller_spec.rb
View file @
5fb63a55
...
...
@@ -266,4 +266,21 @@ RSpec.describe Projects::Settings::CiCdController do
end
end
end
describe
'GET #runner_setup_scripts'
do
it
'renders the setup scripts'
do
get
:runner_setup_scripts
,
params:
{
os:
'linux'
,
arch:
'amd64'
,
namespace_id:
project
.
namespace
,
project_id:
project
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
have_key
(
"install"
)
expect
(
json_response
).
to
have_key
(
"register"
)
end
it
'renders errors if they occur'
do
get
:runner_setup_scripts
,
params:
{
os:
'foo'
,
arch:
'bar'
,
namespace_id:
project
.
namespace
,
project_id:
project
}
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
).
to
have_key
(
"errors"
)
end
end
end
spec/controllers/runner_setup_controller_spec.rb
0 → 100644
View file @
5fb63a55
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
RunnerSetupController
do
let
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
end
describe
'GET #platforms'
do
it
'renders the platforms'
do
get
:platforms
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
have_key
(
"windows"
)
expect
(
json_response
).
to
have_key
(
"kubernetes"
)
end
end
end
spec/routing/admin_routing_spec.rb
View file @
5fb63a55
...
...
@@ -184,3 +184,9 @@ RSpec.describe Admin::PlanLimitsController, "routing" do
expect
(
post
(
"/admin/plan_limits"
)).
to
route_to
(
'admin/plan_limits#create'
)
end
end
RSpec
.
describe
Admin
::
RunnersController
,
"routing"
do
it
"to #runner_setup_scripts"
do
expect
(
get
(
"/admin/runners/runner_setup_scripts"
)).
to
route_to
(
'admin/runners#runner_setup_scripts'
)
end
end
spec/routing/group_routing_spec.rb
View file @
5fb63a55
...
...
@@ -43,6 +43,10 @@ RSpec.shared_examples 'groups routing' do
expect
(
get
(
"/groups/
#{
group_path
}
/-/milestones"
)).
to
route_to
(
'groups/milestones#index'
,
group_id:
group_path
)
end
it
"to #runner_setup_scripts"
do
expect
(
get
(
"/groups/
#{
group_path
}
/-/settings/ci_cd/runner_setup_scripts"
)).
to
route_to
(
'groups/settings/ci_cd#runner_setup_scripts'
,
group_id:
group_path
)
end
it
'routes to the avatars controller'
do
expect
(
delete
(
"/groups/
#{
group_path
}
/-/avatar"
))
.
to
route_to
(
group_id:
group_path
,
...
...
spec/routing/project_routing_spec.rb
View file @
5fb63a55
...
...
@@ -731,6 +731,12 @@ RSpec.describe 'project routing' do
end
end
describe
Projects
::
Settings
::
CiCdController
,
'routing'
do
it
"to #runner_setup_scripts"
do
expect
(
get
(
"/gitlab/gitlabhq/-/settings/ci_cd/runner_setup_scripts"
)).
to
route_to
(
'projects/settings/ci_cd#runner_setup_scripts'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
)
end
end
describe
Projects
::
TemplatesController
,
'routing'
do
describe
'#show'
do
def
show_with_template_type
(
template_type
)
...
...
spec/routing/routing_spec.rb
View file @
5fb63a55
...
...
@@ -374,3 +374,9 @@ RSpec.describe Snippets::BlobsController, "routing" do
.
to
route_to
(
'snippets/blobs#raw'
,
snippet_id:
'1'
,
ref:
'master'
,
path:
'lib/version.rb'
)
end
end
RSpec
.
describe
RunnerSetupController
,
'routing'
do
it
'to #platforms'
do
expect
(
get
(
"/-/runner_setup/platforms"
)).
to
route_to
(
'runner_setup#platforms'
)
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment