-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Initial refactoring of yumrepo. #2086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CLA signed by all contributors. |
Related tickets: |
Also incorporates Redmine 22304 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the stripping here to handle 'enabled = 1' cases.
@apenney from the yum config parser: http://yum.baseurl.org/gitweb?p=yum.git;a=blob;f=yum/config.py#l387
Seems like yum's boolean options also take yes and no in addition to (0|1|false|true). This might be worth expanding into the rest of yumrepos options. |
Ahhhh, nice, I didn't look in config.py, I had only got as far as repo.py. That'll teach me. I'll fix this globally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#instance_variable_get
is generally evil, if this needs to be used by outside classes then can we make an attr_reader for entries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can take a look at this, I definitely don't like grubbing in inifile in this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be rewritten as section(@resource[:name])[property.to_s] = value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had troubles with this, and ended up using []= (which is actually defined in inifile special, just in case you thought I was relying on some standard ruby here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a bit more information to this? If this is actually necessary then it may indicate that something else is going on, and if it's not necessary then I would prefer the more common syntax.
I'll keep working on this. I'll make sure self.reposdir is covered as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote reposdir and added find_conf_value for now to make this a little cleaner. Are you ok with this @adrienthebo ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment confuses me, because this method will be invoked after every resource has been evaluated, so we'll be calling self.class.store
every time.
Add a .destory and .destroy? in order to flag files for deletion. We also sneak in a .entries reader in order to let us read the entries directly. This should fix PUP-1066 and #12687.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This scares the bejezus out of me, providers should never have to look at Puppet[:noop]
because destructive methods should never be called if Puppet is in noop mode. Why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My honest answer is "I don't know, it was in the original type". I suspect it predates whatever safety work is done in noop runs and can be removed. I'll do some experimentations with removing it and noop.
This work strips out all of the provider code from the type, and creates a new ruby provider for yumrepo. While this code still uses inifile it's been rewritten to take advantage of the modernization of Puppet. It's now a little easier to understand and test. This covers: #8758, #9293, #22304 (projects.puppetlabs.com)
… when noop is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(PUP-789) refactor yumrepo into type and provider
Merged into master in e638972; this should be released in 3.5.0. Thanks for all your hard work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After seeing @peterhuene's fix up yesterday at a76d681, I took a look at this pull. There are some file api accesses via the native ruby api (e.g. here) and some via the Puppet::FileSystem
abstraction (e.g. line 50). For consistency's sake, we should probably scrub this pull to use that abstraction consistently. @apenney @adrienthebo thoughts?
I agree, I'll go though and do the needful shortly. |
[I've made this PR early, as I'd like feedback on the direction of the provider/type, and the tests. It seems to work for me, which is about as strongly tested as it is right now.]
This work strips out all of the provider code from the type, and
creates a new ruby provider for yumrepo.
While this code still uses inifile it's been rewritten to take advantage
of the modernization of Puppet. It's now a little easier to understand
and test.