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 ability to designate location as internal #351

Merged
merged 1 commit into from
Jun 24, 2014
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
6 changes: 6 additions & 0 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Parameters:
# [*ensure*] - Enables or disables the specified location
# (present|absent)
# [*internal*] - Indicates whether or not this loation can be
# used for internal requests only. Default: false
# [*vhost*] - Defines the default vHost for this location
# entry to include with
# [*location*] - Specifies the URI associated with this location
Expand Down Expand Up @@ -102,6 +104,7 @@

define nginx::resource::location (
$ensure = present,
$internal = false,
$location = $name,
$vhost = undef,
$www_root = undef,
Expand Down Expand Up @@ -178,6 +181,9 @@
if ($fastcgi_split_path != undef) {
validate_string($fastcgi_split_path)
}

validate_bool($internal)

validate_bool($ssl)
validate_bool($ssl_only)
if ($location_alias != undef) {
Expand Down
72 changes: 72 additions & 0 deletions spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@
:value => 'my_location',
:match => ' location my_location {',
},
{
:title => 'should not set internal',
:attr => 'internal',
:value => false,
:notmatch => /internal;/
},
{
:title => 'should set internal',
:attr => 'internal',
:value => true,
:match => ' internal;'
},
{
:title => 'should contain ordered prepended directives',
:attr => 'location_cfg_prepend',
Expand Down Expand Up @@ -167,6 +179,18 @@
:value => 'my_location',
:match => ' location my_location {',
},
{
:title => 'should not set internal',
:attr => 'internal',
:value => false,
:notmatch => /internal;/
},
{
:title => 'should set internal',
:attr => 'internal',
:value => true,
:match => ' internal;'
},
{
:title => 'should contain ordered prepended directives',
:attr => 'location_cfg_prepend',
Expand Down Expand Up @@ -230,6 +254,18 @@
:value => 'my_location',
:match => ' location my_location {',
},
{
:title => 'should not set internal',
:attr => 'internal',
:value => false,
:notmatch => /internal;/
},
{
:title => 'should set internal',
:attr => 'internal',
:value => true,
:match => ' internal;'
},
{
:title => 'should contain ordered prepended directives',
:attr => 'location_cfg_prepend',
Expand Down Expand Up @@ -287,6 +323,18 @@
:value => 'my_location',
:match => ' location my_location {',
},
{
:title => 'should not set internal',
:attr => 'internal',
:value => false,
:notmatch => /internal;/
},
{
:title => 'should set internal',
:attr => 'internal',
:value => true,
:match => ' internal;'
},
{
:title => 'should contain ordered prepended directives',
:attr => 'location_cfg_prepend',
Expand Down Expand Up @@ -380,6 +428,18 @@
:value => 'my_location',
:match => ' location my_location {',
},
{
:title => 'should not set internal',
:attr => 'internal',
:value => false,
:notmatch => /internal;/
},
{
:title => 'should set internal',
:attr => 'internal',
:value => true,
:match => ' internal;'
},
{
:title => 'should set the allow directive',
:attr => 'location_allow',
Expand Down Expand Up @@ -499,6 +559,18 @@
:value => 'my_location',
:match => ' location my_location {',
},
{
:title => 'should not set internal',
:attr => 'internal',
:value => false,
:notmatch => /internal;/
},
{
:title => 'should set internal',
:attr => 'internal',
:value => true,
:match => ' internal;'
},
{
:title => 'should contain ordered config directives',
:attr => 'location_custom_cfg',
Expand Down
3 changes: 3 additions & 0 deletions templates/vhost/location_header.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
location <%= @location %> {
<% if @internal -%>
internal;
<% end -%>
<% if @location_allow -%>
<%- @location_allow.each do |allow_rule| -%>
allow <%= allow_rule %>;
Expand Down