From abce35c11217296b2d1e65f94226a91040fdd2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phanie=20Jaumotte?= Date: Tue, 30 Jul 2024 11:03:31 +0200 Subject: [PATCH] squash all modification license endpoint --- lib/puppet/provider/elasticsearch_license/xpack.rb | 7 +++---- manifests/license.pp | 2 +- spec/classes/006_elasticsearch_license_spec.rb | 4 ++-- spec/unit/provider/elasticsearch_license/xpack_spec.rb | 10 +++++----- types/multipath.pp | 1 - types/status.pp | 1 - 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/puppet/provider/elasticsearch_license/xpack.rb b/lib/puppet/provider/elasticsearch_license/xpack.rb index 4bae734c5..7053faf8b 100644 --- a/lib/puppet/provider/elasticsearch_license/xpack.rb +++ b/lib/puppet/provider/elasticsearch_license/xpack.rb @@ -3,20 +3,19 @@ require 'puppet/provider/elastic_rest' Puppet::Type.type(:elasticsearch_license).provide( - :xpack, - api_resource_style: :bare, + :ruby, parent: Puppet::Provider::ElasticREST, metadata: :content, metadata_pipeline: [ ->(data) { Puppet_X::Elastic.deep_to_s data }, ->(data) { Puppet_X::Elastic.deep_to_i data } ], - api_uri: '_xpack/license', + api_uri: '_license', query_string: { 'acknowledge' => 'true' } ) do - desc 'A REST API based provider to manage Elasticsearch X-Pack licenses.' + desc 'A REST API based provider to manage Elasticsearch licenses.' mk_resource_methods diff --git a/manifests/license.pp b/manifests/license.pp index 866b85775..ea6025a11 100644 --- a/manifests/license.pp +++ b/manifests/license.pp @@ -72,7 +72,7 @@ port => $api_port, timeout => $api_timeout, } - -> elasticsearch_license { 'xpack': + -> elasticsearch_license { 'license': ensure => $ensure, content => $_content, protocol => $api_protocol, diff --git a/spec/classes/006_elasticsearch_license_spec.rb b/spec/classes/006_elasticsearch_license_spec.rb index 580bdadef..b8ce3d957 100644 --- a/spec/classes/006_elasticsearch_license_spec.rb +++ b/spec/classes/006_elasticsearch_license_spec.rb @@ -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' => { diff --git a/spec/unit/provider/elasticsearch_license/xpack_spec.rb b/spec/unit/provider/elasticsearch_license/xpack_spec.rb index 00691acab..4b444de50 100644 --- a/spec/unit/provider/elasticsearch_license/xpack_spec.rb +++ b/spec/unit/provider/elasticsearch_license/xpack_spec.rb @@ -2,14 +2,14 @@ require_relative '../../../helpers/unit/provider/elasticsearch_rest_shared_examples' -describe Puppet::Type.type(:elasticsearch_license).provider(:xpack) do # rubocop:disable RSpec/MultipleMemoizedHelpers - let(:name) { 'xpack' } +describe Puppet::Type.type(:elasticsearch_license).provider(:ruby) do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:name) { 'ruby' } let(:example1) do { - name: 'xpack', + name: 'ruby', ensure: :present, - provider: :xpack, + provider: :ruby, content: { 'license' => { 'status' => 'active', @@ -59,5 +59,5 @@ } end - include_examples 'REST API', 'xpack/license', nil, true + include_examples 'REST API', 'license', nil, true end diff --git a/types/multipath.pp b/types/multipath.pp index 94126dc82..63dea224d 100644 --- a/types/multipath.pp +++ b/types/multipath.pp @@ -1,2 +1 @@ -# Multipath type type Elasticsearch::Multipath = Variant[Array[Stdlib::Absolutepath], Stdlib::Absolutepath] diff --git a/types/status.pp b/types/status.pp index 296557c75..e31498bdb 100644 --- a/types/status.pp +++ b/types/status.pp @@ -1,2 +1 @@ -# Status type type Elasticsearch::Status = Enum['enabled', 'disabled', 'running', 'unmanaged']