Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #330
This is a larger refactoring of the inner workings of hdm to introduce the concept of different "layers" of hiera configuration. As a first step, it allows to show the "global layer" as well as the environment layer that we always supported.
This also paves the way for #331, as recognizing that there is more than one layer is a prerequisite for that.
Having had to move around and change lots of stuff, I decided to change the architecture a little bit. Until now, the models in
app/models
were strictly divided: Top level classes were mostly "high-level" classes that mimicked rails' ActiveRecord-API where possible. The classes inapp/models/hiera_data
represented "low-level" objects that dealt directly with hiera data, files etc.The class
HieraData
inapp/models/hiera_data.rb
was used as the central interface between "high-" and "low-level" classes. It was a nice separation in the sense that the high level classes did not have to know anything about hiera internals. And it has served us well for quite some time. But this also meant thatHieraData
was already a very big and complex class. With the addition of layers this was prone to grow out of hand.Once I decided to break up this structure, it turned out there was a lot of redundant and even some unused code, so I could actually delete a lot of code (always a good thing 🙂). I am really happy with how everything in the "low-level" classes turned out. The change comes with some additional upsides:
HieraData
are being createdBut as always there are downsides as well. The high-level model classes have become more complex as they need to know more about the hiera internals. They also have more dependencies, because more references to low-level classes need to be passed around. I am not 100% happy with the current state here, as it feels more "bolted on" than actually designed. But I think that #331 and/or #84 may bring more clarity here.
There is also a small detail that changed because of these refactorings and that is not trivial to change back: When doing a key search, hdm now displays the full path to the files instead of a shorter path relative to the
datadir
:I hope that is OK. If not, I think I can find a way to restore the old behavior. It just will not be pretty 😬
Please note that given how big a change this is, this might introduce some instability. Things that used to work might be broken so give this a good test-drive if possible.
One thing I left out intentionally is the API / integration with foreman. I made sure the behavior of the API did not change, but did nothing more. If we want the global layer in foreman as well, we should create a new issue for that (and decide if that warrants and API v2). But this should probably wait until after #331.