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
7827d187
Commit
7827d187
authored
Sep 20, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor API interface
parent
d36a4504
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
55 deletions
+73
-55
app/controllers/projects/feature_flags_controller.rb
app/controllers/projects/feature_flags_controller.rb
+0
-1
app/helpers/feature_flags_helper.rb
app/helpers/feature_flags_helper.rb
+11
-0
app/views/projects/feature_flags/_configure_feature_flags_modal.html.haml
...ts/feature_flags/_configure_feature_flags_modal.html.haml
+11
-12
lib/api/api.rb
lib/api/api.rb
+1
-1
lib/api/feature_flags.rb
lib/api/feature_flags.rb
+50
-0
lib/api/unleash.rb
lib/api/unleash.rb
+0
-41
No files found.
app/controllers/projects/feature_flags_controller.rb
View file @
7827d187
...
...
@@ -9,7 +9,6 @@ class Projects::FeatureFlagsController < Projects::ApplicationController
def
index
@feature_flags
=
project
.
operations_feature_flags
@unleash_instanceid
=
project
.
feature_flag_access_token
end
def
new
...
...
app/helpers/feature_flags_helper.rb
0 → 100644
View file @
7827d187
# frozen_string_literal: true
module
FeatureFlagsHelper
def
unleash_api_url
(
project
)
"
#{
root_url
(
only_path:
false
)
}
api/v4/feature_flags/projects/
#{
project
.
id
}
/unleash"
end
def
unleash_api_instanceid
(
project
)
project
.
feature_flag_access_token
end
end
app/views/projects/feature_flags/_configure_feature_flags_modal.html.haml
View file @
7827d187
...
...
@@ -15,9 +15,8 @@
.form-group
=
label_tag
:api_url
,
s_
(
'FeatureFlags|API URL'
),
class:
'label-light'
.input-group
-
unleash_api_url
=
"
#{
root_url
(
only_path:
false
)
}
api/v4/unleash"
=
text_field_tag
:api_url
,
unleash_api_url
,
unleash_api_url
(
@project
)
,
readonly:
true
,
class:
"form-control js-select-on-focus"
%span
.input-group-append
...
...
@@ -28,29 +27,29 @@
class:
"input-group-text btn btn-default"
)
.form-group
=
label_tag
:
application_name
,
s_
(
'FeatureFlags|Application name
'
),
class:
'label-light'
=
label_tag
:
instance_id
,
s_
(
'FeatureFlags|Instance ID
'
),
class:
'label-light'
.input-group
=
text_field_tag
:
application_name
,
@project
.
id
,
=
text_field_tag
:
instance_id
,
unleash_api_instanceid
(
@project
)
,
readonly:
true
,
class:
"form-control js-select-on-focus"
%span
.input-group-append
=
clipboard_button
(
target:
'#
application_name
'
,
title:
_
(
"Copy
name
to clipboard"
),
=
clipboard_button
(
target:
'#
instance_id
'
,
title:
_
(
"Copy
ID
to clipboard"
),
placement:
"left"
,
container:
'#configure-feature-flags-modal'
,
class:
"input-group-text btn btn-default"
)
.form-group
=
label_tag
:
instance_id
,
s_
(
'FeatureFlags|Instance ID
'
),
class:
'label-light'
=
label_tag
:
application_name
,
s_
(
'FeatureFlags|Application name
'
),
class:
'label-light'
.input-group
=
text_field_tag
:
instance_id
,
@unleash_instanceid
,
=
text_field_tag
:
application_name
,
"production"
,
readonly:
true
,
class:
"form-control js-select-on-focus"
%span
.input-group-append
=
clipboard_button
(
target:
'#
instance_id
'
,
title:
_
(
"Copy
ID
to clipboard"
),
=
clipboard_button
(
target:
'#
application_name
'
,
title:
_
(
"Copy
name
to clipboard"
),
placement:
"left"
,
container:
'#configure-feature-flags-modal'
,
class:
"input-group-text btn btn-default"
)
lib/api/api.rb
View file @
7827d187
...
...
@@ -108,6 +108,7 @@ module API
mount
::
API
::
Environments
mount
::
API
::
Events
mount
::
API
::
Features
mount
::
API
::
FeatureFlags
mount
::
API
::
Files
mount
::
API
::
GroupBoards
mount
::
API
::
GroupMilestones
...
...
@@ -158,7 +159,6 @@ module API
mount
::
API
::
Templates
mount
::
API
::
Todos
mount
::
API
::
Triggers
mount
::
API
::
Unleash
mount
::
API
::
Users
mount
::
API
::
Variables
mount
::
API
::
Version
...
...
lib/api/feature_flags.rb
0 → 100644
View file @
7827d187
module
API
class
FeatureFlags
<
Grape
::
API
include
PaginationParams
resource
:feature_flags
do
resource
:projects
,
requirements:
API
::
PROJECT_ENDPOINT_REQUIREMENTS
do
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
route_param
:id
do
resource
:unleash
do
before
do
authenticate_by_unleash_access_token!
end
get
'features'
do
present
project
,
with:
Entities
::
UnleashFeatures
end
post
'client/register'
do
# not supported yet
status
:ok
end
post
'client/metrics'
do
# not supported yet
status
:ok
end
end
end
end
helpers
do
def
project
@project
||=
find_project
(
params
[
:id
])
end
def
unleash_instanceid
params
[
:instanceid
]
||
env
[
:HTTP_UNLEASH_INSTANCEID
]
end
def
authenticate_by_unleash_access_token!
unless
Operations
::
FeatureFlagsAccessToken
.
find_by
(
token:
unleash_instanceid
,
project:
project
)
unauthorized!
end
end
end
end
end
end
lib/api/unleash.rb
deleted
100644 → 0
View file @
d36a4504
module
API
class
Unleash
<
Grape
::
API
include
PaginationParams
before
do
unauthorized!
unless
access_token
end
get
':unleash/features'
do
present
@project
,
with:
Entities
::
UnleashFeatures
end
post
'unleash/client/register'
do
status
:ok
end
post
'unleash/client/metrics'
do
status
:ok
end
private
helpers
do
def
project
@project
||=
find_project
(
unleash_appname
)
end
def
access_token
@access_token
||=
ProjectFeatureFlagsAccessToken
.
find_by
(
token:
unleash_instanceid
,
project:
project
)
end
def
unleash_appname
params
[
:appname
]
||
env
[
:HTTP_UNLEASH_APPNAME
]
end
def
unleash_instanceid
params
[
:instanceid
]
||
env
[
:HTTP_UNLEASH_INSTANCEID
]
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