# HG changeset patch
# User Naman Jagdish Gala <ngala@gitlab.com>
# Date 1674448960 0
#      Mon Jan 23 04:42:40 2023 +0000
# Node ID 45db6d923afdcc0c47a3aca9b3eb460976deed57
# Parent  c319ed1f9054112720c381761ece2fa410acd95b
Use config file for Pages Headers parameter instead of command line

Changelog: changed

diff --git a/files/gitlab-cookbooks/gitlab-pages/templates/default/gitlab-pages-config.erb b/files/gitlab-cookbooks/gitlab-pages/templates/default/gitlab-pages-config.erb
--- a/files/gitlab-cookbooks/gitlab-pages/templates/default/gitlab-pages-config.erb
+++ b/files/gitlab-cookbooks/gitlab-pages/templates/default/gitlab-pages-config.erb
@@ -185,3 +185,6 @@
 <%- if @redirects_max_rule_count -%>
 redirects-max-rule-count=<%= @redirects_max_rule_count %>
 <%-end -%>
+<%- if @headers -%>
+header=<%= @headers.join(';;') %>
+<%-end -%>
diff --git a/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-run.erb b/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-run.erb
--- a/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-run.erb
+++ b/files/gitlab-cookbooks/gitlab-pages/templates/default/sv-gitlab-pages-run.erb
@@ -12,6 +12,3 @@
 exec chpst -e <%= @options[:env_dir] %> \
     /opt/gitlab/embedded/bin/gitlab-pages \
     -config="<%= node['gitlab-pages']['dir'] %>/gitlab-pages-config" \
-    <% headers.each do |spec| %>
-    -header="<%= spec %>" \
-    <% end %>
diff --git a/spec/chef/cookbooks/gitlab-pages/recipes/gitlab-pages_spec.rb b/spec/chef/cookbooks/gitlab-pages/recipes/gitlab-pages_spec.rb
--- a/spec/chef/cookbooks/gitlab-pages/recipes/gitlab-pages_spec.rb
+++ b/spec/chef/cookbooks/gitlab-pages/recipes/gitlab-pages_spec.rb
@@ -308,17 +308,12 @@
             redirects-max-config-size=128000
             redirects-max-path-segments=50
             redirects-max-rule-count=2000
+            header=X-XSS-Protection: 1; mode=block;;X-Content-Type-Options: nosniff;;Test: Header
         EOS
 
         expect(chef_run).to render_file("/var/opt/gitlab/pages/gitlab-pages-config").with_content(expected_content)
       end
 
-      it 'specifies headers as arguments in the run file' do
-        expect(chef_run).to render_file("/opt/gitlab/sv/gitlab-pages/run").with_content(%r{-header="X-XSS-Protection: 1; mode=block"})
-        expect(chef_run).to render_file("/opt/gitlab/sv/gitlab-pages/run").with_content(%r{-header="X-Content-Type-Options: nosniff"})
-        expect(chef_run).to render_file("/opt/gitlab/sv/gitlab-pages/run").with_content(%r{-header="Test: Header"})
-      end
-
       it 'renders the env dir files' do
         expect(chef_run).to render_file("/opt/gitlab/etc/gitlab-pages/env/GITLAB_CONTINUOUS_PROFILING")
           .with_content('stackdriver?service=gitlab-pages')