Skip to content

Commit

Permalink
use arrays of strings instead of multiline strings
Browse files Browse the repository at this point in the history
  • Loading branch information
johrstrom committed Jan 10, 2024
1 parent 70cfb12 commit 16adcad
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 52 deletions.
4 changes: 2 additions & 2 deletions ood-portal-generator/lib/ood_portal_generator/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def initialize(opts = {})
@pun_stage_cmd = opts.fetch(:pun_stage_cmd, "sudo /opt/ood/nginx_stage/sbin/nginx_stage")

# custom directives
@custom_vhost_directives = opts.fetch(:custom_vhost_directives, nil)
@custom_location_directives = opts.fetch(:custom_location_directives, nil)
@custom_vhost_directives = opts.fetch(:custom_vhost_directives, [])
@custom_location_directives = opts.fetch(:custom_location_directives, [])

# Maintenance configuration
@use_maintenance = opts.fetch(:use_maintenance, true)
Expand Down
24 changes: 12 additions & 12 deletions ood-portal-generator/share/ood_portal_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,21 @@
# - 'AuthType openid-connect'
# - 'Require valid-user'

# Custom apache directives to apply to the entire vhost.
# Note this is a multiline string.
# List of custom apache directives to apply to the entire vhost.
# Note this is an array of strings.
# Example:
# custom_vhost_directives: |
# SetEnv SPECIAL_ENV_VAR custom
# Default: nil (no custom directives)
#custom_vhost_directives: nil
# custom_vhost_directives:
# - 'SetEnv SPECIAL_ENV_VAR custom'
# Default: [] (no custom directives)
#custom_vhost_directives: []

# Custom apache directives to apply to the Locations.
# Note this is a multiline string.
# List of custom apache directives to apply to the Locations.
# Note this is an array of strings.
# Example:
# custom_location_directives: |
# SetEnv SPECIAL_ENV_VAR custom
# Default: nil (no custom directives)
#custom_location_directives: nil
# custom_location_directives:
# - 'SetEnv SPECIAL_ENV_VAR custom'
# Default: [] (no custom directives)
#custom_location_directives: []

# Redirect user to the following URI when accessing root URI
# Example:
Expand Down
19 changes: 11 additions & 8 deletions ood-portal-generator/spec/fixtures/input/custom_directives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ auth:
- 'AuthType openid-connect'
- 'Require valid-user'

custom_location_directives: |
SetEnv SPECIAL_LOCATION_ENV_VAR custom_location
SetEnv SECOND_LOCATION_VAR custom_location2
SetEnv INDENTED_LOCATION_VAR custom_location3
custom_location_directives:
- 'SetEnv SPECIAL_LOCATION_ENV_VAR custom_location'
- 'SetEnv SECOND_LOCATION_VAR custom_location2'
- ' SetEnv INDENTED_LOCATION_VAR custom_location3'

custom_vhost_directives: |
SetEnv SPECIAL_VHOST_ENV_VAR custom_vhost
SetEnv SECOND_VHOST_VAR custom_vhost2
SetEnv INDENTED_VHOST_VAR custom_vhost3
custom_vhost_directives:
- SetEnv SPECIAL_VHOST_ENV_VAR custom_vhost
- SetEnv SECOND_VHOST_VAR custom_vhost2
- ' SetEnv INDENTED_VHOST_VAR custom_vhost3'
- '<Location "/foo">'
- ' SetEnv SPECIAL_VHOST_LOCATION_ENV_VAR custom_vhost4'
- '</Location>'

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ auth:
- 'AuthType openid-connect'
- 'Require valid-user'

custom_location_directives: |
SetEnv SPECIAL_LOCATION_ENV_VAR custom_location
SetEnv SECOND_LOCATION_VAR custom_location2
custom_location_directives:
- SetEnv SPECIAL_LOCATION_ENV_VAR custom_location
- SetEnv SECOND_LOCATION_VAR custom_location2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ auth:
- 'AuthType openid-connect'
- 'Require valid-user'

custom_vhost_directives: |
SetEnv SPECIAL_VHOST_ENV_VAR custom_vhost
SetEnv SECOND_VHOST_VAR custom_vhost2
custom_vhost_directives:
- SetEnv SPECIAL_VHOST_ENV_VAR custom_vhost
- SetEnv SECOND_VHOST_VAR custom_vhost2

1 change: 1 addition & 0 deletions ood-portal-generator/spec/fixtures/ood-portal.conf.all
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Listen 8080

SetEnv OOD_ALLOWED_HOSTS "foo.example.com,test.proxy.name,test.server.name"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
1 change: 1 addition & 0 deletions ood-portal-generator/spec/fixtures/ood-portal.conf.dex
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@

SetEnv OOD_ALLOWED_HOSTS "8.8.8.8,example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@

SetEnv OOD_ALLOWED_HOSTS "example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@

SetEnv OOD_ALLOWED_HOSTS "example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@

SetEnv OOD_ALLOWED_HOSTS "example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

SetEnv OOD_ALLOWED_HOSTS "8.8.8.8,example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
1 change: 1 addition & 0 deletions ood-portal-generator/spec/fixtures/ood-portal.conf.nomaint
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

SetEnv OOD_ALLOWED_HOSTS "8.8.8.8,example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
1 change: 1 addition & 0 deletions ood-portal-generator/spec/fixtures/ood-portal.conf.oidc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@

SetEnv OOD_ALLOWED_HOSTS "ondemand.example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@

SetEnv OOD_ALLOWED_HOSTS "ondemand.example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@

SetEnv OOD_ALLOWED_HOSTS "example-proxy.com,example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
1 change: 1 addition & 0 deletions ood-portal-generator/spec/fixtures/output/auth.conf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

SetEnv OOD_ALLOWED_HOSTS "8.8.8.8,example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
1 change: 1 addition & 0 deletions ood-portal-generator/spec/fixtures/output/auth_deb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

SetEnv OOD_ALLOWED_HOSTS "8.8.8.8,example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
SetEnv SPECIAL_VHOST_ENV_VAR custom_vhost
SetEnv SECOND_VHOST_VAR custom_vhost2
SetEnv INDENTED_VHOST_VAR custom_vhost3
<Location "/foo">
SetEnv SPECIAL_VHOST_LOCATION_ENV_VAR custom_vhost4
</Location>

#
# Below is used for sub-uri's this Open OnDemand portal supports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

SetEnv OOD_ALLOWED_HOSTS "8.8.8.8,example.com"


#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down
36 changes: 12 additions & 24 deletions ood-portal-generator/templates/ood-portal.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,10 @@ Listen <%= addr_port %>
SetEnv OOD_ALLOWED_HOSTS "<%= @allowed_hosts.join(',') %>"
<%- end -%>

<%- if @custom_vhost_directives -%>
<%- @custom_vhost_directives.each_line do |line| -%>
<%= line -%>
<%- @custom_vhost_directives.to_a.each do |line| -%>
<%= line %>
<%- end -%>

<%- end -%>
#
# Below is used for sub-uri's this Open OnDemand portal supports
#
Expand Down Expand Up @@ -227,10 +225,8 @@ Listen <%= addr_port %>
<%= line %>
<%- end -%>

<%- if @custom_location_directives -%>
<%- @custom_location_directives.each_line do |line| -%>
<%= line -%>
<%- end -%>
<%- @custom_location_directives.to_a.each do |line| -%>
<%= line %>
<%- end -%>

# ProxyPassReverse implementation
Expand Down Expand Up @@ -258,10 +254,8 @@ Listen <%= addr_port %>
<%= line %>
<%- end -%>

<%- if @custom_location_directives -%>
<%- @custom_location_directives.each_line do |line| -%>
<%= line -%>
<%- end -%>
<%- @custom_location_directives.to_a.each do |line| -%>
<%= line %>
<%- end -%>

# ProxyPassReverse implementation
Expand Down Expand Up @@ -290,10 +284,8 @@ Listen <%= addr_port %>
<%= line %>
<%- end -%>

<%- if @custom_location_directives -%>
<%- @custom_location_directives.each_line do |line| -%>
<%= line -%>
<%- end -%>
<%- @custom_location_directives.to_a.each do |line| -%>
<%= line %>
<%- end -%>

ProxyPreserveHost On
Expand Down Expand Up @@ -329,10 +321,8 @@ Listen <%= addr_port %>
<%= line %>
<%- end -%>

<%- if @custom_location_directives -%>
<%- @custom_location_directives.each_line do |line| -%>
<%= line -%>
<%- end -%>
<%- @custom_location_directives.to_a.each do |line| -%>
<%= line %>
<%- end -%>

LuaHookFixups nginx.lua nginx_handler
Expand Down Expand Up @@ -368,10 +358,8 @@ Listen <%= addr_port %>
<%= line %>
<%- end -%>

<%- if @custom_location_directives -%>
<%- @custom_location_directives.each_line do |line| -%>
<%= line -%>
<%- end -%>
<%- @custom_location_directives.to_a.each do |line| -%>
<%= line %>
<%- end -%>
</Location>
<%- end -%>
Expand Down

0 comments on commit 16adcad

Please sign in to comment.