Skip to content

Commit

Permalink
modify key
Browse files Browse the repository at this point in the history
  • Loading branch information
stjmt committed Jul 30, 2024
1 parent c1ae6e6 commit fff51f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
24 changes: 14 additions & 10 deletions lib/puppet/provider/elasticsearch_license/ruby.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
# frozen_string_literal: true

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))

require 'puppet/provider/elastic_rest'

require 'puppet_x/elastic/deep_to_i'
require 'puppet_x/elastic/deep_to_s'

Puppet::Type.type(:elasticsearch_license).provide(
:ruby,
parent: Puppet::Provider::ElasticREST,
api_uri: '_license?acknowledge=true',
metadata: :content,
metadata_pipeline: [
->(data) { Puppet_X::Elastic.deep_to_s data },
->(data) { Puppet_X::Elastic.deep_to_i data }
],
api_uri: '_license',
query_string: {
'acknowledge' => 'true'
}
]
) do
desc 'A REST API based provider to manage Elasticsearch licenses.'

mk_resource_methods

def self.process_body(body)
JSON.parse(body).map do |_object_name, api_object|
Puppet.debug('Got to license.process_body')

JSON.parse(body).map do |object_name, api_object|
{
:name => name.to_s,
:ensure => :present,
name: object_name,
ensure: :present,
metadata => { 'license' => process_metadata(api_object) },
:provider => name
}
provider: name
}.compact
end
end
end
2 changes: 1 addition & 1 deletion manifests/license.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
port => $api_port,
timeout => $api_timeout,
}
-> elasticsearch_license { 'xpack':
-> elasticsearch_license { 'license':
ensure => $ensure,
content => $_content,
protocol => $api_protocol,
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/006_elasticsearch_license_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class { 'elasticsearch' :
it do
expect(subject).to contain_es_instance_conn_validator(
'license-conn-validator'
).that_comes_before('elasticsearch_license[xpack]')
).that_comes_before('elasticsearch_license[license]')
end

it do
expect(subject).to contain_elasticsearch_license('xpack').with(
expect(subject).to contain_elasticsearch_license('license').with(
ensure: 'present',
content: {
'license' => {
Expand Down

0 comments on commit fff51f6

Please sign in to comment.