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
d94d185c
Commit
d94d185c
authored
Mar 10, 2022
by
orozot
Committed by
Michael Kozono
Mar 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add harbor_registry_integration feature flag
Issue:
https://gitlab.com/gitlab-org/gitlab/-/issues/353595
parent
6fd529f6
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
366 additions
and
4 deletions
+366
-4
app/controllers/groups/harbor/repositories_controller.rb
app/controllers/groups/harbor/repositories_controller.rb
+24
-0
app/controllers/projects/harbor/application_controller.rb
app/controllers/projects/harbor/application_controller.rb
+22
-0
app/controllers/projects/harbor/repositories_controller.rb
app/controllers/projects/harbor/repositories_controller.rb
+11
-0
app/views/groups/harbor/repositories/index.html.haml
app/views/groups/harbor/repositories/index.html.haml
+9
-0
app/views/projects/harbor/repositories/index.html.haml
app/views/projects/harbor/repositories/index.html.haml
+9
-0
config/feature_flags/development/harbor_registry_integration.yml
...feature_flags/development/harbor_registry_integration.yml
+8
-0
config/routes/group.rb
config/routes/group.rb
+1
-0
config/routes/project.rb
config/routes/project.rb
+3
-0
ee/spec/features/groups/navbar_spec.rb
ee/spec/features/groups/navbar_spec.rb
+13
-0
ee/spec/features/projects/navbar_spec.rb
ee/spec/features/projects/navbar_spec.rb
+13
-0
lib/sidebars/groups/menus/packages_registries_menu.rb
lib/sidebars/groups/menus/packages_registries_menu.rb
+12
-1
lib/sidebars/projects/menus/packages_registries_menu.rb
lib/sidebars/projects/menus/packages_registries_menu.rb
+12
-1
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/features/groups/navbar_spec.rb
spec/features/groups/navbar_spec.rb
+13
-0
spec/features/projects/navbar_spec.rb
spec/features/projects/navbar_spec.rb
+13
-0
spec/lib/sidebars/groups/menus/packages_registries_menu_spec.rb
...ib/sidebars/groups/menus/packages_registries_menu_spec.rb
+33
-2
spec/lib/sidebars/projects/menus/packages_registries_menu_spec.rb
.../sidebars/projects/menus/packages_registries_menu_spec.rb
+21
-0
spec/requests/groups/harbor/repositories_controller_spec.rb
spec/requests/groups/harbor/repositories_controller_spec.rb
+69
-0
spec/requests/projects/harbor/repositories_controller_spec.rb
.../requests/projects/harbor/repositories_controller_spec.rb
+69
-0
spec/support/helpers/navbar_structure_helper.rb
spec/support/helpers/navbar_structure_helper.rb
+8
-0
No files found.
app/controllers/groups/harbor/repositories_controller.rb
0 → 100644
View file @
d94d185c
# frozen_string_literal: true
module
Groups
module
Harbor
class
RepositoriesController
<
Groups
::
ApplicationController
feature_category
:integrations
before_action
:harbor_registry_enabled!
before_action
do
push_frontend_feature_flag
(
:harbor_registry_integration
)
end
def
show
render
:index
end
private
def
harbor_registry_enabled!
render_404
unless
Feature
.
enabled?
(
:harbor_registry_integration
)
end
end
end
end
app/controllers/projects/harbor/application_controller.rb
0 → 100644
View file @
d94d185c
# frozen_string_literal: true
module
Projects
module
Harbor
class
ApplicationController
<
Projects
::
ApplicationController
layout
'project'
before_action
:harbor_registry_enabled!
before_action
do
push_frontend_feature_flag
(
:harbor_registry_integration
)
end
feature_category
:integrations
private
def
harbor_registry_enabled!
render_404
unless
Feature
.
enabled?
(
:harbor_registry_integration
)
end
end
end
end
app/controllers/projects/harbor/repositories_controller.rb
0 → 100644
View file @
d94d185c
# frozen_string_literal: true
module
Projects
module
Harbor
class
RepositoriesController
<
::
Projects
::
Harbor
::
ApplicationController
def
show
render
:index
end
end
end
end
app/views/groups/harbor/repositories/index.html.haml
0 → 100644
View file @
d94d185c
-
page_title
_
(
"Harbor Registry"
)
-
@content_class
=
"limit-container-width"
unless
fluid_layout
#js-harbor-registry-list-group
{
data:
{
endpoint:
group_harbor_registries_path
(
@group
),
"no_containers_image"
=>
image_path
(
'illustrations/docker-empty-state.svg'
),
"containers_error_image"
=>
image_path
(
'illustrations/docker-error-state.svg'
),
"help_page_path"
=>
help_page_path
(
'user/packages/container_registry/index'
),
connection_error:
(
!!
@connection_error
).
to_s
,
invalid_path_error:
(
!!
@invalid_path_error
).
to_s
,
}
}
app/views/projects/harbor/repositories/index.html.haml
0 → 100644
View file @
d94d185c
-
page_title
_
(
"Harbor Registry"
)
-
@content_class
=
"limit-container-width"
unless
fluid_layout
#js-harbor-registry-list-project
{
data:
{
endpoint:
project_harbor_registry_index_path
(
@project
),
"no_containers_image"
=>
image_path
(
'illustrations/docker-empty-state.svg'
),
"containers_error_image"
=>
image_path
(
'illustrations/docker-error-state.svg'
),
"help_page_path"
=>
help_page_path
(
'user/packages/container_registry/index'
),
connection_error:
(
!!
@connection_error
).
to_s
,
invalid_path_error:
(
!!
@invalid_path_error
).
to_s
,
}
}
config/feature_flags/development/harbor_registry_integration.yml
0 → 100644
View file @
d94d185c
---
name
:
harbor_registry_integration
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81593
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/353595
milestone
:
'
14.9'
type
:
development
group
:
group::package
default_enabled
:
false
config/routes/group.rb
View file @
d94d185c
...
...
@@ -118,6 +118,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
end
resources
:container_registries
,
only:
[
:index
,
:show
],
controller:
'registry/repositories'
resources
:harbor_registries
,
only:
[
:index
,
:show
],
controller:
'harbor/repositories'
resource
:dependency_proxy
,
only:
[
:show
,
:update
]
resources
:email_campaigns
,
only: :index
...
...
config/routes/project.rb
View file @
d94d185c
...
...
@@ -545,6 +545,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources
:container_registry
,
only:
[
:index
,
:destroy
,
:show
],
# rubocop: disable Cop/PutProjectRoutesUnderScope
controller:
'registry/repositories'
resources
:harbor_registry
,
only:
[
:index
,
:show
],
# rubocop: disable Cop/PutProjectRoutesUnderScope
controller:
'harbor/repositories'
namespace
:registry
do
resources
:repository
,
only:
[]
do
# rubocop: disable Cop/PutProjectRoutesUnderScope
# We default to JSON format in the controller to avoid ambiguity.
...
...
ee/spec/features/groups/navbar_spec.rb
View file @
d94d185c
...
...
@@ -16,6 +16,7 @@ RSpec.describe 'Group navbar' do
group
.
add_maintainer
(
user
)
stub_feature_flags
(
customer_relations:
false
)
stub_group_wikis
(
false
)
stub_feature_flags
(
harbor_registry_integration:
false
)
sign_in
(
user
)
insert_package_nav
(
_
(
'Kubernetes'
))
...
...
@@ -231,4 +232,16 @@ RSpec.describe 'Group navbar' do
it_behaves_like
'verified navigation bar'
end
context
'when harbor registry is available'
do
before
do
stub_feature_flags
(
harbor_registry_integration:
true
)
insert_harbor_registry_nav
(
_
(
'Package Registry'
))
visit
group_path
(
group
)
end
it_behaves_like
'verified navigation bar'
end
end
ee/spec/features/projects/navbar_spec.rb
View file @
d94d185c
...
...
@@ -14,6 +14,7 @@ RSpec.describe 'Project navbar' do
before
do
sign_in
(
user
)
stub_feature_flags
(
harbor_registry_integration:
false
)
insert_package_nav
(
_
(
'Infrastructure'
))
insert_infrastructure_registry_nav
insert_infrastructure_google_cloud_nav
...
...
@@ -81,4 +82,16 @@ RSpec.describe 'Project navbar' do
it_behaves_like
'verified navigation bar'
end
end
context
'when harbor registry is available'
do
before
do
stub_feature_flags
(
harbor_registry_integration:
true
)
insert_harbor_registry_nav
(
_
(
'Infrastructure Registry'
))
visit
project_path
(
project
)
end
it_behaves_like
'verified navigation bar'
end
end
lib/sidebars/groups/menus/packages_registries_menu.rb
View file @
d94d185c
...
...
@@ -8,8 +8,8 @@ module Sidebars
def
configure_menu_items
add_item
(
packages_registry_menu_item
)
add_item
(
container_registry_menu_item
)
add_item
(
harbor_registry__menu_item
)
add_item
(
dependency_proxy_menu_item
)
true
end
...
...
@@ -49,6 +49,17 @@ module Sidebars
)
end
def
harbor_registry__menu_item
return
nil_menu_item
(
:harbor_registry
)
if
Feature
.
disabled?
(
:harbor_registry_integration
)
::
Sidebars
::
MenuItem
.
new
(
title:
_
(
'Harbor Registry'
),
link:
group_harbor_registries_path
(
context
.
group
),
active_routes:
{
controller:
'groups/harbor/repositories'
},
item_id: :harbor_registry
)
end
def
dependency_proxy_menu_item
setting_does_not_exist_or_is_enabled
=
!
context
.
group
.
dependency_proxy_setting
||
context
.
group
.
dependency_proxy_setting
.
enabled
...
...
lib/sidebars/projects/menus/packages_registries_menu.rb
View file @
d94d185c
...
...
@@ -9,7 +9,7 @@ module Sidebars
add_item
(
packages_registry_menu_item
)
add_item
(
container_registry_menu_item
)
add_item
(
infrastructure_registry_menu_item
)
add_item
(
harbor_registry__menu_item
)
true
end
...
...
@@ -65,6 +65,17 @@ module Sidebars
)
end
def
harbor_registry__menu_item
return
::
Sidebars
::
NilMenuItem
.
new
(
item_id: :harbor_registry
)
if
Feature
.
disabled?
(
:harbor_registry_integration
)
::
Sidebars
::
MenuItem
.
new
(
title:
_
(
'Harbor Registry'
),
link:
project_harbor_registry_index_path
(
context
.
project
),
active_routes:
{
controller: :harbor_registry
},
item_id: :harbor_registry
)
end
def
packages_registry_disabled?
!::
Gitlab
.
config
.
packages
.
enabled
||
!
can?
(
context
.
current_user
,
:read_package
,
context
.
project
)
end
...
...
locale/gitlab.pot
View file @
d94d185c
...
...
@@ -17932,6 +17932,9 @@ msgstr ""
msgid "HTTP Basic: Access denied\\nYou must use a personal access token with 'api' scope for Git over HTTP.\\nYou can generate one at %{profile_personal_access_tokens_url}"
msgstr ""
msgid "Harbor Registry"
msgstr ""
msgid "Hashed Storage must be enabled to use Geo"
msgstr ""
...
...
spec/features/groups/navbar_spec.rb
View file @
d94d185c
...
...
@@ -18,6 +18,7 @@ RSpec.describe 'Group navbar' do
stub_feature_flags
(
customer_relations:
false
)
stub_config
(
dependency_proxy:
{
enabled:
false
})
stub_config
(
registry:
{
enabled:
false
})
stub_feature_flags
(
harbor_registry_integration:
false
)
stub_group_wikis
(
false
)
group
.
add_maintainer
(
user
)
sign_in
(
user
)
...
...
@@ -70,4 +71,16 @@ RSpec.describe 'Group navbar' do
it_behaves_like
'verified navigation bar'
end
context
'when harbor registry is available'
do
before
do
stub_feature_flags
(
harbor_registry_integration:
true
)
insert_harbor_registry_nav
(
_
(
'Package Registry'
))
visit
group_path
(
group
)
end
it_behaves_like
'verified navigation bar'
end
end
spec/features/projects/navbar_spec.rb
View file @
d94d185c
...
...
@@ -16,6 +16,7 @@ RSpec.describe 'Project navbar' do
sign_in
(
user
)
stub_config
(
registry:
{
enabled:
false
})
stub_feature_flags
(
harbor_registry_integration:
false
)
insert_package_nav
(
_
(
'Infrastructure'
))
insert_infrastructure_registry_nav
insert_infrastructure_google_cloud_nav
...
...
@@ -76,4 +77,16 @@ RSpec.describe 'Project navbar' do
it_behaves_like
'verified navigation bar'
end
context
'when harbor registry is available'
do
before
do
stub_feature_flags
(
harbor_registry_integration:
true
)
insert_harbor_registry_nav
(
_
(
'Infrastructure Registry'
))
visit
project_path
(
project
)
end
it_behaves_like
'verified navigation bar'
end
end
spec/lib/sidebars/groups/menus/packages_registries_menu_spec.rb
View file @
d94d185c
...
...
@@ -23,6 +23,7 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do
context
'when menu does not have any menu item to show'
do
it
'returns false'
do
stub_feature_flags
(
harbor_registry_integration:
false
)
stub_container_registry_config
(
enabled:
false
)
stub_config
(
packages:
{
enabled:
false
})
stub_config
(
dependency_proxy:
{
enabled:
false
})
...
...
@@ -35,11 +36,13 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do
describe
'#link'
do
let
(
:registry_enabled
)
{
true
}
let
(
:packages_enabled
)
{
true
}
let
(
:harbor_registry_integration
)
{
true
}
before
do
stub_container_registry_config
(
enabled:
registry_enabled
)
stub_config
(
packages:
{
enabled:
packages_enabled
})
stub_config
(
dependency_proxy:
{
enabled:
true
})
stub_feature_flags
(
harbor_registry_integration:
harbor_registry_integration
)
end
subject
{
menu
.
link
}
...
...
@@ -60,12 +63,20 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do
context
'when Container Registry is not visible'
do
let
(
:registry_enabled
)
{
false
}
it
'menu link points to Harbor Registry page'
do
expect
(
subject
).
to
eq
find_menu
(
menu
,
:harbor_registry
).
link
end
context
'when Harbor Registry is not visible'
do
let
(
:harbor_registry_integration
)
{
false
}
it
'menu link points to Dependency Proxy page'
do
expect
(
subject
).
to
eq
find_menu
(
menu
,
:dependency_proxy
).
link
end
end
end
end
end
describe
'Menu items'
do
subject
{
find_menu
(
menu
,
item_id
)
}
...
...
@@ -175,6 +186,26 @@ RSpec.describe Sidebars::Groups::Menus::PackagesRegistriesMenu do
it_behaves_like
'the menu entry is not available'
end
end
describe
'Harbor Registry'
do
let
(
:item_id
)
{
:harbor_registry
}
before
do
stub_feature_flags
(
harbor_registry_integration:
harbor_registry_enabled
)
end
context
'when config harbor registry setting is disabled'
do
let
(
:harbor_registry_enabled
)
{
false
}
it_behaves_like
'the menu entry is not available'
end
context
'when config harbor registry setting is enabled'
do
let
(
:harbor_registry_enabled
)
{
true
}
it_behaves_like
'the menu entry is available'
end
end
end
private
...
...
spec/lib/sidebars/projects/menus/packages_registries_menu_spec.rb
View file @
d94d185c
...
...
@@ -33,6 +33,7 @@ RSpec.describe Sidebars::Projects::Menus::PackagesRegistriesMenu do
before
do
stub_container_registry_config
(
enabled:
registry_enabled
)
stub_config
(
packages:
{
enabled:
packages_enabled
})
stub_feature_flags
(
harbor_registry_integration:
false
)
end
context
'when Packages Registry is visible'
do
...
...
@@ -144,5 +145,25 @@ RSpec.describe Sidebars::Projects::Menus::PackagesRegistriesMenu do
end
end
end
describe
'Harbor Registry'
do
let
(
:item_id
)
{
:harbor_registry
}
context
'when config harbor registry setting is disabled'
do
it
'does not add the menu item to the list'
do
stub_feature_flags
(
harbor_registry_integration:
false
)
is_expected
.
to
be_nil
end
end
context
'when config harbor registry setting is enabled'
do
it
'the menu item is added to list of menu items'
do
stub_feature_flags
(
harbor_registry_integration:
true
)
is_expected
.
not_to
be_nil
end
end
end
end
end
spec/requests/groups/harbor/repositories_controller_spec.rb
0 → 100644
View file @
d94d185c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Groups
::
Harbor
::
RepositoriesController
do
let_it_be
(
:group
,
reload:
true
)
{
create
(
:group
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
shared_examples
'responds with 404 status'
do
it
'returns 404'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
shared_examples
'responds with 200 status'
do
it
'renders the index template'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:index
)
end
end
before
do
stub_feature_flags
(
harbor_registry_integration:
true
)
group
.
add_reporter
(
user
)
login_as
(
user
)
end
describe
'GET #index'
do
subject
do
get
group_harbor_registries_path
(
group
)
response
end
context
'with harbor registry feature flag enabled'
do
it_behaves_like
'responds with 200 status'
end
context
'with harbor registry feature flag disabled'
do
before
do
stub_feature_flags
(
harbor_registry_integration:
false
)
end
it_behaves_like
'responds with 404 status'
end
end
describe
'GET #show'
do
subject
do
get
group_harbor_registry_path
(
group
,
1
)
response
end
context
'with harbor registry feature flag enabled'
do
it_behaves_like
'responds with 200 status'
end
context
'with harbor registry feature flag disabled'
do
before
do
stub_feature_flags
(
harbor_registry_integration:
false
)
end
it_behaves_like
'responds with 404 status'
end
end
end
spec/requests/projects/harbor/repositories_controller_spec.rb
0 → 100644
View file @
d94d185c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Projects
::
Harbor
::
RepositoriesController
do
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
shared_examples
'responds with 404 status'
do
it
'returns 404'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
shared_examples
'responds with 200 status'
do
it
'renders the index template'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:index
)
end
end
before
do
stub_feature_flags
(
harbor_registry_integration:
true
)
project
.
add_developer
(
user
)
sign_in
(
user
)
end
describe
'GET #index'
do
subject
do
get
project_harbor_registry_index_path
(
project
)
response
end
context
'with harbor registry feature flag enabled'
do
it_behaves_like
'responds with 200 status'
end
context
'with harbor registry feature flag disabled'
do
before
do
stub_feature_flags
(
harbor_registry_integration:
false
)
end
it_behaves_like
'responds with 404 status'
end
end
describe
'GET #show'
do
subject
do
get
project_harbor_registry_path
(
project
,
1
)
response
end
context
'with harbor registry feature flag enabled'
do
it_behaves_like
'responds with 200 status'
end
context
'with harbor registry feature flag disabled'
do
before
do
stub_feature_flags
(
harbor_registry_integration:
false
)
end
it_behaves_like
'responds with 404 status'
end
end
end
spec/support/helpers/navbar_structure_helper.rb
View file @
d94d185c
...
...
@@ -77,6 +77,14 @@ module NavbarStructureHelper
)
end
def
insert_harbor_registry_nav
(
within
)
insert_after_sub_nav_item
(
within
,
within:
_
(
'Packages & Registries'
),
new_sub_nav_item_name:
_
(
'Harbor Registry'
)
)
end
def
insert_infrastructure_google_cloud_nav
insert_after_sub_nav_item
(
_
(
'Terraform'
),
...
...
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