Skip to content

Conversation

apenney
Copy link
Contributor

@apenney apenney commented Nov 18, 2013

[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.

@puppetcla
Copy link

CLA signed by all contributors.

@Sharpie
Copy link
Member

Sharpie commented Nov 27, 2013

Related tickets:

Redmine 8758
Redmine 9293

@Sharpie
Copy link
Member

Sharpie commented Nov 27, 2013

Also incorporates Redmine 22304

Copy link
Contributor Author

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.

@unux
Copy link

unux commented Jan 22, 2014

@apenney from the yum config parser: http://yum.baseurl.org/gitweb?p=yum.git;a=blob;f=yum/config.py#l387

class BoolOption(Option):
    """An option representing a boolean value.  The value can be one
        of 0, 1, yes, no, true, or false.
        """

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.

@apenney
Copy link
Contributor Author

apenney commented Jan 22, 2014

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@apenney
Copy link
Contributor Author

apenney commented Jan 28, 2014

I'll keep working on this. I'll make sure self.reposdir is covered as well.

@riton
Copy link
Contributor

riton commented Jan 28, 2014

Hey, for #2268, you can now pull from 4599332 il you're okay with this.

Cheers

Copy link
Contributor Author

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 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, looks good

@joshcooper
Copy link
Contributor

@apenney I noticed that travis failed on commits 866f5c5 and 537b6f4. Could you fix those up? That way it's easier to bisect in the future.

Copy link
Contributor

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Ashley Penney added 2 commits February 7, 2014 19:08
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To copy our conversation here, #section may return nil here and if we stub :[]= then incredibly horrible things happen.

orly

adrienthebo added a commit that referenced this pull request Feb 14, 2014
(PUP-789) refactor yumrepo into type and provider
@adrienthebo adrienthebo merged commit e638972 into puppetlabs:master Feb 14, 2014
@adrienthebo
Copy link
Contributor

Merged into master in e638972; this should be released in 3.5.0. Thanks for all your hard work!

Copy link

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?

@adrienthebo
Copy link
Contributor

I agree, I'll go though and do the needful shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants