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

Add support for the Certbot Gandi plugin #295

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

cible
Copy link
Contributor

@cible cible commented Aug 26, 2022

Pull Request (PR) description

Adding feature support for the certbot-plugin-gandi created by @obynio

The plugin use the Production API key.

This Pull Request (PR) fixes the following issues

N/A

data/FreeBSD-family.yaml Outdated Show resolved Hide resolved
data/os/Debian/11.yaml Outdated Show resolved Hide resolved
Comment on lines 25 to 35
if $package_provider {
package { $package_name:
ensure => installed,
provider => $package_provider,
}
}
else {
package { $package_name:
ensure => installed,
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just pass undef along:

Suggested change
if $package_provider {
package { $package_name:
ensure => installed,
provider => $package_provider,
}
}
else {
package { $package_name:
ensure => installed,
}
}
package { $package_name:
ensure => installed,
provider => $package_provider,
}

Comment on lines 38 to 44
if $api_key {
$ini_vars = {
'certbot_plugin_gandi:dns_api_key' => $api_key,
}
} else {
fail('api_key not provided for certbot dns gandi plugin.')
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data type guarantees it's set

Suggested change
if $api_key {
$ini_vars = {
'certbot_plugin_gandi:dns_api_key' => $api_key,
}
} else {
fail('api_key not provided for certbot dns gandi plugin.')
}
$ini_vars = {
'certbot_plugin_gandi:dns_api_key' => $api_key,
}

data/RedHat-family.yaml Outdated Show resolved Hide resolved
@treydock treydock requested review from ekohl and smortex November 16, 2022 18:33
@treydock
Copy link
Contributor

@cible Is this ready for review? The pull request is currently marked as a draft.

@treydock treydock added the enhancement New feature or request label Nov 16, 2022
manifests/plugin/dns_gandi.pp Outdated Show resolved Hide resolved
class letsencrypt::plugin::dns_gandi (
String[1] $api_key,
String[1] $package_name,
Optional[String[1]] $package_provider = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unused parameter. Shouldn't it be passed to the package resource?

manifests/plugin/dns_gandi.pp Outdated Show resolved Hide resolved
spec/spec_helper_acceptance.rb Show resolved Hide resolved
Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>

it do
if package_name.nil?
is_expected.not_to compile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better way is to test for the error:

Suggested change
is_expected.not_to compile
is_expected.to compile.and_raise_error(/A Matcher For The Error/)

PUPPET
end

it { is_expected.not_to compile.with_all_deps }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too it's better to compile and test for a specific error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this one, the module won't work with an empty api_key and I don't know how to handle the error:

  13) letsencrypt::certonly on fedora-36-x86_64 based operating systems with dns-gandi plugin without api_key is expected to fail to compile and raise an error matching /\/expects a value for parameter 'api_key'\//
      Failure/Error: it { is_expected.to compile.and_raise_error(%r{/expects a value for parameter 'api_key'/}) }
        error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Class[Letsencrypt::Plugin::Dns_gandi]: expects a value for parameter 'api_key' (line: 6, column: 11

it { is_expected.to compile.and_raise_error(%r{/expects a value for parameter 'api_key'/}) } is not correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The / is redundant. In Ruby you can define a regex as /my regex/ or %r{my regex} but %r{/my regex/} means you expect / in the output. This is useful if you want to test /var/lib is empty is in the error. Compare %r{/var/lib is empty} to /\/var\/lib is empty/.

manifests/plugin/dns_gandi.pp Outdated Show resolved Hide resolved
spec/classes/plugin/dns_gandi_spec.rb Outdated Show resolved Hide resolved
spec/classes/plugin/dns_gandi_spec.rb Outdated Show resolved Hide resolved
spec/classes/plugin/dns_gandi_spec.rb Outdated Show resolved Hide resolved
@cible
Copy link
Contributor Author

cible commented Nov 23, 2022

It seem ok for me. Sorry for being so slow and bad with ruby. Did I have to do something else? rebase?

@cible cible marked this pull request as ready for review November 23, 2022 14:58
@bastelfreak
Copy link
Member

@cible yes, this needs a rebase. I think we can merge if afterwards 👍

@kenyon kenyon changed the title Adding feature support for the Certbot plugin Gandi Add support for the Certbot Gandi plugin Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants