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

Array to String formatter adds a trailing space to a separator

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 5.2.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Epic Link:
    • Sub-team:
    • Team:
      Platform Core
    • Story Points:
      1
    • Sprint:
      Agent 2017-07-12, Platform Core 2017-08-22
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      The String.new separator logic for collections always included a space even if the separator was an empty string.
    • QA Risk Assessment:
      No Action
    • QA Risk Assessment Reason:
      Covered by spec tests

      Description

      In Puppet 5.0.0 when converting an Array of strings to a comma separated String I use the following format specification to convert and Array of path strings to a path String:

      $path_string_format = {
          Array => {
            format         => '% a',
            separator      => ':',
            string_formats => {
              String => '%s'
            }
          }
        }
      

      Given an array of paths:

      $paths=['/path/to/dir','/another/path/to/dir']
      $path_string=String($paths,$path_string_format)
      

      The expected output is '/path/to/dir:/another/path/to/dir'

      However the output is '/path/to/dir: /another/path/to/dir'

      The String formatting has appended a trailing space to the separator.

      A workaround exists if the string is used in an .erb template by expressing the string like this:

      <%= @path_string.gsub(/\s+/, "") %>
      

      Reading the documentation there does not seem to be a flag or format option to remove this automatic addition of a space.

      Being able to eliminate this space would completely remove the need for the join function from puppetlabs/stdlib

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                Aethylred Aaron Hicks
              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: