diff --git a/lib/puppet/provider/grafana_team/grafana.rb b/lib/puppet/provider/grafana_team/grafana.rb index fdde07f8..f3260df6 100644 --- a/lib/puppet/provider/grafana_team/grafana.rb +++ b/lib/puppet/provider/grafana_team/grafana.rb @@ -99,11 +99,7 @@ def setup_save_preferences_data theme: resource[:theme], timezone: resource[:timezone] } - if major_version >= 10 - request_data[:homeDashboardUID] = dash[:uid] - else - request_data[:homeDashboardId] = dash[:id] - end + request_data[:homeDashboardUID] = dash[:uid] ['PUT', endpoint, request_data] end @@ -159,11 +155,6 @@ def version @version = data['version'] end - def major_version - version unless @version - @version.split('.').first.to_i - end - def setup_search_path(ident, folder_id = nil, search = false) query = if search { diff --git a/spec/acceptance/grafana_datasource_spec.rb b/spec/acceptance/grafana_datasource_spec.rb index d0fd6642..f5d40db6 100644 --- a/spec/acceptance/grafana_datasource_spec.rb +++ b/spec/acceptance/grafana_datasource_spec.rb @@ -47,113 +47,66 @@ class { 'grafana': end end - if Gem::Version.new(grafana_version) > Gem::Version.new('9') - context 'with basic auth in secure json data' do - let(:manifest) do - <<-PUPPET - grafana_datasource { 'prometheus2': - grafana_url => 'http://localhost:3000', - grafana_user => 'admin', - grafana_password => 'admin', - type => 'prometheus', - url => 'https://prom2.example.com', - access_mode => 'proxy', - json_data => { - 'httpMethod' => 'POST', - 'timeInterval' => '10s', - }, - secure_json_data => { - 'basicAuthPassword' => 'prom_password', - }, - basic_auth_user => 'prom_user', - } - PUPPET - end - - it 'works with no errors' do - apply_manifest_on(default, manifest, catch_failures: true) - end + context 'with basic auth in secure json data' do + let(:manifest) do + <<-PUPPET + grafana_datasource { 'prometheus2': + grafana_url => 'http://localhost:3000', + grafana_user => 'admin', + grafana_password => 'admin', + type => 'prometheus', + url => 'https://prom2.example.com', + access_mode => 'proxy', + json_data => { + 'httpMethod' => 'POST', + 'timeInterval' => '10s', + }, + secure_json_data => { + 'basicAuthPassword' => 'prom_password', + }, + basic_auth_user => 'prom_user', + } + PUPPET + end - it 'is idempotent' do - pending('secure_json_data is not returned by API') - apply_manifest_on(default, manifest, catch_changes: true) - end + it 'works with no errors' do + apply_manifest_on(default, manifest, catch_failures: true) end - else - context 'with basic auth in legacy field' do - it_behaves_like 'an idempotent resource' do - let(:manifest) do - <<-PUPPET - grafana_datasource { 'prometheus2': - grafana_url => 'http://localhost:3000', - grafana_user => 'admin', - grafana_password => 'admin', - type => 'prometheus', - url => 'https://prom2.example.com', - access_mode => 'proxy', - json_data => { - 'httpMethod' => 'POST', - 'timeInterval' => '10s', - }, - basic_auth_user => 'prom_user', - basic_auth_password => 'prom_password', - } - PUPPET - end - end + + it 'is idempotent' do + pending('secure_json_data is not returned by API') + apply_manifest_on(default, manifest, catch_changes: true) end end end describe 'influxdb ds' do - if Gem::Version.new(grafana_version) > Gem::Version.new('9') - context 'with password in secure_json_data' do - let(:manifest) do - <<-PUPPET - grafana_datasource { 'influxdb': - grafana_url => 'http://localhost:3000', - grafana_user => 'admin', - grafana_password => 'admin', - type => 'influxdb', - url => 'http://localhost:8086', - access_mode => 'proxy', - user => 'admin', - secure_json_data => { - 'password' => '1nFlux5ecret', - }, - database => 'mydb', - } - PUPPET - end - - it 'works with no errors' do - apply_manifest_on(default, manifest, catch_failures: true) - end + context 'with password in secure_json_data' do + let(:manifest) do + <<-PUPPET + grafana_datasource { 'influxdb': + grafana_url => 'http://localhost:3000', + grafana_user => 'admin', + grafana_password => 'admin', + type => 'influxdb', + url => 'http://localhost:8086', + access_mode => 'proxy', + user => 'admin', + secure_json_data => { + 'password' => '1nFlux5ecret', + }, + database => 'mydb', + } + PUPPET + end - it 'is idempotent' do - pending('secure_json_data is not returned by API') - apply_manifest_on(default, manifest, catch_changes: true) - end + it 'works with no errors' do + apply_manifest_on(default, manifest, catch_failures: true) end - else - context 'with password in legacy field' do - it_behaves_like 'an idempotent resource' do - let(:manifest) do - <<-PUPPET - grafana_datasource { 'influxdb': - grafana_url => 'http://localhost:3000', - grafana_user => 'admin', - grafana_password => 'admin', - type => 'influxdb', - url => 'http://localhost:8086', - access_mode => 'proxy', - user => 'admin', - password => '1nFlux5ecret', - database => 'mydb', - } - PUPPET - end - end + + it 'is idempotent' do + pending('secure_json_data is not returned by API') + apply_manifest_on(default, manifest, catch_changes: true) end end end diff --git a/spec/acceptance/grafana_team_spec.rb b/spec/acceptance/grafana_team_spec.rb index f081c836..1a48c3a4 100644 --- a/spec/acceptance/grafana_team_spec.rb +++ b/spec/acceptance/grafana_team_spec.rb @@ -48,12 +48,7 @@ class { 'grafana': it 'has set default home dashboard' do shell('curl --user admin:admin http://localhost:3000/api/teams/1/preferences') do |f| data = JSON.parse(f.stdout) - # preferences are empty by default in Grafana 10 - if grafana_version =~ %r{^(8|9)} - expect(data).to include('homeDashboardId' => 0) - else - expect(data).to be_empty - end + expect(data).to be_empty end end end diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index af885cff..aa89b0e2 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -21,7 +21,7 @@ let(:params) do { install_method: 'package', - version: '5.4.2' + version: '11.0.0' } end @@ -32,7 +32,7 @@ describe 'use archive to fetch the package to a temporary location' do it do expect(subject).to contain_archive('/tmp/grafana.deb').with_source( - 'https://dl.grafana.com/oss/release/grafana_5.4.2_amd64.deb' + 'https://dl.grafana.com/oss/release/grafana_11.0.0_amd64.deb' ) end @@ -158,13 +158,13 @@ let(:params) do { install_method: 'archive', - version: '5.4.2' + version: '11.0.0' } end install_dir = '/usr/share/grafana' service_config = '/usr/share/grafana/conf/custom.ini' - archive_source = 'https://dl.grafana.com/oss/release/grafana-5.4.2.linux-amd64.tar.gz' + archive_source = 'https://dl.grafana.com/oss/release/grafana-11.0.0.linux-amd64.tar.gz' describe 'extract archive to install_dir' do it { is_expected.to contain_archive('/tmp/grafana.tar.gz').with_ensure('present') } @@ -474,7 +474,7 @@ context 'provisioning_dashboards defined' do let(:params) do { - version: '6.0.0', + version: '11.0.0', provisioning_dashboards: { apiVersion: 1, providers: [ @@ -509,7 +509,7 @@ context 'without puppetsource defined' do let(:params) do { - version: '6.0.0', + version: '11.0.0', provisioning_dashboards: { apiVersion: 1, providers: [ diff --git a/spec/support/acceptance/supported_versions.rb b/spec/support/acceptance/supported_versions.rb index 46fa0e19..19656125 100644 --- a/spec/support/acceptance/supported_versions.rb +++ b/spec/support/acceptance/supported_versions.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true def supported_versions - %w[8.5.22 9.2.15 10.3.1 11.0.0] + %w[10.4.3 11.0.0] end