-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from psu-stewardship/ETDA-1282
etda hostname construction for workflow or explore
- Loading branch information
Showing
5 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
|
||
.idea | ||
# rspec failure tracking | ||
.rspec_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
module EtdaUtilities | ||
class Hosts | ||
def workflow_submit_host(partner, environment = 'prod') | ||
host_builder(partner, environment, true) | ||
end | ||
|
||
def explore_host(partner, environment = 'prod') | ||
host_builder(partner, environment, false) | ||
end | ||
|
||
private | ||
|
||
def host_builder(partner, environment, is_workflow) | ||
return nil if partner.nil? | ||
return 'localhost' if environment == 'development' | ||
location_environment = "#{host_application(is_workflow)}-#{environment}" if environment != 'prod' | ||
"#{host_prefix(is_workflow)}#{partner_host(partner)}#{location_environment}.libraries.psu.edu" | ||
end | ||
|
||
def host_prefix(is_workflow = false) | ||
return '' unless is_workflow | ||
'submit-' | ||
end | ||
|
||
def host_application(is_workflow = false) | ||
return '' if is_workflow | ||
'-explore' | ||
end | ||
|
||
def partner_host(partner) | ||
case partner | ||
when 'graduate' | ||
"etda" | ||
when 'honors' | ||
"honors" | ||
when 'milsch' | ||
"millennium-scholars" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe EtdaUtilities::Hosts, type: :model do | ||
describe 'Hosts' do | ||
describe '#workflow_submit_host' do | ||
it 'returns the correct production host for workflow graduate' do | ||
expect(subject.workflow_submit_host('graduate')).to eq('submit-etda.libraries.psu.edu') | ||
end | ||
it 'returns the correct production host for workflow honors' do | ||
expect(subject.workflow_submit_host('honors')).to eq('submit-honors.libraries.psu.edu') | ||
end | ||
it 'returns the correct production host for workflow millennium scholars' do | ||
expect(subject.workflow_submit_host('milsch')).to eq('submit-millennium-scholars.libraries.psu.edu') | ||
end | ||
it 'returns the correct QA host for workflow graduate' do | ||
expect(subject.workflow_submit_host('graduate', 'qa')).to eq('submit-etda-qa.libraries.psu.edu') | ||
end | ||
it 'returns the correct QA host for workflow honors' do | ||
expect(subject.workflow_submit_host('honors', 'qa')).to eq('submit-honors-qa.libraries.psu.edu') | ||
end | ||
it 'returns the correct QA host for workflow millennium scholars' do | ||
expect(subject.workflow_submit_host('milsch', 'qa')).to eq('submit-millennium-scholars-qa.libraries.psu.edu') | ||
end | ||
it 'returns the correct host for workflow if environment is development' do | ||
expect(subject.workflow_submit_host('graduate', 'development')).to eq('localhost') | ||
end | ||
end | ||
|
||
describe '#explore_host' do | ||
it 'returns the correct production host for explore graduate' do | ||
expect(subject.explore_host('graduate')).to eq('etda.libraries.psu.edu') | ||
end | ||
it 'returns the correct production host for explore honors' do | ||
expect(subject.explore_host('honors')).to eq('honors.libraries.psu.edu') | ||
end | ||
it 'returns the correct production host for explore millennium scholars' do | ||
expect(subject.explore_host('milsch')).to eq('millennium-scholars.libraries.psu.edu') | ||
end | ||
it 'returns the correct QA host for explore graduate' do | ||
expect(subject.explore_host('graduate', 'qa')).to eq('etda-explore-qa.libraries.psu.edu') | ||
end | ||
it 'returns the correct QA host for explore honors' do | ||
expect(subject.explore_host('honors', 'qa')).to eq('honors-explore-qa.libraries.psu.edu') | ||
end | ||
it 'returns the correct QA host for explore millennium scholars' do | ||
expect(subject.explore_host('milsch', 'qa')).to eq('millennium-scholars-explore-qa.libraries.psu.edu') | ||
end | ||
it 'returns the correct host for explore if environment is development' do | ||
expect(subject.explore_host('graduate', 'development')).to eq('localhost') | ||
end | ||
end | ||
end | ||
end |