mmckinst / puppet-lint-top_scope_facts-check

Find and convert from top scope facts to the trusted facts hash
Apache License 2.0
2 stars 4 forks source link

PDK validate --auto-correct creates issues when trying to correct a fact hash #13

Closed davidsandilands closed 1 year ago

davidsandilands commented 1 year ago

When running PDK validate with auto correct the top scope facts check creates errors on its correction when using a fact hash, this can be seen by doing the following

1) Create the following manifest:

file { 'test_file' :content   => file("example/etc/login.defs.${::operatingsystem}${::operatingsystemrelease}"),
 } 

2) Run validate command:

pdk validate 

3) Confirm legacy fact is detected

pdk (WARNING): puppet-lint: legacy fact (manifests/test.pp:2:60)
pdk (WARNING): puppet-lint: legacy fact (manifests/test.pp:2:80)

4) Run autocorrect on the validation command:

pdk validate --auto-correct --puppet-version 7.9.0

5) Confirm legacy fact is updated with autocorrect

pdk (CORRECTED): puppet-lint: top scope fact instead of facts hash (manifests/test.pp:2:60)
pdk (CORRECTED): puppet-lint: top scope fact instead of facts hash (manifests/test.pp:2:80) 

When you then run pdk validate an error is thrown:

pdk (ERROR): puppet-syntax: Could not parse for environment production: Syntax error at 'os' (manifests/test.pp:2:76) 
davidsandilands commented 1 year ago

Sorry posted on wrong module