From 857b061d0edb6ead8f7453c06de0842f8bab72e2 Mon Sep 17 00:00:00 2001 From: Andrejs Date: Mon, 17 Mar 2025 07:25:14 +0000 Subject: [PATCH 1/3] Add additional options to registry repositories method --- lib/gitlab/client/container_registry.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/client/container_registry.rb b/lib/gitlab/client/container_registry.rb index dc9a5eaf6..e625d071f 100644 --- a/lib/gitlab/client/container_registry.rb +++ b/lib/gitlab/client/container_registry.rb @@ -10,9 +10,14 @@ module ContainerRegistry # Gitlab.registry_repositories(5) # # @param [Integer, String] project The ID or name of a project. + # @param [Hash] options A customizable set of options. + # @option options [Boolean] :tags Return tags array in the response. + # @option options [Boolean] :tags_count Return tags count in the response. + # @option options [Integer] :page The page number. + # @option options [Integer] :per_page The number of results per page. # @return [Array] Returns list of registry repositories in a project. - def registry_repositories(project) - get("/projects/#{url_encode project}/registry/repositories") + def registry_repositories(project, options = {}) + get("/projects/#{url_encode project}/registry/repositories", query: options) end # Delete a repository in registry. From f91738ce867357868ade8e7d610a13ff66eda6d7 Mon Sep 17 00:00:00 2001 From: Andrejs Date: Mon, 17 Mar 2025 07:37:19 +0000 Subject: [PATCH 2/3] Add tests for request with options --- spec/gitlab/client/container_registry_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/gitlab/client/container_registry_spec.rb b/spec/gitlab/client/container_registry_spec.rb index a87abaae8..626e6384c 100644 --- a/spec/gitlab/client/container_registry_spec.rb +++ b/spec/gitlab/client/container_registry_spec.rb @@ -16,6 +16,17 @@ it "returns a paginated response of project's registry repositories" do expect(@registry_repositories).to be_a Gitlab::PaginatedResponse end + + context 'with options' do + before do + stub_get('/projects/3/registry/repositories?tags=true&tags_count=true&per_page=100', 'registry_repositories') + @registry_repositories = Gitlab.registry_repositories(3, { tags: true, tags_count: true, per_page: 100 }) + end + + it "passes query options" do + expect(a_get('/projects/3/registry/repositories?tags=true&tags_count=true&per_page=100')).to have_been_made + end + end end describe '.delete_registry_repository' do From f7c13f689d893b1a273dab76a66425ed3958e5bc Mon Sep 17 00:00:00 2001 From: Andrejs Date: Mon, 17 Mar 2025 07:41:30 +0000 Subject: [PATCH 3/3] Fix rubocop error --- spec/gitlab/client/container_registry_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/gitlab/client/container_registry_spec.rb b/spec/gitlab/client/container_registry_spec.rb index 626e6384c..9ef01d0d0 100644 --- a/spec/gitlab/client/container_registry_spec.rb +++ b/spec/gitlab/client/container_registry_spec.rb @@ -23,7 +23,7 @@ @registry_repositories = Gitlab.registry_repositories(3, { tags: true, tags_count: true, per_page: 100 }) end - it "passes query options" do + it 'passes query options' do expect(a_get('/projects/3/registry/repositories?tags=true&tags_count=true&per_page=100')).to have_been_made end end