Skip to content

Commit

Permalink
Merge pull request #271 from solarkennedy/rebase_218
Browse files Browse the repository at this point in the history
Rebase #218
  • Loading branch information
solarkennedy authored Jul 27, 2016
2 parents 7c0aa60 + 6f60982 commit 875a336
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ group :development do
end

group :test do
gem "json"
gem "json", '~> 1.8.3'
gem "json_pure", '~> 1.8.3'
# Pin for 1.8.7 compatibility for now
gem "rake", '< 11.0.0'
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.7.0'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ DEPENDENCIES
beaker-rspec (>= 5.1.0)
hiera
hiera-puppet-helper
json
json (~> 1.8.3)
pry
puppet (~> 3.7.0)
puppet-blacksmith
Expand All @@ -317,4 +317,4 @@ DEPENDENCIES
vagrant-wrapper

BUNDLED WITH
1.10.6
1.11.2
5 changes: 3 additions & 2 deletions lib/puppet/provider/consul_acl/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def self.prefetch(resources)
Puppet.debug("prefetching for #{name}")
port = resource[:port]
hostname = resource[:hostname]
protocol = resource[:protocol]
token = resource[:acl_api_token]

found_acls = list_resources(token, port, hostname).select do |acl|
Expand All @@ -35,7 +36,7 @@ def self.list_resources(acl_api_token, port, hostname)

# this might be configurable by searching /etc/consul.d
# but would break for anyone using nonstandard paths
uri = URI("http://#{hostname}:#{port}/v1/acl")
uri = URI("#{protocol}://#{hostname}:#{port}/v1/acl")
http = Net::HTTP.new(uri.host, uri.port)

path=uri.request_uri + "/list?token=#{acl_api_token}"
Expand Down Expand Up @@ -69,7 +70,7 @@ def self.list_resources(acl_api_token, port, hostname)
end

def put_acl(method,body)
uri = URI("http://#{@resource[:hostname]}:#{@resource[:port]}/v1/acl")
uri = URI("#{@resource[:protocol]}://#{@resource[:hostname]}:#{@resource[:port]}/v1/acl")
http = Net::HTTP.new(uri.host, uri.port)
acl_api_token = @resource[:acl_api_token]
path = uri.request_uri + "/#{method}?token=#{acl_api_token}"
Expand Down
6 changes: 6 additions & 0 deletions lib/puppet/type/consul_acl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
desc 'ID of token'
end

newproperty(:protocol) do
desc 'consul protocol'
newvalues('http', 'https')
defaultto 'http'
end

newparam(:port) do
desc 'consul port'
defaultto 8500
Expand Down
4 changes: 4 additions & 0 deletions spec/unit/puppet/type/consul_acl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@
it 'should accept a hash of rules' do
expect(@acl[:rules]).to eq(samplerules)
end

it 'should default to http' do
expect(@acl[:protocol]).to eq(:http)
end
end
end

0 comments on commit 875a336

Please sign in to comment.