debian-mirror-gitlab/app/finders/packages/helm/package_files_finder.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
891 B
Ruby
Raw Normal View History

2021-09-04 01:27:46 +05:30
# frozen_string_literal: true
module Packages
module Helm
class PackageFilesFinder
2021-09-30 23:02:18 +05:30
DEFAULT_PACKAGE_FILES_COUNT = 20
MAX_PACKAGE_FILES_COUNT = 1000
2021-11-11 11:23:49 +05:30
delegate :most_recent!, to: :execute
2021-09-04 01:27:46 +05:30
def initialize(project, channel, params = {})
@project = project
@channel = channel
@params = params
end
def execute
2021-09-30 23:02:18 +05:30
package_files = Packages::PackageFile.for_helm_with_channel(@project, @channel)
.limit_recent(limit)
2021-09-04 01:27:46 +05:30
by_file_name(package_files)
end
private
2021-09-30 23:02:18 +05:30
def limit
limit_param = @params[:limit] || DEFAULT_PACKAGE_FILES_COUNT
[limit_param, MAX_PACKAGE_FILES_COUNT].min
end
2021-09-04 01:27:46 +05:30
def by_file_name(files)
return files unless @params[:file_name]
files.with_file_name(@params[:file_name])
end
end
end
end