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

Fail defined types if nginx class was not declared before #1070

Merged
merged 1 commit into from
Sep 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions manifests/resource/geo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
Optional[Boolean] $proxy_recursive = undef
) {

if ! defined(Class['nginx']) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is fine and probably goes with the style of the module as a whole... that said, I think some people would say that 'unless' is more idiomatic, and probably lines up better with https://docs.puppet.com/puppet/4.9/lang_conditional.html ? I like 'if not' better than 'if !' but IIRC, it may not work in the DSL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If or unless is IMHO very opinionated. I for myself prefer if over unless in most situations. But I'll change to unless if requested.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mostly just don't like if ! vs if not but I don't have a strong opinion, and it's used all throughout the code, so I don't see any reason to change it.

fail('You must include the nginx base class before using any defined resources')
}

$root_group = $::nginx::root_group
$conf_dir = "${::nginx::conf_dir}/conf.d"

Expand Down
4 changes: 4 additions & 0 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@
Optional[String] $expires = undef,
) {

if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

$root_group = $::nginx::root_group

File {
Expand Down
4 changes: 4 additions & 0 deletions manifests/resource/mailhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
Array $server_name = [$name]
) {

if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

$root_group = $::nginx::root_group

File {
Expand Down
4 changes: 4 additions & 0 deletions manifests/resource/map.pp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
Enum['absent', 'present'] $ensure = 'present',
Boolean $hostnames = false
) {
if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

validate_re($string, '^.{2,}$',
"Invalid string value [${string}]. Expected a minimum of 2 characters.")

Expand Down
4 changes: 4 additions & 0 deletions manifests/resource/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@
Hash $locations = {}
) {

if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

# Variables
if $::nginx::confd_only {
$server_dir = "${::nginx::conf_dir}/conf.d"
Expand Down
4 changes: 4 additions & 0 deletions manifests/resource/streamhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
String $mode = $::nginx::global_mode,
) {

if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

# Variables
if $::nginx::confd_only {
$streamhost_dir = "${::nginx::conf_dir}/conf.stream.d"
Expand Down
4 changes: 4 additions & 0 deletions manifests/resource/upstream.pp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
Enum['http', 'stream'] $upstream_context = 'http',
) {

if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

$root_group = $::nginx::root_group

$ensure_real = $ensure ? {
Expand Down
3 changes: 3 additions & 0 deletions manifests/resource/upstream/member.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
Integer $port = 80,
$upstream_fail_timeout = '10s',
) {
if ! defined(Class['nginx']) {
fail('You must include the nginx base class before using any defined resources')
}

# Uses: $server, $port, $upstream_fail_timeout
concat::fragment { "${upstream}_upstream_member_${name}":
Expand Down