Skip to content

Commit

Permalink
Allow unsetting the host name env
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Oct 23, 2024
1 parent 65f5547 commit 52a209e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/clean-apes-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openproject/helm-charts": minor
---

Allow unsetting the host name env
2 changes: 1 addition & 1 deletion charts/openproject/templates/secret_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ stringData:
OPENPROJECT_SEED_LOCALE: {{ .Values.openproject.seed_locale | quote }}
{{- if .Values.ingress.enabled }}
OPENPROJECT_HOST__NAME: {{ .Values.openproject.host | default .Values.ingress.host | quote }}
{{- else if .Values.openproject.host }}
{{- else if not .Values.openproject.prevent_host_output -}}
OPENPROJECT_HOST__NAME: {{ .Values.openproject.host | quote }}
{{- end }}
OPENPROJECT_HSTS: {{ .Values.openproject.hsts | quote }}
Expand Down
5 changes: 5 additions & 0 deletions charts/openproject/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ openproject:
#
host:

## In most cases, you want to output OPENPROJECT_HOST__NAME
# to get additional host level protections from the application.
# If you need to support multiple hosts or dynamic hosts, enable this
prevent_host_output: false

## Enable HSTS.
#
hsts: true
Expand Down
49 changes: 49 additions & 0 deletions spec/charts/openproject/host_name_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true
require 'spec_helper'

describe 'host name configuration' do
let(:template) { HelmTemplate.new(default_values) }

subject { template.dig('Secret/optest-openproject-core', 'stringData') }

context 'when setting host' do
let(:default_values) do
HelmTemplate.with_defaults(<<~YAML
openproject:
host: bla.example.com
YAML
)
end

it 'adds a respective ENV', :aggregate_failures do
expect(subject)
.to include("OPENPROJECT_HOST__NAME" => "bla.example.com")
end
end

context 'when setting no host name' do
let(:default_values) do
HelmTemplate.with_defaults({})
end

it 'the host name is the default', :aggregate_failures do
expect(subject)
.to include("OPENPROJECT_HOST__NAME" => "openproject.example.com")
end
end

context 'when setting no host name and disabling it' do
let(:default_values) do
HelmTemplate.with_defaults(<<~YAML
openproject:
prevent_host_output: true
YAML
)
end

it 'the host is not output', :aggregate_failures do
expect(subject.keys)
.not_to include("OPENPROJECT_HOST__NAME")
end
end
end

0 comments on commit 52a209e

Please sign in to comment.