Sha256: 43b8593e5fcbdb724e90c33f83c66d09462245ef7abf6e9acdf676a232486ff8
Contents?: true
Size: 1.99 KB
Versions: 4
Compression:
Stored size: 1.99 KB
Contents
# frozen_string_literal: true require_relative '../command_builders/text_content_builder' module Gitlab module Triage module EntityBuilders class IssueBuilder def initialize( type:, action:, resources:, network:, policy_spec: {}, separator: "\n") @type = type @policy_spec = policy_spec @item_template = action[:item] @title_template = action[:title] @summary_template = action[:summary] @summary_destination = action[:destination] @redact_confidentials = action[:redact_confidential_resources] != false @resources = resources @network = network @separator = separator end def title @title ||= build_text(title_resource, @title_template) end def description @description ||= build_text(description_resource, @summary_template) end def destination @summary_destination end def valid? title =~ /\S+/ && any_resources? end def any_resources? @resources.any? end private def title_resource { type: @type } end def description_resource title_resource.merge( title: title, items: items, resources: @resources) end def items @items ||= @resources.map(&method(:build_item)).join(@separator) end def build_item(resource) case resource when IssueBuilder resource.description else build_text(resource, @item_template) end end def build_text(resource, template) return '' unless template CommandBuilders::TextContentBuilder.new( template, resource: resource, network: @network, redact_confidentials: @redact_confidentials) .build_command.chomp end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems