Skip to content

Commit

Permalink
Drop support for EoL Grafana 8 & 9
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jun 7, 2024
1 parent 0eb3012 commit 99a01de
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 119 deletions.
9 changes: 0 additions & 9 deletions lib/puppet/provider/grafana_team/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ def setup_save_preferences_data
theme: resource[:theme],
timezone: resource[:timezone]
}
if major_version >= 10
request_data[:homeDashboardUID] = dash[:uid]

Check failure on line 102 in lib/puppet/provider/grafana_team/grafana.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Layout/IndentationConsistency: Inconsistent indentation detected. (https://rubystyle.guide#spaces-indentation, https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions)
else
request_data[:homeDashboardId] = dash[:id]
end
['PUT', endpoint, request_data]
end

Expand Down Expand Up @@ -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
{
Expand Down
149 changes: 51 additions & 98 deletions spec/acceptance/grafana_datasource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions spec/acceptance/grafana_team_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions spec/classes/grafana_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
let(:params) do
{
install_method: 'package',
version: '5.4.2'
version: '11.0.0'
}
end

Expand All @@ -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

Expand Down Expand Up @@ -158,7 +158,7 @@
let(:params) do
{
install_method: 'archive',
version: '5.4.2'
version: '11.0.0'
}
end

Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion spec/support/acceptance/supported_versions.rb
Original file line number Diff line number Diff line change
@@ -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.3.1 11.0.0]
end

0 comments on commit 99a01de

Please sign in to comment.