Sha256: a5c9192153e87534972ada1f728e3a7279644af0d43f26ba83c97101d509dc01

Contents?: true

Size: 1.83 KB

Versions: 16

Compression:

Stored size: 1.83 KB

Contents

#include <internal/facts/resolvers/ldom_resolver.hpp>
#include <facter/facts/collection.hpp>
#include <facter/facts/fact.hpp>
#include <facter/facts/scalar_value.hpp>
#include <facter/facts/map_value.hpp>

using namespace std;
using namespace facter::facts;

namespace facter { namespace facts { namespace resolvers {

    ldom_resolver::ldom_resolver() :
        resolver(
            "ldom",
            {
                fact::ldom,
            },
            {
                string("^ldom_"),
            })

    {
    }

    void ldom_resolver::resolve(collection& facts)
    {
        auto data = collect_data(facts);

        if (!data.ldom.empty()) {
            auto ldom = make_value<map_value>();

            for (auto& sub_key : data.ldom) {
                if (sub_key.values.size() == 0) {
                    continue;

                } else if (sub_key.values.size() == 1) {
                    string key = sub_key.values.begin()->first;
                    string value = sub_key.values.begin()->second;

                    ldom->add(key, make_value<string_value>(value));
                    facts.add("ldom_" + key, make_value<string_value>(move(value), true));

                } else {
                    // If we have multiple sub key values, insert a map into the structured fact to contain them.
                    auto sub_value = make_value<map_value>();

                    for (auto& kv : sub_key.values) {
                        sub_value->add(kv.first, make_value<string_value>(kv.second));
                        facts.add("ldom_" + sub_key.key + "_" + move(kv.first), make_value<string_value>(move(kv.second), true));
                    }

                    ldom->add(sub_key.key, move(sub_value));
                }
            }

            facts.add(fact::ldom, move(ldom));
        }
    }

}}}  // namespace facter::facts

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/ldom_resolver.cc
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/src/facts/resolvers/ldom_resolver.cc