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

add support for puppet:// as a source to install gem #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/puppet/provider/rvm_gem/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ def self.gemsplit(desc)
end
end

def gemfile_from_puppet_url(source)
unless tmp = Puppet::FileServing::Content.indirection.find(source, :environment => resource.catalog.environment_instance, :links => :follow)
fail "Could not find gemfile at %s" % source
end
tmpfile = Tempfile.open(['puppet-rvm_geminstaller','.gem'])
tmpfile.write(tmp.content)
tmpfile.flush
return tmpfile.path.to_s
Comment on lines +83 to +86
Copy link
Member

Choose a reason for hiding this comment

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

I think this leaks a temporary file for every Puppet run.

Copy link
Author

Choose a reason for hiding this comment

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

You are correct the file persists. However, you cannot delete the file right there, as it would no longer be available for the installation procedure.

Unfortunately, I no longer have an instance to validate, but I believe the assumption was this would only be execute if the gem is missing and thus create a file once.

end

def install(useversion = true)
command = gembinary + ['install']
Expand All @@ -102,8 +111,7 @@ def install(useversion = true)
when /file/i
command << uri.path
when 'puppet'
# we don't support puppet:// URLs (yet)
raise Puppet::Error.new("puppet:// URLs are not supported as gem sources")
command << gemfile_from_puppet_url(uri.to_s)
else
# interpret it as a gem repository
command << "--source" << "#{source}" << resource[:name]
Expand Down