Welcome to mirror list, hosted at ThFree Co, Russian Federation.

repository.rb « harbor « concerns « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0e541e2172e5a0a5499380a987a6dcd0eceebe59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true

module Harbor
  module Repository
    def index
      respond_to do |format|
        format.html
        format.json do
          repositories
        end
      end
    end

    # The show action renders index to allow frontend routing to work on page refresh
    def show
      render :index
    end

    private

    def query_params
      params.permit(:search, :sort, :page, :limit)
    end

    def query
      Gitlab::Harbor::Query.new(container.harbor_integration, query_params)
    end

    def repositories
      unless query.valid?
        return render(
          json: { message: 'Invalid parameters', errors: query.errors },
          status: :unprocessable_entity
        )
      end

      repositories_json = ::Integrations::HarborSerializers::RepositorySerializer.new
                                        .with_pagination(request, response)
                                        .represent(
                                          query.repositories,
                                          url: container.harbor_integration.url,
                                          project_name: container.harbor_integration.project_name
                                        )
      render json: repositories_json
    end

    def container
      raise NotImplementedError
    end
  end
end