Sha256: 47d82c6c4ec20ae90f4cd2d9239a6a5eaafc49b7557b91c39f19aaa5b4b82758

Contents?: true

Size: 1.54 KB

Versions: 16

Compression:

Stored size: 1.54 KB

Contents

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

using namespace std;

namespace facter { namespace facts { namespace resolvers {

    identity_resolver::identity_resolver() :
        resolver(
            "id",
            {
                fact::id,
                fact::gid,
                fact::identity
            })
    {
    }

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

        auto identity = make_value<map_value>();
        if (!data.user_name.empty()) {
            facts.add(fact::id, make_value<string_value>(data.user_name, true));
            identity->add("user", make_value<string_value>(move(data.user_name)));
        }
        if (data.user_id) {
            identity->add("uid", make_value<integer_value>(*data.user_id));
        }
        if (!data.group_name.empty()) {
            facts.add(fact::gid, make_value<string_value>(data.group_name, true));
            identity->add("group", make_value<string_value>(move(data.group_name)));
        }
        if (data.group_id) {
            identity->add("gid", make_value<integer_value>(*data.group_id));
        }
        if (data.privileged) {
            identity->add("privileged", make_value<boolean_value>(*data.privileged));
        }

        if (!identity->empty()) {
            facts.add(fact::identity, move(identity));
        }
    }

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