[katello-devel] some thoughts on foreman-architectures branch
Dmitri Dolguikh
dmitri at redhat.com
Wed Sep 5 15:30:59 UTC 2012
The logic used to access Foreman server is spread over several classes:
a bunch of automatically-generated proxy-type classes that reside in
foreman_api gem, ForemanModel (resides in
lib/resources/foreman_model.rb), that is a base-class for Foreman
resource classes that reside in app/models/foreman.
Good things first:
- app/models/foreman classes are minimal, and clearly show what
attributes are being used.
- app/models/foreman classes allow for local validation via standard
ActiveModel validators.
- app/models/foreman classes allow for easy customization of json
generation.
Things I don't like:
- I can't shake the feeling that the approach represented in the
branch is a huge duplication of effort. We are replicating
ActiveResource on every step of the way, and:
- ActiveResource's error handling is better/consistent (ours is
minimal and current approach would require us to recreate all of
RestClient's exceptions)
- ActiveResource's error parsing is much better (we'll have to
duplicate AR's code to be able to parse remote errors).
- Pretty much all of ForemanModel is what we'd get with
ActiveResource for free. Keep in mind that custom methods are simple
with ActiveResource.
- Foreman uses rabl [1] for json-generation, we implemented a custom
approach. I think rabl is at least worth a look.
- Apipie in it's current shape promotes code duplication. See
foreman_api classes, domain- and architectures-controllers in katello.
I propose:
- It's been close to a couple of years since we looked at
ActiveResource last. I'd like to see where it is now, how hard it is to
use with oauth and non-rails types of resource urls these days.
- I'd like to evaluate rabl for use in Katello
- I'd like to fix code duplication issues in Apipie, possibly switch
it to use ActiveResource instead of RestClient
-d
[1] https://github.com/nesquena/rabl <https://github.com/nesquena/rabl>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/katello-devel/attachments/20120905/9bab0d9c/attachment.htm>
More information about the katello-devel
mailing list