Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
g5k-api
Commits
9ad255b6
Commit
9ad255b6
authored
Apr 03, 2017
by
MARGERY David
Committed by
Lucas Nussbaum
Jun 07, 2017
Browse files
move code to set sane defaults in the params to a separate function
parent
b5655cc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/controllers/resources_controller.rb
View file @
9ad255b6
...
...
@@ -29,28 +29,13 @@ class ResourcesController < ApplicationController
def
fetch
(
path
)
allow
:get
;
vary_on
:accept
Rails
.
logger
.
info
"Fetching
#{
path
}
"
branch
=
params
[
:branch
]
||
'master'
branch
=
[
'origin'
,
branch
].
join
(
"/"
)
unless
Rails
.
env
==
"test"
# abasu : Added code for getting 'queues' element in hash params - 11.12.2015
# abasu : In request to feature bug ref. #6363
# abasu : params_queues is the array with 'queues' values passed in 'params'
if
params
[
:queues
].
nil?
# no filter, so assign everything except "production"
params
[
:queues
]
=
[
"admin"
,
"default"
]
# As of 11.12.2015 the queues accepted are:
# "all" or any combination of "admin", "default", "production"
else
if
params
[
:queues
]
==
"all"
# for use by sys-admin
params
[
:queues
]
=
[
"admin"
,
"default"
,
"production"
]
else
params
[
:queues
]
=
params
[
:queues
].
split
(
","
)
end
# if params[:queues] == "all"
end
# if params[:queues].nil?
object
=
lookup_path
(
path
,
branch
,
params
)
enrich_params
(
params
)
object
=
lookup_path
(
path
,
params
)
raise
NotFound
,
"Cannot find resource
#{
path
}
"
if
object
.
nil?
if
object
.
has_key?
(
'items'
)
object
[
'links'
]
=
links_for_collection
(
object
)
object
[
'items'
].
each
{
|
item
|
...
...
@@ -91,10 +76,32 @@ class ResourcesController < ApplicationController
end
end
def
lookup_path
(
path
,
branch
,
params
)
def
enrich_params
(
params
)
branch
=
params
[
:branch
]
||
'master'
branch
=
[
'origin'
,
branch
].
join
(
"/"
)
unless
Rails
.
env
==
"test"
params
[
:branch
]
=
branch
# abasu : Added code for getting 'queues' element in hash params - 11.12.2015
# abasu : In request to feature bug ref. #6363
# abasu : params_queues is the array with 'queues' values passed in 'params'
if
params
[
:queues
].
nil?
# no filter, so assign everything except "production"
params
[
:queues
]
=
[
"admin"
,
"default"
]
# As of 11.12.2015 the queues accepted are:
# "all" or any combination of "admin", "default", "production"
else
if
params
[
:queues
]
==
"all"
# for use by sys-admin
params
[
:queues
]
=
[
"admin"
,
"default"
,
"production"
]
else
params
[
:queues
]
=
params
[
:queues
].
split
(
","
)
end
# if params[:queues] == "all"
end
# if params[:queues].nil?
end
def
lookup_path
(
path
,
params
)
object
=
EM
::
Synchrony
.
sync
repository
.
async_find
(
path
.
gsub
(
/\/?platforms/
,
''
),
:branch
=>
branch
,
:branch
=>
params
[
:
branch
]
,
:version
=>
params
[
:version
]
)
...
...
Write
Preview
Supports
Markdown
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