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
68676776
Commit
68676776
authored
Nov 07, 2020
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing install instructions for containers
parent
3a8e7fd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
49 deletions
+71
-49
app/graphql/resolvers/ci/runner_setup_resolver.rb
app/graphql/resolvers/ci/runner_setup_resolver.rb
+5
-1
spec/graphql/resolvers/ci/runner_setup_resolver_spec.rb
spec/graphql/resolvers/ci/runner_setup_resolver_spec.rb
+66
-48
No files found.
app/graphql/resolvers/ci/runner_setup_resolver.rb
View file @
68676776
...
...
@@ -27,7 +27,7 @@ module Resolvers
)
{
install_instructions:
instructions
.
install_script
,
install_instructions:
instructions
.
install_script
||
other_install_instructions
(
platform
)
,
register_instructions:
instructions
.
register_command
}
ensure
...
...
@@ -36,6 +36,10 @@ module Resolvers
private
def
other_install_instructions
(
platform
)
Gitlab
::
Ci
::
RunnerInstructions
::
OTHER_ENVIRONMENTS
[
platform
.
to_sym
][
:installation_instructions_url
]
end
def
target_param
(
args
)
project_param
(
args
[
:project_id
])
||
group_param
(
args
[
:group_id
])
||
{}
end
...
...
spec/graphql/resolvers/ci/runner_setup_resolver_spec.rb
View file @
68676776
...
...
@@ -8,77 +8,95 @@ RSpec.describe Resolvers::Ci::RunnerSetupResolver do
describe
'#resolve'
do
let
(
:user
)
{
create
(
:user
)
}
subject
(
:resolve_subject
)
{
resolve
(
described_class
,
ctx:
{
current_user:
user
},
args:
{
platform:
'linux'
,
architecture:
'amd64'
}.
merge
(
target_param
))
}
subject
(
:resolve_subject
)
{
resolve
(
described_class
,
ctx:
{
current_user:
user
},
args:
{
platform:
platform
,
architecture:
'amd64'
}.
merge
(
target_param
))
}
context
'without target parameter'
do
let
(
:target_param
)
{
{}
}
context
'with container platforms'
do
let
(
:platform
)
{
'docker'
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:target_param
)
{
{
project_id:
project
.
to_global_id
}
}
context
'when user is not admin'
do
it
'returns access error'
do
expect
{
resolve_subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
it
'returns install instructions'
do
expect
(
resolve_subject
[
:install_instructions
]).
not_to
eq
(
nil
)
end
context
'when user is admin'
do
before
do
user
.
update!
(
admin:
true
)
end
it
'returns install and register instructions'
do
expect
(
resolve_subject
.
keys
).
to
contain_exactly
(
:install_instructions
,
:register_instructions
)
expect
(
resolve_subject
.
values
).
not_to
include
(
nil
)
end
it
'does not return register instructions'
do
expect
(
resolve_subject
[
:register_instructions
]).
to
eq
(
nil
)
end
end
context
'with project target parameter'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:target_param
)
{
{
project_id:
project
.
to_global_id
}
}
context
'with regular platforms'
do
let
(
:platform
)
{
'linux'
}
context
'when user has access to admin builds on project'
do
before
do
project
.
add_maintainer
(
user
)
end
context
'without target parameter'
do
let
(
:target_param
)
{
{}
}
it
'returns install and register instructions'
do
expect
(
resolve_subject
.
keys
).
to
contain_exactly
(
:install_instructions
,
:register_instructions
)
expect
(
resolve_subject
.
values
).
not_to
include
(
nil
)
context
'when user is not admin'
do
it
'returns access error'
do
expect
{
resolve_subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
end
context
'when user does not have access to admin builds on project
'
do
before
do
project
.
add_developer
(
user
)
end
context
'when user is admin
'
do
before
do
user
.
update!
(
admin:
true
)
end
it
'returns access error'
do
expect
{
resolve_subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
it
'returns install and register instructions'
do
expect
(
resolve_subject
.
keys
).
to
contain_exactly
(
:install_instructions
,
:register_instructions
)
expect
(
resolve_subject
.
values
).
not_to
include
(
nil
)
end
end
end
end
context
'with group target parameter'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:target_param
)
{
{
group_id:
group
.
to_global_id
}
}
context
'with project target parameter'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:target_param
)
{
{
project_id:
project
.
to_global_id
}
}
context
'when user has access to admin builds on project'
do
before
do
project
.
add_maintainer
(
user
)
end
context
'when user has access to admin builds on group'
do
before
do
group
.
add_owner
(
user
)
it
'returns install and register instructions'
do
expect
(
resolve_subject
.
keys
).
to
contain_exactly
(
:install_instructions
,
:register_instructions
)
expect
(
resolve_subject
.
values
).
not_to
include
(
nil
)
end
end
it
'returns install and register instructions'
do
expect
(
resolve_subject
.
keys
).
to
contain_exactly
(
:install_instructions
,
:register_instructions
)
expect
(
resolve_subject
.
values
).
not_to
include
(
nil
)
context
'when user does not have access to admin builds on project'
do
before
do
project
.
add_developer
(
user
)
end
it
'returns access error'
do
expect
{
resolve_subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
end
context
'when user does not have access to admin builds on group'
do
before
do
group
.
add_developer
(
user
)
context
'with group target parameter'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:target_param
)
{
{
group_id:
group
.
to_global_id
}
}
context
'when user has access to admin builds on group'
do
before
do
group
.
add_owner
(
user
)
end
it
'returns install and register instructions'
do
expect
(
resolve_subject
.
keys
).
to
contain_exactly
(
:install_instructions
,
:register_instructions
)
expect
(
resolve_subject
.
values
).
not_to
include
(
nil
)
end
end
it
'returns access error'
do
expect
{
resolve_subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
context
'when user does not have access to admin builds on group'
do
before
do
group
.
add_developer
(
user
)
end
it
'returns access error'
do
expect
{
resolve_subject
}.
to
raise_error
(
Gitlab
::
Graphql
::
Errors
::
ResourceNotAvailable
)
end
end
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