Unify Identifier tools for Work Item entities

Description

Epics, Issues and Merge Requests are supposed to be migrated to Work Items. That means that correspondent Duo Chat tools that used to identify those entities should support work item links. That's an opportunity to unify the extract_resource methods of Reader tool executors:

Implementation plan

Change the extract_resource method in the Tools class to implement all the repeated logic

For instance, you might do something like this

  def extract(text)
    return unless @project

    extractor = Gitlab::ReferenceExtractor.new(@project, @current_user)
    extractor.analyze(text, {})
    resources = get_resources(extractor)

    resources.first if resources.one?
  end

And then implement get_resources in each child class

  def get_resources(extractor)
    extractor.issues
  end

You might want to add something like this to be safe

 def get_resources(extractor)
    raise NotImplementedError, "Subclasses must implement get_resources"
  end

That is just one example of how it might be done though. Please let @lesley-r know if you have identified any flaws in this plan so she can learn :)

Acceptance criteria

  • The extract_resource method from issues, epics, and MRs are combined into one method
  • All dead code is removed
Edited by Lesley Razzaghian