Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement plugin versions #263

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3d73de8
Fix #104 - User password set on each puppet run
TuningYourCode Mar 12, 2020
f62ffc2
Merge branch 'voxpupuli:master' into master
TuningYourCode Oct 13, 2021
748e72c
Merge branch 'voxpupuli:master' into master
TuningYourCode Mar 4, 2022
c66bcab
Add package provider for improved plugin handling #178
TuningYourCode Oct 13, 2021
b3dbb1e
rubocop: fix namespaces
bastelfreak Mar 8, 2022
a0e6673
Accept `Sensitive` `cfg`
alexjfisher May 17, 2022
b4e5aa5
Remove outdated `Integer note` from README
alexjfisher May 23, 2022
29b2d16
Accept `Sensitive` `ldap_cfg`
alexjfisher May 23, 2022
b61020c
Fix `grafana_user` and switch to using `flush`
alexjfisher May 24, 2022
f36e625
Fix performance of `grafana_user`
alexjfisher May 26, 2022
fcbbe60
Remove `address` param from `grafana_organization`
alexjfisher May 26, 2022
81c2517
Add `organizations` property to `grafana_user`
alexjfisher May 30, 2022
b928d72
Disable Arch Linux testing
bastelfreak Aug 15, 2022
4cc713d
modulesync 5.3.0
bastelfreak Mar 8, 2022
e83dc36
beaker tests: install lsb-release on Debian osfamily
bastelfreak Mar 8, 2022
5573242
Add support for custom repository URL
Aug 11, 2022
3483c8c
Switch documentation to puppet strings
Aug 16, 2022
8d1f19b
Release 11.0.0
bastelfreak Aug 17, 2022
aee7364
[blacksmith] Bump version to 11.0.1-rc0
bastelfreak Aug 17, 2022
872d4d2
modulesync 5.3.0
bastelfreak Oct 2, 2022
5fd3765
Refactor `grafana_datasource`
alexjfisher Oct 6, 2022
fad2da5
Fix `grafana_folder` `permissions` idempotency
alexjfisher Oct 10, 2022
782fb46
Updated the link to the toml gem
Oct 7, 2022
4294f05
Do not show datasource config changes
fklajn Aug 25, 2022
08cd6b0
Release 11.1.0
alexjfisher Nov 1, 2022
d2420b5
Regenerate `REFERENCE.md`
alexjfisher Nov 2, 2022
95595d3
[blacksmith] Bump version to 11.1.1-rc0
alexjfisher Nov 2, 2022
5027685
modulesync 5.4.0
bastelfreak Dec 20, 2022
c567602
Fix default PGP key
smortex Feb 3, 2023
a86d01f
Move static default settings from Hiera to Puppet
smortex Feb 3, 2023
dd288e9
modulesync 5.4.0
bastelfreak Mar 4, 2023
a7d5c0b
Regenerate REFERENCE.md
bastelfreak Mar 4, 2023
43ab0f6
puppet-lint: Enable parameter_documentation check
bastelfreak Mar 4, 2023
5dd818d
Update repo urls
promasu Mar 17, 2023
ccdd5b9
Add Rocky 8 support
bastelfreak Mar 4, 2023
6e8ab63
Add AlmaLinux 8 support
bastelfreak Mar 4, 2023
815e35f
Disable beta packages tests on Debian
smortex Mar 22, 2023
44ecf2a
Drop older grafana versions (6.x, 7.x) from tests
smortex Mar 22, 2023
8475817
Release 11.2.0
smortex Mar 22, 2023
6c0d3bf
[blacksmith] Bump version to 11.2.1-rc0
bastelfreak Mar 30, 2023
375c019
modulesync 5.5.0
maxadamo Apr 15, 2023
23dce35
Drop Puppet 6 support
bastelfreak Apr 28, 2023
b0dad4e
puppet/archive: Allow 7.x
bastelfreak Jun 14, 2023
1d60f8d
puppetlabs/stdlib: Require 9.x
bastelfreak Jun 14, 2023
977b970
CI: Use puppetlabs/apt 9.1
bastelfreak Jun 14, 2023
4051e04
Release 12.0.0
bastelfreak Jun 14, 2023
3f9b459
[blacksmith] Bump version to 12.0.1-rc0
bastelfreak Jun 14, 2023
b857460
cleanup .fixtures.yml
bastelfreak Jun 22, 2023
4c8ea4e
modulesync 6.0.0
bastelfreak Jun 22, 2023
5b4e34e
Add puppet 8 support
bastelfreak Jun 22, 2023
3f920cc
puppetlabs/stdlib: Require 9.x
bastelfreak Jun 22, 2023
7743da4
Add EL9 support
bastelfreak Jun 22, 2023
145c11e
Add Ubuntu 22.04 support
bastelfreak Jun 22, 2023
85868c7
Release 13.0.0
bastelfreak Jun 22, 2023
7208307
[blacksmith] Bump version to 13.0.1-rc0
bastelfreak Jun 22, 2023
7221ec8
Fix #104 - User password set on each puppet run
TuningYourCode Mar 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def existing_permissions
end
end

def permission_data(destroy = false) # rubocop:disable Style/OptionalBooleanParameter
def permission_data(destroy = false)
raise format('Unknown dashboard: %s', resource[:dashboard]) unless dashboard

endpoint = format('%s/dashboards/id/%s/permissions', grafana_api_path, dashboard[:id])
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/grafana_datasource/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def password=(value)
save_datasource
end

# rubocop:disable Style/PredicateName
# rubocop:disable Naming/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 Style/PredicateName
# rubocop:enable Naming/PredicateName

def basic_auth
datasource[:basic_auth]
Expand Down
72 changes: 72 additions & 0 deletions lib/puppet/provider/package/grafana.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# frozen_string_literal: true

require 'puppet/provider/package'

Puppet::Type.type(:package).provide :grafana, parent: Puppet::Provider::Package do
desc 'This provider only handles grafana plugins.'

has_feature :installable, :install_options, :uninstallable, :upgradeable, :versionable

has_command(:grafana_cli, 'grafana-cli') do
is_optional
end

def self.pluginslist
plugins = {}

grafana_cli('plugins', 'ls').split(%r{\n}).each do |line|
next unless line =~ %r{^(\S+)\s+@\s+((?:\d\.).+)\s*$}

name = Regexp.last_match(1)
version = Regexp.last_match(2)
plugins[name] = version
end

plugins
end

def self.instances
pluginslist.map do |k, v|
new(name: k, ensure: v, provider: 'grafana')
end
end

def query
plugins = self.class.pluginslist

if plugins.key?(resource[:name])
{ ensure: plugins[resource[:name]], name: resource[:name] }
else
{ ensure: :absent, name: resource[:name] }
end
end

def latest
grafana_cli('plugins', 'list-versions', resource[:name]).lines.first.strip
end

def update
cmd = %w[plugins update]
cmd << install_options if resource[:install_options]
cmd << resource[:name]

grafana_cli(*cmd)
end

def install
cmd = %w[plugins install]
cmd << install_options if resource[:install_options]
cmd << resource[:name]
cmd << resource[:ensure] unless resource[:ensure].is_a? Symbol

grafana_cli(*cmd)
end

def install_options
join_options(resource[:install_options])
end

def uninstall
grafana_cli('plugins', 'uninstall', resource[:name])
end
end
4 changes: 2 additions & 2 deletions lib/puppet/type/grafana_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

newproperty(:password) do
desc 'The password for the user'
def insync?(_is) # rubocop:disable Naming/MethodParameterName
def insync?(_is)
provider.check_password
end
end
Expand All @@ -60,7 +60,7 @@ def insync?(_is) # rubocop:disable Naming/MethodParameterName
defaultto :false
end

def set_sensitive_parameters(sensitive_parameters) # rubocop:disable Style/AccessorMethodName
def set_sensitive_parameters(sensitive_parameters) # rubocop:disable Naming/AccessorMethodName
parameter(:password).sensitive = true if parameter(:password)
super(sensitive_parameters)
end
Expand Down
26 changes: 26 additions & 0 deletions spec/acceptance/grafana_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,31 @@ class { 'grafana':
end
end
end

context 'grafana plugins' do
it 'installs' do
pp = <<-EOS
class { 'grafana':
version => 'latest',
}

package { 'grafana-image-renderer':
provider => 'grafana',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe package('grafana-image-renderer') do
it { is_expected.to be_installed }
end

describe service('grafana-server') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end
end
end
2 changes: 0 additions & 2 deletions spec/classes/grafana_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
it { is_expected.to contain_class('grafana::service') }
end

# rubocop:disable RSpec/EmptyExampleGroup
context 'with parameter install_method is set to package' do
let(:params) do
{
Expand Down Expand Up @@ -461,7 +460,6 @@
end
end
end
# rubocop:enable RSpec/EmptyExampleGroup
end
end
end