Sha256: ec0060e365acac3b69f81a579d504c862399df028464f0639a4f604413044412

Contents?: true

Size: 1.32 KB

Versions: 20

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require_relative '../command_builders/text_content_builder'

module Gitlab
  module Triage
    module EntityBuilders
      class IssueBuilder
        attr_reader :destination

        def initialize(
          type:, action:, resource:, network:,
          policy_spec: {}, separator: "\n")
          @type = type
          @policy_spec = policy_spec
          @item_template = action[:item]
          @title_template = action[:title]
          @description_template = action[:description]
          @destination = action[:destination]
          @redact_confidentials =
            action[:redact_confidential_resources] != false
          @resource = resource
          @network = network
          @separator = separator
        end

        def title
          @title ||= build_text(@title_template)
        end

        def description
          @description ||= build_text(@description_template)
        end

        def valid?
          title =~ /\S+/
        end

        private

        def build_text(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

20 entries across 20 versions & 2 rubygems

Version Path
gitlab-triage-1.44.1 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.44.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.43.2 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.43.1 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.43.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.42.2 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.42.1 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.42.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.41.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.40.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.30.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.29.0 lib/gitlab/triage/entity_builders/issue_builder.rb
payping-gitlab-triage-0.1.3 lib/gitlab/triage/entity_builders/issue_builder.rb
payping-gitlab-triage-0.1.2 lib/gitlab/triage/entity_builders/issue_builder.rb
payping-gitlab-triage-0.1.1 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.28.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.27.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.26.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.25.0 lib/gitlab/triage/entity_builders/issue_builder.rb
gitlab-triage-1.24.0 lib/gitlab/triage/entity_builders/issue_builder.rb