Sha256: b7986ab32a031699ef7d1bd8a5fa8426285c595a3195f6185d47ffbb1734c81f

Contents?: true

Size: 1.35 KB

Versions: 14

Compression:

Stored size: 1.35 KB

Contents

#include <facter/cwrapper.hpp>

#include <facter/facts/collection.hpp>
#include <facter/util/config.hpp>

#include <stdlib.h>
#include <stdio.h>
#include <sstream>

uint8_t get_default_facts(char **result) {
    try {
        // NB: ssh resolver cannot be blocked
        facter::facts::collection facts {{},      // blocklist set
                                         {},      // ttls map (resolvers - ttl)
                                         true};   // ignore_cache flag

        // The boolean arg is meant to avoid including ruby facts
        facts.add_default_facts(false);

        // NB: skipping the add_environment_facts() call

        // TODO: consider iterating only the facts we're interested
        // in by using the 'queries' arg
        std::ostringstream stream;
        facts.write(stream,
                    facter::facts::format::json,
                    {},     // queries vector
                    true,   // show_legacy flag
                    true);  // strict_errors flag

        auto json_facts = stream.str();
        auto l = json_facts.length()+1;

        *result = static_cast<char*>(malloc(sizeof(char)*l));
        if (*result == nullptr) {
            return EXIT_FAILURE;
        }

        strncpy(*result, json_facts.c_str(), l);
    } catch (const std::exception&) {
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

Version data entries

14 entries across 14 versions & 2 rubygems

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