2021-06-08 01:23:25 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Packages
|
|
|
|
module Helm
|
|
|
|
class FileMetadatum < ApplicationRecord
|
|
|
|
self.primary_key = :package_file_id
|
|
|
|
|
|
|
|
belongs_to :package_file, inverse_of: :helm_file_metadatum
|
|
|
|
|
|
|
|
validates :package_file, presence: true
|
|
|
|
validate :valid_helm_package_type
|
|
|
|
|
|
|
|
validates :channel,
|
|
|
|
presence: true,
|
2021-11-18 22:05:49 +05:30
|
|
|
length: { maximum: 255 },
|
2021-06-08 01:23:25 +05:30
|
|
|
format: { with: Gitlab::Regex.helm_channel_regex }
|
|
|
|
|
|
|
|
validates :metadata,
|
|
|
|
json_schema: { filename: "helm_metadata" }
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def valid_helm_package_type
|
|
|
|
return if package_file&.package&.helm?
|
|
|
|
|
|
|
|
errors.add(:package_file, _('Package type must be Helm'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|