2020-06-02 14:08:32 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Releases
|
|
|
|
class CreateEvidenceService
|
2020-06-16 11:08:32 -04:00
|
|
|
def initialize(release, pipeline: nil)
|
2020-06-02 14:08:32 -04:00
|
|
|
@release = release
|
2020-06-16 11:08:32 -04:00
|
|
|
@pipeline = pipeline
|
2020-06-02 14:08:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
evidence = release.evidences.build
|
|
|
|
|
2020-06-17 20:08:35 -04:00
|
|
|
summary = ::Evidences::EvidenceSerializer.new.represent(evidence, evidence_options) # rubocop: disable CodeReuse/Serializer
|
2020-06-02 14:08:32 -04:00
|
|
|
evidence.summary = summary
|
2020-10-18 20:08:50 -04:00
|
|
|
# TODO: fix the sha generation https://gitlab.com/groups/gitlab-org/-/epics/3683
|
2020-06-02 14:08:32 -04:00
|
|
|
evidence.summary_sha = Gitlab::CryptoHelper.sha256(summary)
|
|
|
|
|
|
|
|
evidence.save!
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-06-17 20:08:35 -04:00
|
|
|
attr_reader :release, :pipeline
|
|
|
|
|
|
|
|
def evidence_options
|
|
|
|
{}
|
|
|
|
end
|
2020-06-02 14:08:32 -04:00
|
|
|
end
|
|
|
|
end
|
2020-06-17 20:08:35 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Releases::CreateEvidenceService.prepend_mod_with('Releases::CreateEvidenceService')
|