Sha256: 4a362313be40b22dc2b3d7ef567ff7e8eee391b549268e87caf4a3e569e65bad

Contents?: true

Size: 1.62 KB

Versions: 16

Compression:

Stored size: 1.62 KB

Contents

#include <internal/facts/resolvers/augeas_resolver.hpp>
#include <internal/util/agent.hpp>
#include <facter/facts/collection.hpp>
#include <facter/facts/fact.hpp>
#include <facter/facts/scalar_value.hpp>
#include <facter/facts/map_value.hpp>
#include <leatherman/execution/execution.hpp>
#include <leatherman/logging/logging.hpp>
#include <leatherman/util/regex.hpp>

using namespace std;
using namespace facter::util;
using namespace leatherman::util;
using namespace leatherman::execution;

namespace facter { namespace facts { namespace resolvers {

    augeas_resolver::augeas_resolver() :
        resolver(
            "augeas",
            {
                fact::augeas,
                fact::augeasversion,
            })
    {
    }

    string augeas_resolver::get_version()
    {
        string augparse = agent::which("augparse");
        string value;
        boost::regex regexp("^augparse (\\d+\\.\\d+\\.\\d+)");
        // Version info goes on stderr.
        each_line(augparse, {"--version"}, nullptr, [&](string& line) {
            if (re_search(line, regexp, &value)) {
                return false;
            }
            return true;
        });
        return value;
    }

    void augeas_resolver::resolve(collection& facts)
    {
        auto version = get_version();
        if (version.empty()) {
            return;
        }

        auto augeas = make_value<map_value>();
        augeas->add("version", make_value<string_value>(version));
        facts.add(fact::augeasversion, make_value<string_value>(move(version), true));
        facts.add(fact::augeas, move(augeas));
    }

}}}  // namespace facter::facts::resolvers

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/src/facts/resolvers/augeas_resolver.cc