Skip to content

Commit

Permalink
Merge pull request #22697 from agrare/add_application_domain_to_pod_e…
Browse files Browse the repository at this point in the history
…nvironment

Add APPLICATION_DOMAIN to pod environment
  • Loading branch information
bdunne authored Sep 12, 2023
2 parents 264fd67 + 2667830 commit 5912c45
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions app/models/miq_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def logon_status_details

def ui_hostname
if MiqEnvironment::Command.is_podified?
ENV.fetch("APPLICATION_DOMAIN")
ENV.fetch("APPLICATION_DOMAIN", nil)
else
hostname || ipaddress
end
Expand All @@ -422,7 +422,7 @@ def ui_ipaddress

def ui_address(contact_with = :hostname)
if MiqEnvironment::Command.is_podified?
ENV.fetch("APPLICATION_DOMAIN")
ENV.fetch("APPLICATION_DOMAIN", nil)
else
contact_with == :hostname ? ui_hostname : ui_ipaddress
end
Expand All @@ -440,7 +440,7 @@ def ui_url(contact_with = :hostname)

def ws_hostname
if MiqEnvironment::Command.is_podified?
ENV.fetch("APPLICATION_DOMAIN")
ENV.fetch("APPLICATION_DOMAIN", nil)
else
hostname || ipaddress
end
Expand All @@ -456,7 +456,7 @@ def ws_ipaddress

def ws_address
if MiqEnvironment::Command.is_podified?
ENV.fetch("APPLICATION_DOMAIN")
ENV.fetch("APPLICATION_DOMAIN", nil)
else
::Settings.webservices.contactwith == 'hostname' ? ws_hostname : ws_ipaddress
end
Expand Down
1 change: 1 addition & 0 deletions lib/container_orchestrator/object_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def default_environment
[
{:name => "GUID", :value => MiqServer.my_guid},
{:name => "HOME", :value => Rails.root.join("tmp").to_s},
{:name => "APPLICATION_DOMAIN", :value => ENV["APPLICATION_DOMAIN"]},
{:name => "MEMCACHED_SERVER", :value => ENV["MEMCACHED_SERVER"]},
{:name => "MEMCACHED_SERVICE_NAME", :value => ENV["MEMCACHED_SERVICE_NAME"]},
{:name => "WORKER_HEARTBEAT_FILE", :value => Rails.root.join("tmp", "worker.hb").to_s},
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/container_orchestrator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
expect(subject.send(:default_environment)).not_to include({:name => "DATABASE_NAME", :valueFrom => {:secretKeyRef => {:key => "dbname", :name => "postgresql-secrets"}}})
end

it "sets APPLICATION_DOMAIN" do
stub_const("ENV", ENV.to_h.merge("APPLICATION_DOMAIN" => "manageiq"))
expect(subject.send(:default_environment)).to include({:name => "APPLICATION_DOMAIN", :value => "manageiq"})
end

it "doesn't include memcached env vars by default" do
env = subject.send(:default_environment)

Expand Down
4 changes: 2 additions & 2 deletions spec/models/miq_region_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
context "podified" do
before do
expect(MiqEnvironment::Command).to receive(:is_podified?).and_return(true)
expect(ENV).to receive(:fetch).with("APPLICATION_DOMAIN").and_return("manageiq.apps.mycluster.com")
expect(ENV).to receive(:fetch).with("APPLICATION_DOMAIN", nil).and_return("manageiq.apps.mycluster.com")
end

it "returns the applicationDomain from the CR" do
Expand Down Expand Up @@ -178,7 +178,7 @@
context "podified" do
before do
expect(MiqEnvironment::Command).to receive(:is_podified?).and_return(true)
expect(ENV).to receive(:fetch).with("APPLICATION_DOMAIN").and_return("manageiq.apps.mycluster.com")
expect(ENV).to receive(:fetch).with("APPLICATION_DOMAIN", nil).and_return("manageiq.apps.mycluster.com")
end

it "returns the applicationDomain from the CR" do
Expand Down

0 comments on commit 5912c45

Please sign in to comment.