Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-1100) Use PDK to build module packages #260

Merged
merged 3 commits into from
Oct 30, 2018
Merged

Conversation

rodjek
Copy link
Contributor

@rodjek rodjek commented Oct 5, 2018

Attempt to load the PDK gem first in order to use PDK as a library. If
that fails, fall back to executing pdk build.

Note This depends on PDK 1.7.1 being released and so shouldn't be
merged until then.

@codecov-io
Copy link

codecov-io commented Oct 5, 2018

Codecov Report

Merging #260 into master will decrease coverage by 0.06%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #260      +/-   ##
=========================================
- Coverage   40.46%   40.4%   -0.07%     
=========================================
  Files          10      10              
  Lines         734     750      +16     
=========================================
+ Hits          297     303       +6     
- Misses        437     447      +10
Impacted Files Coverage Δ
lib/puppetlabs_spec_helper/rake_tasks.rb 41.46% <33.33%> (-0.34%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 128b379...eecc826. Read the comment docs.

@puppetcla
Copy link

CLA signed by all contributors.

require 'puppet/face'
pmod = Puppet::Face['module', :current]
pmod.build('./')
require 'pdk/module/build'
Copy link
Contributor

Choose a reason for hiding this comment

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

Concerned about having this adding pdk gem as a soft dependency. If the default behavior is to use pdk's build feature as a library method, then perhaps we should add pdk as a runtime dependency.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm OK with the soft dependency for accessing it as a library but I think there should be a more explicit error message at the end if pdk is not available on their PATH, or fall back to loading the old face which I think is what Bryan is suggesting below?

path = PDK::Module::Build.invoke(:force => true, :'target-dir' => File.join(Dir.pwd, 'pkg'))
puts "Module built: #{path}"
rescue LoadError
system('pdk build --force')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also check if Puppet::Face['module', :current] is nil or returns an error? And potentially default to the old way if the puppet < 6 is being loaded?

Attempt to load the PDK gem first in order to use PDK as a library. If
that fails, fall back to executing `pdk build`.

*Note* This depends on PDK 1.7.1 being released and so shouldn't be
merged until then.
@rodjek
Copy link
Contributor Author

rodjek commented Oct 30, 2018

OK, I've gone back to a soft dependency for now until we can resolve the json_pure dependency in PDK that conflicts with Puppet 4.x.

As the logic currently stands:

  • If Puppet < 6.0.0, build with PMT as before
  • If Puppet > 6.0.0
    • If the PDK gem is available, use PDK as a library and call PDK::Module::Build.invoke
    • If the PDK gem is not available:
      • If PDK is installed, execute pdk build --force
      • If PDK is not installed, print an error asking the user to install PDK.

@bmjen bmjen merged commit dcfca89 into puppetlabs:master Oct 30, 2018
@rodjek rodjek deleted the pdk-1100 branch October 30, 2018 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants