Katello Repository STI refactoring

Hello all,

I wanted to share the plan for refactoring the Katello Repositories model
and get some feedback.

We have been wanting to break up repositories for some time. The
repositories table has a field "content_type", which is used to handle yum,
file, docker, ostree, and puppet repos. In addition to this, there is a
"Content View Puppet Environment" model, which inherits repository methods.
[1]

Some reasons to refactor repositories are:

  • The repository model is large and monolithic
  • Multiple exceptions have to be made for different content_types i.e [2]
  • Its easy to introduce bugs in this area
  • the complexity is blocking or making it harder to design new features
    around repositories
  • Its the first step to implementing content type plugins - original design
    here [3]

The plan is to use Single Table Inheritance on the repositories table, and
move the content_type column to the type column. Each content type will be
its own class and can have its own methods.

The API will likely stay the same or have minimal changes, The rabl files
would just need updating. Any additional API changes can happen after the
refactoring (with proper deprecation warnings)

This would be broken into small changes, which will look something like
this:

  • add STI to repositories model, but keep old logic
  • setup classes for each content type
  • remove content_type field and update logic that uses that field to know
    use type field
  • move content based on functionality (in individual commits)
  • remove content view puppet environment and use "puppet" type repository
    in its place

Let me know if you have any questions, looking forward to hearing
everyone's opinions.

[1]


[2]

[3] ContentPlugins - Katello - Foreman

Thanks,
John Mitsch
Red Hat Engineering
(860)-967-7285
irc: jomitsch