Open elfranne opened 1 year ago
Ability to checkout the latest release.
Currently i made a custom lib to call Github API which is a simplified version of https://github.com/takumakume/puppet-github-release-properties :
require 'net/http' require 'uri' require 'json' require 'stringio' Puppet::Functions.create_function(:latest_git_tag) do dispatch :latest_git_tag do param 'String', :repo end def latest_git_tag(repo) uri = URI.parse("https://api.github.com/repos/#{repo}/releases/latest") http = Net::HTTP.new(uri.host, uri.port) http.open_timeout = 10 http.read_timeout = 15 http.use_ssl = true request = Net::HTTP::Get.new(uri) request['Content-Type'] = 'application/json' request['Accept'] = 'application/vnd.github.v3+json' request['Accept-Encoding'] = 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3' response = http.request(request) raise "#{response.code} #{response.message}: #{uri}" unless response.class == Net::HTTPOK raw_body = if response.header['Content-Encoding'].eql?('gzip') Zlib::GzipReader.new(StringIO.new(response.body)).read else response.body end return JSON.load(raw_body)['tag_name'] end end
That I use like that :
vcsrepo { '/path/to/repo': ensure => present, provider => git, source => 'git://example.com/repo.git', revision => latest_git_tag('puppetlabs/puppetlabs-vcsrepo'), }
Downloading the tarball might be an option ?
This is a very simplified that fit my very specific needs (Github). Is there a better way ? Feedback is very welcome !
Use Case
Ability to checkout the latest release.
Describe the Solution You Would Like
Currently i made a custom lib to call Github API which is a simplified version of https://github.com/takumakume/puppet-github-release-properties :
That I use like that :
Describe Alternatives You've Considered
Downloading the tarball might be an option ?
Additional Context
This is a very simplified that fit my very specific needs (Github). Is there a better way ? Feedback is very welcome !