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

Rebase #218 #271

Merged
merged 4 commits into from
Jul 27, 2016
Merged
Show file tree
Hide file tree
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
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