Skip to content

Commit

Permalink
Merge pull request #351 from rabbitt/feature/internal-locations
Browse files Browse the repository at this point in the history
add ability to designate location as internal
  • Loading branch information
James Fryman committed Jun 24, 2014
2 parents 400e58a + 9b14ba9 commit a861f23
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
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

0 comments on commit a861f23

Please sign in to comment.