Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ENV variables for urls #936

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/foreman_rh_cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@
require 'uri'

module ForemanRhCloud
def self.on_premise_url
return unless ForemanRhCloud.with_local_advisor_engine?
port = ENV['ADVISOR_ENGINE_PORT'] || "8000"
ENV['ADVISOR_ENGINE_URL'] || "http://#{ForemanRhCloud.foreman_host.fqdn || 'localhost'}:#{port}"
jeremylenz marked this conversation as resolved.
Show resolved Hide resolved
end

def self.env_or_on_premise_url(env_var_name)
ENV[env_var_name] || on_premise_url
end

def self.base_url
# for testing set ENV to 'https://ci.cloud.redhat.com'
@base_url ||= ENV['SATELLITE_RH_CLOUD_URL'] || 'https://cloud.redhat.com'
@base_url ||= env_or_on_premise_url('SATELLITE_RH_CLOUD_URL') || 'https://cloud.redhat.com'
end

def self.cert_base_url
@cert_base_url ||= ENV['SATELLITE_CERT_RH_CLOUD_URL'] || 'https://cert.cloud.redhat.com'
@cert_base_url ||= env_or_on_premise_url('SATELLITE_CERT_RH_CLOUD_URL') || 'https://cert.cloud.redhat.com'
end

def self.legacy_insights_url
@legacy_insights_url ||= ENV['SATELLITE_LEGACY_INSIGHTS_URL'] || 'https://cert-api.access.redhat.com'
@legacy_insights_url ||= env_or_on_premise_url('SATELLITE_LEGACY_INSIGHTS_URL') || 'https://cert-api.access.redhat.com'
jeremylenz marked this conversation as resolved.
Show resolved Hide resolved
end

def self.verify_ssl_method
Expand Down
Loading