Skip to content

Commit

Permalink
refactor: no longer accept envs prefixed with report_portal
Browse files Browse the repository at this point in the history
  • Loading branch information
alexo committed Dec 21, 2023
1 parent 85b3da6 commit bc45255
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ read_timeout: 60
It will search for the following environment variables which may be in upper or lowercase (the official client defers to lower case, this is available here for compatibility).
- `REPORT_PORTAL_API_KEY` - the API Key for this Report Portal instance which must be created in advance
- `RP_API_KEY` - the API Key for this Report Portal instance which must be created in advance
- `RP_ENDPOINT` - the endpoint for this Report Portal instance
- `RP_PROJECT` - the Report Portal project name which must be created in advance and this user added as a member
- `RP_LAUNCH` - the name of this 'launch'
Expand Down
6 changes: 2 additions & 4 deletions lib/parallel_report_portal/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module ParallelReportPortal
#
# == Environment variables
#
# REPORT_PORTAL_API_KEY:: The API key required for authentication
# RP_API_KEY:: The API key required for authentication
# RP_ENDPOINT:: the URL of the Report Portal API endpoint
# RP_PROJECT:: the Report Portal project name -- this must already exist within Report Port and this user must be a member of the project
# RP_LAUNCH:: The name of this launch
Expand Down Expand Up @@ -61,7 +61,7 @@ class Configuration
def initialize
load_configuration_file
ATTRIBUTES.each do |attr|
env_value = get_env("rp_#{attr.to_s}") || get_env("report_portal_#{attr.to_s}")
env_value = get_env("rp_#{attr.to_s}")
send(:"#{attr}=", env_value) if env_value
end

Expand Down Expand Up @@ -153,8 +153,6 @@ def load_configuration_file
ATTRIBUTES.each do |attr|
yaml_key = if yaml.has_key?("rp_#{attr}".to_sym)
"rp_#{attr}".to_sym
elsif yaml.has_key?("report_portal_#{attr}".to_sym)
"report_portal_#{attr}".to_sym
else
attr
end
Expand Down
12 changes: 6 additions & 6 deletions spec/parallel_report_portal/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
expect(Dir).to receive(:[]).with('./config/*').and_return([])
expect(Dir).to receive(:[]).with('./*').and_return(['./report_portal.yml'])
expect(File).to receive(:read).with('./report_portal.yml').and_return(<<~CONFIG)
report_portal_api_key: 0a14044a-65fb-4981-b4b0-e699f99b4e59
rp_api_key: 0a14044a-65fb-4981-b4b0-e699f99b4e59
rp_endpoint: https://url.local:10000/a/path
rp_project: rp_project
rp_launch: rp_launch_name
Expand All @@ -163,7 +163,7 @@
expect(Dir).to receive(:[]).with('./config/*').and_return([])
expect(Dir).to receive(:[]).with('./*').and_return(['./report_portal.yml'])
expect(File).to receive(:read).with('./report_portal.yml').and_return(<<~CONFIG)
REPORT_PORTAL_API_KEY: 0a14044a-65fb-4981-b4b0-e699f99b4e59
RP_API_KEY: 0a14044a-65fb-4981-b4b0-e699f99b4e59
RP_ENDPOINT: https://url.local:10000/a/path
RP_PROJECT: rp_project
RP_LAUNCH: rp_launch_name
Expand Down Expand Up @@ -220,14 +220,14 @@
expect(config.project).to eq(project)
end

it 'accepts REPORT_PORTAL_API_KEY' do
api_key = ENV['REPORT_PORTAL_API_KEY'] = '0a14044a-65fb-4981-b4b0-e699f99b4e59'
it 'accepts RP_API_KEY' do
api_key = ENV['RP_API_KEY'] = '0a14044a-65fb-4981-b4b0-e699f99b4e59'
config = ParallelReportPortal::Configuration.new
expect(config.api_key).to eq(api_key)
end

it 'accepts report_portal_api_key' do
api_key = ENV['report_portal_api_key'] = '0a14044a-65fb-4981-b4b0-e699f99b4e59'
it 'accepts rp_api_key' do
api_key = ENV['rp_api_key'] = '0a14044a-65fb-4981-b4b0-e699f99b4e59'
config = ParallelReportPortal::Configuration.new
expect(config.api_key).to eq(api_key)
end
Expand Down

0 comments on commit bc45255

Please sign in to comment.