[PDK-547] Files generated from PDK new module on Windows create with CRLF line endings Created: 2017/09/27  Updated: 2018/11/29  Resolved: 2018/11/13

Status: Closed
Project: Puppet Development Kit
Component/s: None
Affects Version/s: None
Fix Version/s: PDK 1.8.0

Type: Bug Priority: Normal
Reporter: Glenn Sarti Assignee: Tim Sharpe
Resolution: Fixed Votes: 0
Labels: resolved-issue-added
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

PDK 1.1.10
Windows 10


Issue Links:
Relates
relates to PDK-443 EOL config in generated .gitattribute... Closed
Template:
Acceptance Criteria:
  • Files which are expected to be LF in .gitattributes should have LF line endings on any OS
Method Found: Customer Feedback
Release Notes: Bug Fix
Release Notes Summary: Files generated by PDK will no longer have CRLF line endings. They should all have LF line endings now.
QA Risk Assessment: Needs Assessment

 Description   

I created a new module using pdk new module ...

and it generated all of the files using CRLF line endings. This caused git to complain because .rb files should be LF

}
----------------------------------------
About to generate this module; continue? Yes
pdk (INFO): Module 'windows_bitlocker' generated at path 'C:/Source/puppetlabs-windows_bitlocker/windows_bitlocker/windows_bitlocker'.
pdk (INFO): In your module directory, add classes with the 'pdk new class' command.
 
C:\Source\puppetlabs-windows_bitlocker\windows_bitlocker [master +15 ~0 -0 !]> git add --a
warning: CRLF will be replaced by LF in spec/spec_helper.rb.
The file will have its original line endings in your working directory.
C:\Source\puppetlabs-windows_bitlocker\windows_bitlocker [master +16 ~0 -0 ~]>



 Comments   
Comment by Glenn Sarti [ 2017/09/27 ]

spec_helper.rb hexdump

  Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 	
00000000: 72 65 71 75 69 72 65 20 27 70 75 70 70 65 74 6C    require.'puppetl
00000010: 61 62 73 5F 73 70 65 63 5F 68 65 6C 70 65 72 2F    abs_spec_helper/
00000020: 6D 6F 64 75 6C 65 5F 73 70 65 63 5F 68 65 6C 70    module_spec_help
00000030: 65 72 27 0D 0A 72 65 71 75 69 72 65 20 27 72 73    er'..require.'rs
00000040: 70 65 63 2D 70 75 70 70 65 74 2D 66 61 63 74 73    pec-puppet-facts
00000050: 27 0D 0A 69 6E 63 6C 75 64 65 20 52 73 70 65 63    '..include.Rspec
00000060: 50 75 70 70 65 74 46 61 63 74 73 0D 0A 0D 0A 64    PuppetFacts....d
00000070: 65 66 61 75 6C 74 5F 66 61 63 74 73 20 3D 20 7B    efault_facts.=.{
00000080: 0D 0A 20 20 70 75 70 70 65 74 76 65 72 73 69 6F    ....puppetversio
00000090: 6E 3A 20 50 75 70 70 65 74 2E 76 65 72 73 69 6F    n:.Puppet.versio
000000a0: 6E 2C 0D 0A 20 20 66 61 63 74 65 72 76 65 72 73    n,....factervers
000000b0: 69 6F 6E 3A 20 46 61 63 74 65 72 2E 76 65 72 73    ion:.Facter.vers
000000c0: 69 6F 6E 2C 0D 0A 7D 0D 0A 0D 0A 64 65 66 61 75    ion,..}....defau
000000d0: 6C 74 5F 66 61 63 74 73 5F 70 61 74 68 20 3D 20    lt_facts_path.=.
000000e0: 46 69 6C 65 2E 65 78 70 61 6E 64 5F 70 61 74 68    File.expand_path
000000f0: 28 46 69 6C 65 2E 6A 6F 69 6E 28 46 69 6C 65 2E    (File.join(File.
00000100: 64 69 72 6E 61 6D 65 28 5F 5F 46 49 4C 45 5F 5F    dirname(__FILE__
00000110: 29 2C 20 27 64 65 66 61 75 6C 74 5F 66 61 63 74    ),.'default_fact
00000120: 73 2E 79 6D 6C 27 29 29 0D 0A 64 65 66 61 75 6C    s.yml'))..defaul
00000130: 74 5F 6D 6F 64 75 6C 65 5F 66 61 63 74 73 5F 70    t_module_facts_p
00000140: 61 74 68 20 3D 20 46 69 6C 65 2E 65 78 70 61 6E    ath.=.File.expan
00000150: 64 5F 70 61 74 68 28 46 69 6C 65 2E 6A 6F 69 6E    d_path(File.join
00000160: 28 46 69 6C 65 2E 64 69 72 6E 61 6D 65 28 5F 5F    (File.dirname(__
00000170: 46 49 4C 45 5F 5F 29 2C 20 27 64 65 66 61 75 6C    FILE__),.'defaul
00000180: 74 5F 6D 6F 64 75 6C 65 5F 66 61 63 74 73 2E 79    t_module_facts.y
00000190: 6D 6C 27 29 29 0D 0A 0D 0A 69 66 20 46 69 6C 65    ml'))....if.File
000001a0: 2E 65 78 69 73 74 3F 28 64 65 66 61 75 6C 74 5F    .exist?(default_
000001b0: 66 61 63 74 73 5F 70 61 74 68 29 20 26 26 20 46    facts_path).&&.F
000001c0: 69 6C 65 2E 72 65 61 64 61 62 6C 65 3F 28 64 65    ile.readable?(de
000001d0: 66 61 75 6C 74 5F 66 61 63 74 73 5F 70 61 74 68    fault_facts_path
000001e0: 29 0D 0A 20 20 64 65 66 61 75 6C 74 5F 66 61 63    )....default_fac
000001f0: 74 73 2E 6D 65 72 67 65 21 28 59 41 4D 4C 2E 73    ts.merge!(YAML.s
00000200: 61 66 65 5F 6C 6F 61 64 28 46 69 6C 65 2E 72 65    afe_load(File.re
00000210: 61 64 28 64 65 66 61 75 6C 74 5F 66 61 63 74 73    ad(default_facts
00000220: 5F 70 61 74 68 29 29 29 0D 0A 65 6E 64 0D 0A 0D    _path)))..end...
00000230: 0A 69 66 20 46 69 6C 65 2E 65 78 69 73 74 3F 28    .if.File.exist?(
00000240: 64 65 66 61 75 6C 74 5F 6D 6F 64 75 6C 65 5F 66    default_module_f
00000250: 61 63 74 73 5F 70 61 74 68 29 20 26 26 20 46 69    acts_path).&&.Fi
00000260: 6C 65 2E 72 65 61 64 61 62 6C 65 3F 28 64 65 66    le.readable?(def
00000270: 61 75 6C 74 5F 6D 6F 64 75 6C 65 5F 66 61 63 74    ault_module_fact
00000280: 73 5F 70 61 74 68 29 0D 0A 20 20 64 65 66 61 75    s_path)....defau
00000290: 6C 74 5F 66 61 63 74 73 2E 6D 65 72 67 65 21 28    lt_facts.merge!(
000002a0: 59 41 4D 4C 2E 73 61 66 65 5F 6C 6F 61 64 28 46    YAML.safe_load(F
000002b0: 69 6C 65 2E 72 65 61 64 28 64 65 66 61 75 6C 74    ile.read(default
000002c0: 5F 6D 6F 64 75 6C 65 5F 66 61 63 74 73 5F 70 61    _module_facts_pa
000002d0: 74 68 29 29 29 0D 0A 65 6E 64 0D 0A 0D 0A 52 53    th)))..end....RS
000002e0: 70 65 63 2E 63 6F 6E 66 69 67 75 72 65 20 64 6F    pec.configure.do
000002f0: 20 7C 63 7C 0D 0A 20 20 63 2E 64 65 66 61 75 6C    .|c|....c.defaul
00000300: 74 5F 66 61 63 74 73 20 3D 20 64 65 66 61 75 6C    t_facts.=.defaul
00000310: 74 5F 66 61 63 74 73 0D 0A 65 6E 64 0D 0A          t_facts..end..

Note all of the 0D 0A references CRLF

Comment by Glenn Sarti [ 2017/09/27 ]

Should we perhaps be using binary mode to stop the CRLF conversion?

https://github.com/puppetlabs/pdk/blob/52f5ecf99d613206b29cfffbc68e3522279fc8bb/lib/pdk/generators/puppet_object.rb#L130

https://ruby-doc.org/core-2.2.2/IO.html Binary mode

Generated at Tue Nov 19 14:48:44 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.