-
Notifications
You must be signed in to change notification settings - Fork 567
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 #207 from rtyler/issues/206-firewall-port-refactor
Introduce the jenkins_port function
- Loading branch information
Showing
8 changed files
with
59 additions
and
27 deletions.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
module Puppet::Parser::Functions | ||
newfunction(:jenkins_port, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| | ||
Return the configurad Jenkins port value | ||
(corresponds to /etc/defaults/jenkins -> JENKINS_PORT | ||
Example: | ||
$port = jenkins_port() | ||
ENDHEREDOC | ||
|
||
config_hash = lookupvar('::jenkins::config_hash') | ||
if config_hash && \ | ||
config_hash['HTTP_PORT'] && \ | ||
config_hash['HTTP_PORT']['value'] | ||
return config_hash['HTTP_PORT']['value'] | ||
else | ||
return lookupvar('::jenkins::params::port') | ||
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
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
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 |
---|---|---|
|
@@ -8,5 +8,4 @@ | |
context 'firewall' do | ||
it { should contain_firewall('500 allow Jenkins inbound traffic') } | ||
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,30 @@ | ||
require 'spec_helper' | ||
|
||
describe 'jenkins_port' do | ||
let(:facts) { { :osfamily => 'RedHat', :operatingsystem => 'RedHat' } } | ||
let(:pre_condition) { 'include ::jenkins' } | ||
# Lazily loaded function call to be used in examples. Not overwriting | ||
# `subject` since rspec-puppet is already defining that to return the | ||
# function | ||
let(:port) { | ||
subject.call([]) | ||
} | ||
|
||
it 'should default to 8080' do | ||
expect(port).to eql '8080' | ||
end | ||
|
||
context 'with overwritten configuration' do | ||
let(:pre_condition) do | ||
<<-ENDPUPPET | ||
class { 'jenkins': | ||
config_hash => {'HTTP_PORT' => {'value' => '1337'}}, | ||
} | ||
ENDPUPPET | ||
end | ||
|
||
it 'should be our overwritten port' do | ||
expect(port).to eql('1337') | ||
end | ||
end | ||
end |