Commit c2c871e5 authored by Mathieu Parent's avatar Mathieu Parent

Debian CRUD group distribution endpoints

Create/Read/Update/Delete group distributions

Changelog: added
parent 837a6eba
......@@ -117,6 +117,7 @@ class GroupPolicy < BasePolicy
enable :delete_metrics_dashboard_annotation
enable :update_metrics_dashboard_annotation
enable :create_custom_emoji
enable :create_package
enable :create_package_settings
end
......@@ -134,6 +135,7 @@ class GroupPolicy < BasePolicy
end
rule { maintainer }.policy do
enable :destroy_package
enable :create_projects
enable :admin_pipeline
enable :admin_build
......
---
name: debian_group_packages
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66188
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/336536
milestone: '14.1'
type: development
group: group::package
default_enabled: false
......@@ -4,7 +4,11 @@ group: Package
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
# Debian API
# Debian API **(FREE SELF)**
> - Debian API [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42670) in GitLab 13.5.
> - Debian group API [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66188) in GitLab 14.2.
> - [Deployed behind a feature flag](../../user/feature_flags.md), disabled by default.
This is the API documentation for [Debian](../../user/packages/debian_repository/index.md).
......@@ -24,8 +28,10 @@ for details on which headers and token types are supported.
## Enable the Debian API
The Debian API for GitLab is behind a feature flag that is disabled by default. GitLab
administrators with access to the GitLab Rails console can enable this API for your instance.
Debian repository support is still a work in progress. It's gated behind a feature flag that's
**disabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
can opt to enable it.
To enable it:
......@@ -39,6 +45,13 @@ To disable it:
Feature.disable(:debian_packages)
```
## Enable the Debian group API
The Debian group API is behind a feature flag that is disabled by default.
[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
can opt to enable it. To enable it, follow the instructions in
[Enable the Debian group API](../../user/packages/debian_repository/index.md#enable-the-debian-group-api).
## Upload a package file
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62028) in GitLab 14.0.
......
......@@ -4,30 +4,27 @@ group: Package
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
# Debian group distributions API **(FREE)**
# Debian group distributions API **(FREE SELF)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/5835) in GitLab 14.0.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66188) in GitLab 14.2.
> - [Deployed behind a feature flag](../../user/feature_flags.md), disabled by default.
See the [Debian package registry documentation](../../user/packages/debian_repository/index.md)
for more information about working with Debian packages.
This is the reference documentation for the Debian group distributions API. This API is behind a
feature flag that is disabled by default. To use this API, you must [enable it](#enable-the-debian-group-api).
## Enable Debian repository feature
WARNING:
This API is under development and is not meant for production use.
Debian repository support is gated behind a feature flag that is **disabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
can opt to enable it.
To enable it:
```ruby
Feature.enable(:debian_packages)
```
For more information about working with Debian packages, see the
[Debian package registry documentation](../../user/packages/debian_repository/index.md).
To disable it:
## Enable the Debian group API
```ruby
Feature.disable(:debian_packages)
```
Debian group repository support is still a work in progress. It's gated behind a feature flag that's
**disabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
can opt to enable it. To enable it, follow the instructions in
[Enable the Debian group API](../../user/packages/debian_repository/index.md#enable-the-debian-group-api).
## List all Debian distributions in a group
......
......@@ -4,16 +4,24 @@ group: Package
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
# Debian project distributions API **(FREE)**
# Debian project distributions API **(FREE SELF)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/5835) in GitLab 14.0.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42670) in GitLab 13.5.
> - [Deployed behind a feature flag](../../user/feature_flags.md), disabled by default.
See the [Debian package registry documentation](../../user/packages/debian_repository/index.md)
for more information about working with Debian packages.
This is the reference documentation for the Debian project distributions API. This API is behind a
feature flag that is disabled by default. To use this API, you must [enable the Debian API](#enable-the-debian-api).
## Enable Debian repository feature
WARNING:
This API is under development and is not meant for production use.
Debian repository support is gated behind a feature flag that is **disabled by default**.
For more information about working with Debian packages, see the
[Debian package registry documentation](../../user/packages/debian_repository/index.md).
## Enable the Debian API
Debian repository support is still a work in progress. It's gated behind a feature flag that's
**disabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
can opt to enable it.
......
......@@ -6,7 +6,9 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Debian packages in the Package Registry **(FREE)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/5835) in GitLab 14.1.
> - Debian API [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42670) in GitLab 13.5.
> - Debian group API [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66188) in GitLab 14.2.
> - [Deployed behind a feature flag](../../feature_flags.md), disabled by default.
WARNING:
The Debian package registry for GitLab is under development and isn't ready for production use due to
......@@ -20,7 +22,7 @@ Project and Group packages are supported.
For documentation of the specific API endpoints that Debian package manager
clients use, see the [Debian API documentation](../../../api/packages/debian.md).
## Enable Debian repository feature
## Enable the Debian API **(FREE SELF)**
Debian repository support is still a work in progress. It's gated behind a feature flag that's
**disabled by default**.
......@@ -39,6 +41,22 @@ To disable it:
Feature.disable(:debian_packages)
```
## Enable the Debian group API **(FREE SELF)**
The Debian group repository is also behind a second feature flag that is disabled by default.
To enable it:
```ruby
Feature.enable(:debian_group_packages)
```
To disable it:
```ruby
Feature.disable(:debian_group_packages)
```
## Build a Debian package
Creating a Debian package is documented [on the Debian Wiki](https://wiki.debian.org/Packaging).
......
......@@ -188,6 +188,7 @@ module API
mount ::API::GroupMilestones
mount ::API::Groups
mount ::API::GroupContainerRepositories
mount ::API::GroupDebianDistributions
mount ::API::GroupVariables
mount ::API::ImportBitbucketServer
mount ::API::ImportGithub
......
......@@ -80,6 +80,8 @@ module API
use :optional_distribution_params
end
get '/' do
authorize_read_package!(project_or_group)
distribution_params = declared_params(include_missing: false)
distributions = ::Packages::Debian::DistributionsFinder.new(project_or_group, distribution_params).execute
......@@ -96,6 +98,8 @@ module API
requires :codename, type: String, regexp: Gitlab::Regex.debian_distribution_regex, desc: 'The Debian Codename'
end
get '/:codename' do
authorize_read_package!(project_or_group)
distribution = ::Packages::Debian::DistributionsFinder.new(project_or_group, codename: params[:codename]).execute.last!
present distribution, with: ::API::Entities::Packages::Debian::Distribution
......
......@@ -18,7 +18,7 @@ module API
before do
require_packages_enabled!
not_found! unless ::Feature.enabled?(:debian_packages, user_group)
not_found! unless ::Feature.enabled?(:debian_group_packages, user_group)
authorize_read_package!(user_group)
end
......
# frozen_string_literal: true
module API
class GroupDebianDistributions < ::API::Base
params do
requires :id, type: String, desc: 'The ID of a group'
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
rescue_from ArgumentError do |e|
render_api_error!(e.message, 400)
end
rescue_from ActiveRecord::RecordInvalid do |e|
render_api_error!(e.message, 400)
end
after_validation do
require_packages_enabled!
not_found! unless ::Feature.enabled?(:debian_group_packages, user_group)
end
namespace ':id/-' do
helpers do
def project_or_group
user_group
end
end
include ::API::Concerns::Packages::DebianDistributionEndpoints
end
end
end
end
......@@ -19,8 +19,6 @@ module API
require_packages_enabled!
not_found! unless ::Feature.enabled?(:debian_packages, user_project)
authorize_read_package!
end
namespace ':id' do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe API::GroupDebianDistributions do
include HttpBasicAuthHelpers
include WorkhorseHelpers
include_context 'Debian repository shared context', :group, false do
describe 'POST groups/:id/-/debian_distributions' do
let(:method) { :post }
let(:url) { "/groups/#{container.id}/-/debian_distributions" }
let(:api_params) { { 'codename': 'my-codename' } }
it_behaves_like 'Debian repository write endpoint', 'POST distribution request', :created, /^{.*"codename":"my-codename",.*"components":\["main"\],.*"architectures":\["all","amd64"\]/, authenticate_non_public: false
end
describe 'GET groups/:id/-/debian_distributions' do
let(:url) { "/groups/#{container.id}/-/debian_distributions" }
it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^\[{.*"codename":"existing-codename",.*"components":\["existing-component"\],.*"architectures":\["all","existing-arch"\]/, authenticate_non_public: false
end
describe 'GET groups/:id/-/debian_distributions/:codename' do
let(:url) { "/groups/#{container.id}/-/debian_distributions/#{distribution.codename}" }
it_behaves_like 'Debian repository read endpoint', 'GET request', :success, /^{.*"codename":"existing-codename",.*"components":\["existing-component"\],.*"architectures":\["all","existing-arch"\]/, authenticate_non_public: false
end
describe 'PUT groups/:id/-/debian_distributions/:codename' do
let(:method) { :put }
let(:url) { "/groups/#{container.id}/-/debian_distributions/#{distribution.codename}" }
let(:api_params) { { suite: 'my-suite' } }
it_behaves_like 'Debian repository write endpoint', 'PUT distribution request', :success, /^{.*"codename":"existing-codename",.*"suite":"my-suite",/, authenticate_non_public: false
end
describe 'DELETE groups/:id/-/debian_distributions/:codename' do
let(:method) { :delete }
let(:url) { "/groups/#{container.id}/-/debian_distributions/#{distribution.codename}" }
it_behaves_like 'Debian repository maintainer write endpoint', 'DELETE distribution request', :success, /^{"message":"202 Accepted"}$/, authenticate_non_public: false
end
end
end
......@@ -38,12 +38,14 @@ RSpec.shared_context 'GroupPolicy context' do
delete_metrics_dashboard_annotation
update_metrics_dashboard_annotation
create_custom_emoji
create_package
create_package_settings
]
end
let(:maintainer_permissions) do
%i[
destroy_package
create_projects
read_cluster create_cluster update_cluster admin_cluster add_cluster
]
......
......@@ -4,7 +4,7 @@ RSpec.shared_context 'Debian repository shared context' do |container_type, can_
include_context 'workhorse headers'
before do
stub_feature_flags(debian_packages: true)
stub_feature_flags(debian_packages: true, debian_group_packages: true)
end
let_it_be(:private_container, freeze: can_freeze) { create(container_type, :private) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment