Skip to content

Commit

Permalink
Merge pull request #399 from chef/CHEF-12878-download-install-sh-from…
Browse files Browse the repository at this point in the history
…-new-download-api

Download install sh from new download api
  • Loading branch information
jaymzh authored Oct 29, 2024
2 parents 63193ba + ea92420 commit 98741b9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/mixlib/install/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ module Mixlib
class Install
class Generator
def self.install_command(options)
if options.for_ps1?
PowerShell.new(options).install_command
else
Bourne.new(options).install_command
end
klass = options.for_ps1? ? PowerShell : Bourne
meth = options.options[:new_omnibus_download_url] ? :install_sh_from_upstream : :install_command

klass.new(options).send(meth)
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions lib/mixlib/install/generator/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require "ostruct" unless defined?(OpenStruct)
require_relative "../util"
require_relative "../dist"
require "net/http" unless defined?(Net::HTTP)

module Mixlib
class Install
Expand Down Expand Up @@ -68,6 +69,17 @@ def self.get_script(name, context = {})
def get_script(name, context = {})
self.class.get_script(name, context)
end

def install_sh_from_upstream
uri = URI.parse(options.options[:new_omnibus_download_url])
response = Net::HTTP.get_response(uri)

if response.code == "200"
response.body
else
raise StandardError, "unable to fetch the install.sh"
end
end
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions lib/mixlib/install/script_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require_relative "generator/powershell"
require_relative "dist"
require "cgi"
require "net/http" unless defined?(Net::HTTP)

module Mixlib
class Install
Expand Down Expand Up @@ -101,6 +102,17 @@ def install_command
shell_code_from_file(vars)
end

def install_command_from_omnitruck(url)
uri = URI.parse(url)
response = Net::HTTP.get_response(uri)

if response.code == "200"
response.body
else
raise StandardError, "unable to fetch the install.sh"
end
end

private

# Generates the install command variables for Bourne shell-based
Expand Down

0 comments on commit 98741b9

Please sign in to comment.