Skip to content

Commit

Permalink
Merge pull request #300 from visioncritical/fix-windows-install
Browse files Browse the repository at this point in the history
Fixed Windows installation issue
  • Loading branch information
johnbellone committed Mar 19, 2016
2 parents 5ab70f4 + b525b16 commit 9d3ecf5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions libraries/consul_installation_binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Copyright 2014-2016, Bloomberg Finance L.P.
#
require 'poise'
require_relative './helpers'

module ConsulCookbook
module Provider
Expand All @@ -18,6 +19,7 @@ module Provider
# @since 2.0
class ConsulInstallationBinary < Chef::Provider
include Poise(inversion: :consul_installation)
include ::ConsulCookbook::Helpers
provides(:binary)
inversion_attribute('consul')

Expand All @@ -31,12 +33,13 @@ def self.provides_auto?(_node, _resource)
# @api private
def self.default_inversion_options(node, resource)
archive_basename = binary_basename(node, resource)
extract_to = node.windows? ? node.config_prefix_path : '/opt/consul'
super.merge(
version: resource.version,
archive_url: default_archive_url % { version: resource.version, basename: archive_basename },
archive_basename: archive_basename,
archive_checksum: binary_checksum(node, resource),
extract_to: '/opt/consul'
extract_to: extract_to
)
end

Expand All @@ -47,12 +50,12 @@ def action_create
}

notifying_block do
directory ::File.join(options[:extract_to], new_resource.version) do
directory join_path(options[:extract_to], new_resource.version) do
recursive true
end

zipfile options[:archive_basename] do
path ::File.join(options[:extract_to], new_resource.version)
path join_path(options[:extract_to], new_resource.version)
source archive_url
checksum options[:archive_checksum]
not_if { ::File.exist?(consul_program) }
Expand All @@ -62,17 +65,16 @@ def action_create

def action_remove
notifying_block do
directory ::File.join(options[:extract_to], new_resource.version) do
directory join_path(options[:extract_to], new_resource.version) do
recursive true
action :delete
end
end
end

def consul_program
@program ||= ::File.join(options[:extract_to], new_resource.version, 'consul')
return @program unless node.platform?('windows')
@program + '.exe'
@program ||= join_path(options[:extract_to], new_resource.version, 'consul')
windows? ? @program + '.exe' : @program
end

def self.default_archive_url
Expand Down

0 comments on commit 9d3ecf5

Please sign in to comment.