Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-7640

Property::List is inconsistent with respect to #is_to_s and #should_to_s



    • Type: Bug
    • Status: Accepted
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Template:
    • Team:
    • Method Found:
      Needs Assessment
    • QA Risk Assessment:
      Needs Assessment


      Problem 1.
      The Puppet::Property::List class, super class of Puppet::Property::OrderedList implements the method #is_to_s but does not implement #should_to_s. This leads to inconsistent representation of the current and to values when change events are reported.

      The groups property of a User type can for instance present changes like:

      Notice: /Stage[main]/Main/User[foobar]/groups: groups changed wheel,sshd to ['mail', 'sshd', 'wheel']

      Problem 2.
      Since the delimiter separated list is no longer quoted by default due to the changes in PUP-7616, consequently, a list with no entries is represented as an empty string. Adding the first group to a user looks like this:

      Notice: /Stage[main]/Main/User[foobar]/groups: groups changed  to ['wheel']

      The methods #is_to_s and #should_to_s should be implemented the same way and we need to make a decision on the representation.

      Alternative 1.
      The property is changed to rely on default behavior (i.e. the special #is_to_s is simply removed. The result will then be that both values are represented as bracketed arrays and that the current delimiter property is rendered useless. The above changes would then instead look like:

      groups changed ['sshd', 'wheel'] to ['mail', 'sshd', 'wheel']
      groups changed [] to ['wheel']

      Alternative 2.
      A #should_to_s is added that is equal to #is_to_s. Both methods present a list of entries joined by the given delimiter. This list must then be quoted to avoid problem #2. The changes would then be presented as:

      groups changed 'sshd,wheel' to 'mail,sshd,wheel'
      groups changed '' to 'wheel'

      While this alternative vouches for a more compact presentation, it is also problematic. List is abstract and used as the parent of by many properties. The presentation will look strange if one or several entries contain:

      1. the delimiter
      2. a single quote
      3. a complex object

      The presentation is also different from how the property is presented by commands like puppet resource, which always uses the bracketed array.




            thomas.hallgren Thomas Hallgren
            0 Vote for this issue
            2 Start watching this issue



                Zendesk Support