-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Consul Version Fact #209
Merged
Merged
Consul Version Fact #209
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
533f590
Merge pull request #2 from solarkennedy/master
robrankin 9ddb175
Adding Consul Version Puppet fact
robrankin d2dcb9d
Fixing PS Windows Fact
robrankin bfd9b77
Rewrite as ruby
robrankin ee01560
Test for consul_version fact
robrankin d578f59
Test without consul installed on linux
robrankin 6f189af
Add Windows test
robrankin e5c9746
Merge pull request #3 from solarkennedy/master
robrankin ae3bdd9
Remove Windows support from fact for now
robrankin b01d49e
Merge pull request #4 from solarkennedy/master
robrankin f848024
Specify value to test
robrankin acb20f8
Quiet any error output for nodes that dont have Consul installed
robrankin dfbcf8f
Corecting the test would be a good idea as well
robrankin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,10 @@ | ||
# consul_version.rb | ||
|
||
Facter.add(:consul_version) do | ||
confine :kernel => 'Linux' | ||
setcode do | ||
version = Facter::Util::Resolution.exec('consul --version 2> /dev/null') | ||
version = version.lines.first.split[1].tr('v','') | ||
version | ||
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,24 @@ | ||
require "spec_helper" | ||
|
||
describe Facter::Util::Fact do | ||
before { | ||
Facter.clear | ||
} | ||
|
||
describe "consul_version" do | ||
|
||
context 'Returns consul version on Linux' | ||
it do | ||
consul_version_output = <<-EOS | ||
Consul v0.6.0 | ||
Consul Protocol: 3 (Understands back to: 1) | ||
EOS | ||
allow(Facter.fact(:kernel)).to receive(:value).and_return("Linux") | ||
allow(Facter::Util::Resolution).to receive(:exec).with('consul --version 2> /dev/null'). | ||
and_return(consul_version_output) | ||
expect(Facter.fact(:consul_version).value).to match('0.6.0') | ||
end | ||
|
||
end | ||
|
||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty for using confine