14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v10.0.1](https://github.com/voxpupuli/puppet-grafana/tree/v10.0.1) (2021-12-02)

[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v10.0.0...v10.0.1)

**Fixed bugs:**

- Grafana\_datasource no longer idempotent [\#270](https://github.com/voxpupuli/puppet-grafana/issues/270)
- Add support for HTTP operation PATCH to fix grafana\_membership [\#266](https://github.com/voxpupuli/puppet-grafana/pull/266) ([dgoetz](https://github.com/dgoetz))

**Merged pull requests:**

- Fix rubocop after disabling BooleanSymbol cop [\#271](https://github.com/voxpupuli/puppet-grafana/pull/271) ([root-expert](https://github.com/root-expert))
- Correct type for the example [\#265](https://github.com/voxpupuli/puppet-grafana/pull/265) ([earthgecko](https://github.com/earthgecko))

## [v10.0.0](https://github.com/voxpupuli/puppet-grafana/tree/v10.0.0) (2021-11-26)

[Full Changelog](https://github.com/voxpupuli/puppet-grafana/compare/v9.0.1...v10.0.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ app_mode = production
http_port = 8080

[database]
type = sqlite3
type = mysql
host = 127.0.0.1:3306
name = grafana
user = root
Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/provider/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def send_request(operation = 'GET', path = '', data = nil, search_path = {})
request = Net::HTTP::Get.new(uri.request_uri)
when 'DELETE'
request = Net::HTTP::Delete.new(uri.request_uri)
when 'PATCH'
request = Net::HTTP::Patch.new(uri.request_uri)
request.body = data.to_json
else
raise Puppet::Error, format('Unsupported HTTP operation %s', operation)
end
Expand Down
16 changes: 8 additions & 8 deletions lib/puppet/provider/grafana_datasource/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def datasources
password: datasource['password'],
database: datasource['database'],
access_mode: datasource['access'],
is_default: datasource['isDefault'] ? true : false,
with_credentials: datasource['withCredentials'] ? true : false,
basic_auth: datasource['basicAuth'] ? true : false,
is_default: datasource['isDefault'] ? :true : :false,
with_credentials: datasource['withCredentials'] ? :true : :false,
basic_auth: datasource['basicAuth'] ? :true : :false,
basic_auth_user: datasource['basicAuthUser'],
basic_auth_password: datasource['basicAuthPassword'],
json_data: datasource['jsonData'],
Expand Down Expand Up @@ -147,7 +147,7 @@ def password=(value)
save_datasource
end

# rubocop:disable Naming/PredicateName
# rubocop:disable Style/PredicateName
def is_default
datasource[:is_default]
end
Expand All @@ -156,7 +156,7 @@ def is_default=(value)
resource[:is_default] = value
save_datasource
end
# rubocop:enable Naming/PredicateName
# rubocop:enable Style/PredicateName

def basic_auth
datasource[:basic_auth]
Expand Down Expand Up @@ -225,11 +225,11 @@ def save_datasource
database: resource[:database],
user: resource[:user],
password: resource[:password],
isDefault: (resource[:is_default] == true),
basicAuth: (resource[:basic_auth] == true),
isDefault: (resource[:is_default] == :true),
basicAuth: (resource[:basic_auth] == :true),
basicAuthUser: resource[:basic_auth_user],
basicAuthPassword: resource[:basic_auth_password],
withCredentials: (resource[:with_credentials] == true),
withCredentials: (resource[:with_credentials] == :true),
jsonData: resource[:json_data],
secureJsonData: resource[:secure_json_data]
}
Expand Down
12 changes: 6 additions & 6 deletions lib/puppet/provider/grafana_notification/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def notifications
id: notification['id'],
name: notification['name'],
type: notification['type'],
is_default: notification['isDefault'] ? true : false,
send_reminder: notification['sendReminder'] ? true : false,
is_default: notification['isDefault'] ? :true : :false,
send_reminder: notification['sendReminder'] ? :true : :false,
frequency: notification['frequency'],
settings: notification['settings']
}
Expand All @@ -59,7 +59,7 @@ def type=(value)
save_notification
end

# rubocop:disable Naming/PredicateName
# rubocop:disable Style/PredicateName
def is_default
notification[:is_default]
end
Expand All @@ -77,7 +77,7 @@ def send_reminder=(value)
resource[:send_reminder] = value
save_notification
end
# rubocop:enable Naming/PredicateName
# rubocop:enable Style/PredicateName

def frequency
notification[:frequency]
Expand All @@ -101,8 +101,8 @@ def save_notification
data = {
name: resource[:name],
type: resource[:type],
isDefault: (resource[:is_default] == true),
sendReminder: (resource[:send_reminder] == true),
isDefault: (resource[:is_default] == :true),
sendReminder: (resource[:send_reminder] == :true),
frequency: resource[:frequency],
settings: resource[:settings]
}
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/provider/grafana_user/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def users
email: user['email'],
theme: user['theme'],
password: nil,
is_admin: user['isGrafanaAdmin'] ? true : false
is_admin: user['isGrafanaAdmin'] ? :true : :false
}
end
rescue JSON::ParserError
Expand Down Expand Up @@ -88,7 +88,7 @@ def password=(value)
save_user
end

# rubocop:disable Naming/PredicateName
# rubocop:disable Style/PredicateName
def is_admin
user[:is_admin]
end
Expand All @@ -97,7 +97,7 @@ def is_admin=(value)
resource[:is_admin] = value
save_user
end
# rubocop:enable Naming/PredicateName
# rubocop:enable Style/PredicateName

def save_user
data = {
Expand All @@ -106,7 +106,7 @@ def save_user
email: resource[:email],
password: resource[:password],
theme: resource[:theme],
isGrafanaAdmin: (resource[:is_admin] == true)
isGrafanaAdmin: (resource[:is_admin] == :true)
}

if user.nil?
Expand Down
12 changes: 6 additions & 6 deletions lib/puppet/type/grafana_datasource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@

newproperty(:is_default) do
desc 'Whether the datasource is the default one'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:basic_auth) do
desc 'Whether basic auth is enabled or not'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:basic_auth_user) do
Expand All @@ -93,8 +93,8 @@

newproperty(:with_credentials) do
desc 'Whether credentials such as cookies or auth headers should be sent with cross-site requests'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:json_data) do
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/type/grafana_notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@

newproperty(:is_default) do
desc 'Whether the notification is the default one'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:send_reminder) do
desc 'Whether automatic message resending is enabled or not'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:frequency) do
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/type/grafana_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def insync?(_is) # rubocop:disable Naming/MethodParameterName

newproperty(:is_admin) do
desc 'Whether the user is a grafana admin'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

def set_sensitive_parameters(sensitive_parameters) # rubocop:disable Naming/AccessorMethodName
def set_sensitive_parameters(sensitive_parameters) # rubocop:disable Style/AccessorMethodName
parameter(:password).sensitive = true if parameter(:password)
super(sensitive_parameters)
end
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-grafana",
"version": "10.0.0",
"version": "10.0.1",
"author": "Vox Pupuli",
"summary": "This module provides Grafana, a dashboard and graph editor for Graphite and InfluxDB.",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/grafana_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
describe 'create data_dir' do
it { is_expected.to contain_file('/var/lib/grafana').with_ensure('directory') }
end
when 'FreBSD'
when 'FreeBSD'
describe 'create data_dir' do
it { is_expected.to contain_file('/var/db/grafana').with_ensure('directory') }
end
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/puppet/type/grafana_datasource_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@
expect(gdatasource[:type]).to eq('elasticsearch')
expect(gdatasource[:organization]).to eq('test_org')
expect(gdatasource[:access_mode]).to eq(:proxy)
expect(gdatasource[:is_default]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gdatasource[:basic_auth]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gdatasource[:is_default]).to eq(:true)
expect(gdatasource[:basic_auth]).to eq(:true)
expect(gdatasource[:basic_auth_user]).to eq('user')
expect(gdatasource[:basic_auth_password]).to eq('password')
expect(gdatasource[:with_credentials]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gdatasource[:with_credentials]).to eq(:true)
expect(gdatasource[:database]).to eq('test_db')
expect(gdatasource[:user]).to eq('db_user')
expect(gdatasource[:password]).to eq('db_password')
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/puppet/type/grafana_notification_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
expect(gnotification[:name]).to eq('foo')
expect(gnotification[:grafana_url]).to eq('http://example.com')
expect(gnotification[:type]).to eq('email')
expect(gnotification[:is_default]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gnotification[:send_reminder]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gnotification[:is_default]).to eq(:true)
expect(gnotification[:send_reminder]).to eq(:true)
expect(gnotification[:frequency]).to eq('20m')
expect(gnotification[:settings]).to eq(adresses: 'test@example.com')
end
Expand Down