Skip to content

(#22557) Raise an error providing a package resource with multiple names#1950

Closed
jpartlow wants to merge 1 commit intopuppetlabs:masterfrom
jpartlow:issue/master/22557-array-of-package-names-not-allowed
Closed

(#22557) Raise an error providing a package resource with multiple names#1950
jpartlow wants to merge 1 commit intopuppetlabs:masterfrom
jpartlow:issue/master/22557-array-of-package-names-not-allowed

Conversation

@jpartlow
Copy link
Contributor

Redmine #22557 brought up a regression in package provider behavior
(specifically dpkg). Previously it was possible, under some
circumstances to supply a package resource with an array for the name
attribute, and have puppet manage the set of packages. However, this
was an accidental feature which could fail if some packages were in
different states because the providers' query methods ultimately operate
on the package property hash info of just one of the packages.

This commit makes explicit that a package resource should not have its
name attribute set to an array of more than one value, and will raise a
ResourceError if this is attempted.

@puppetcla
Copy link

CLA signed by all contributors.

Redmine #22557 brought up a regression in package provider behavior
(specifically dpkg).  Previously it was possible, under some
circumstances to supply a package resource with an array for the name
attribute, and have puppet manage the set of packages.  However, this
was an accidental feature which could fail if some packages were in
different states because the providers' query methods ultimately operate
on the package property hash info of just one of the packages.

This commit makes explicit that a package resource should not have its
name attribute set to an array of more than one value, and will raise a
ResourceError if this is attempted.
Copy link
Contributor

Choose a reason for hiding this comment

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

@jpartlow this change will work for package providers in core, but not modules, e.g. https://github.com/bjoernalbers/puppet-homebrew/blob/master/lib/puppet/provider/package/homebrew.rb#L47-L49. I'm not sure if we care?

From what I can tell the Puppet::Provider::Package#query method is only called by the #properties method in the same class. We could create a new query method that does the validate check:

def query_wrapper
  validate_resource
  query
end

def properties
  if @property_hash.empty?
    @property_hash = query_wrapper || {:ensure => :absent}

and then leave the core & custom package providers as they were?

@zaphod42
Copy link
Contributor

zaphod42 commented Oct 8, 2013

Superseded by GH-1980

@zaphod42 zaphod42 closed this Oct 8, 2013
@jpartlow jpartlow deleted the issue/master/22557-array-of-package-names-not-allowed branch November 21, 2013 20:11
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.

4 participants