Skip to content
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

(PUP-1526) Add environment settings for package type #4928

Closed
wants to merge 1 commit into from
Closed

(PUP-1526) Add environment settings for package type #4928

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 30, 2016

This patch adds to the package type the :settable_environment feature
and the :environment parameter used by that feature. :environment
is either a string of the form "NAME=VALUE" or an array of such strings.

The Puppet::Provider::Package is modified to include wrapped versions
of the execute, execpipe, and has_command methods which include
the custom environment if the calling resource defines it. This
includes a required modification to the CommandDefiner class in
Puppet::Provider to allow the executor and resolver to be overridden.

All package providers are modified to use the Puppet::Provider::Package
versions of execute, execpipe, and has_command.

The yum package provider is updated to actually support the
environment parameter and :settable_environment feature.

Finally, the spec tests for the package type and yum provider
are updated to test for the :settable_environment feature and the
environment parameter.

@ghost
Copy link
Author

ghost commented Apr 30, 2016

Note - this PR still only provides the :settable_environment feature on the yum provider, because I don't have the facilities or knowledge to properly test this out with the other package providers. But theoretically all that should be required is to include the :settable_environment feature in a provider, and ensure it doesn't make any direct calls to Puppet::Util::Execution .

@puppetcla
Copy link

CLA signed by all contributors.

@ghost
Copy link
Author

ghost commented Apr 30, 2016

this replaces pr #4862

@HAIL9000
Copy link
Contributor

HAIL9000 commented May 3, 2016

Hey @jearls, thank you for the contribution! We're going to try and pull this into our next sprint so we can get some eyes on it and hopefully get it merged.

@whopper whopper added the blocked PRs blocked on work external to the PR itself label Jun 14, 2016
newparam(:environment) do
desc "Any additional environment variables you want to set for operations
against this package. The value should be a single string of the form
`NAME=value` or an array of such strings.
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes me sad, but I agree that consistency with exec is good here :(

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I had originally made this accept a hash. I guess I could try to let it accept either, but I thought that would be more confusing than just keeping it consistent.

@branan
Copy link
Contributor

branan commented Jun 28, 2016

I don't really like moving all the providers to use a common helper if you're not going to enable the :settable_environment feature on them - it seems like it's just complexity and code churn without much gain in those cases

@branan branan added Waiting on Contributor and removed blocked PRs blocked on work external to the PR itself Pending Triage labels Jun 28, 2016
@ghost
Copy link
Author

ghost commented Jul 19, 2016

The reason I didn't add the custom environment to any other provider is because I have no expertise in any other packaging system and no experience with non-RedHat Linux OSes. I originally had just added this to only to the yum package type, and was requested to make it more generally available since the original request was for a different packaging system. However, because I don't know how those other packaging systems work and have no real way to test them, I chose to create the framework and allow someone who knows what they're doing to implement the feature in the other packaging systems.

@branan
Copy link
Contributor

branan commented Jul 26, 2016

@jearls That makes sense. This is a useful feature for us to get in, and the work you've done building a framework for the other providers looks like it's in the right direction to me, so I'm not going to push for its removal.

It looks like this has picked up some conflicts with the base branch in the interim. If you could get it rebased that'd be awesome. You'll also probably have to squash your second commit in to your first, or at the very least add the ticket number to it, in order to make our commit message checker happy.

@darkfoxprime
Copy link

Sorry it's taken so long. I completely missed the update from July. I just rebased and force-pushed, but I don't know if I've got the spec file correct, since I haven't seen/used the "shared examples" thing before.

This patch adds to the package type the `:settable_environment` feature
and the `:environment` parameter used by that feature.  `:environment`
is either a string of the form "NAME=VALUE" or an array of such strings.

The Puppet::Provider::Package is modified to include wrapped versions
of the `execute`, `execpipe`, and `has_command` methods which include
the custom environment if the calling resource defines it.  This
includes a required modification to the `CommandDefiner` class in
Puppet::Provider to allow the executor and resolver to be overridden.

All package providers are modified to use the Puppet::Provider::Package
versions of `execute`, `execpipe`, and `has_command`.

The `yum` package provider is updated to actually support the
`environment` parameter and `:settable_environment` feature.

Finally, the `spec` tests for the `package` type and `yum` provider
are updated to test for the `:settable_environment` feature and the
`environment` parameter.
@prometheanfire
Copy link
Contributor

once this merges I'll update the portage package provider, this is useful for overriding FEATURES and the like if needed.

@@ -239,6 +239,8 @@ def initialize(name, path, confiner)
@optional = false
@confiner = confiner
@custom_environment = {}
@command_resolver = Puppet::Util
Copy link
Contributor

Choose a reason for hiding this comment

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

The Puppet::Util module is mixed into the provider, so I don't think this is necessary.

def command
if not @optional
@confiner.confine :exists => @path, :for_binary => true
end

Puppet::Provider::Command.new(@name, @path, Puppet::Util, Puppet::Util::Execution, { :failonfail => true, :combine => true, :custom_environment => @custom_environment })
Puppet::Provider::Command.new(@name, @path, @command_resolver, @command_executor, { :failonfail => true, :combine => true, :custom_environment => @custom_environment })
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly, I think you can just pass self here, e.g. Command.new(@name, @path, self, ...)

@MosesMendoza
Copy link
Contributor

This PR hasn't been updated in some time, and I'm afraid the team won't have time to review it in the near future. Let's track future conversation in the ticket, PUP-1526, and we can re-open this PR if/when there's bandwidth to support it. Closing for now.

@rledousa
Copy link

I commented into PUP-1526. We can definitely use this feature to work around a bug in pip3.6

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.

None yet

9 participants