Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/stable'
- Loading branch information
Showing
9 changed files
with
112 additions
and
47 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @file | ||
* Declares the Linux kernel fact resolver. | ||
*/ | ||
#pragma once | ||
|
||
#include "../posix/kernel_resolver.hpp" | ||
|
||
namespace facter { namespace facts { namespace linux { | ||
|
||
/** | ||
* Responsible for resolving kernel facts. | ||
*/ | ||
struct kernel_resolver : posix::kernel_resolver | ||
{ | ||
protected: | ||
/** | ||
* Parses the major and minor kernel versions. | ||
* @param version The version to parse. | ||
* @return Returns a tuple of major and minor versions. | ||
*/ | ||
std::tuple<std::string, std::string> parse_version(std::string const& version) const override; | ||
}; | ||
|
||
}}} // namespace facter::facts::linux |
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,20 @@ | ||
#include <internal/facts/linux/kernel_resolver.hpp> | ||
#include <internal/util/regex.hpp> | ||
#include <boost/regex.hpp> | ||
#include <tuple> | ||
|
||
using namespace std; | ||
using namespace facter::util; | ||
|
||
namespace facter { namespace facts { namespace linux { | ||
|
||
tuple<string, string> kernel_resolver::parse_version(string const& version) const | ||
{ | ||
string major, minor; | ||
if (re_search(version, boost::regex("(\\d+\\.\\d+)(.*)"), &major, &minor)) { | ||
return make_tuple(major, minor); | ||
} | ||
return make_tuple(move(version), string()); | ||
} | ||
|
||
}}} // namespace facter::facts::resolvers |