aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/core/credentials/yql_credentials.cpp
blob: e0099bea64c5599b3fe75e2881811bb68a90403e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "yql_credentials.h"

namespace NYql {

void TCredentials::AddCredential(const TString& alias, const TCredential& cred) {
    CredentialTable_.emplace(alias, cred);
}

const TCredential* TCredentials::FindCredential(const TStringBuf& name) const {
    return CredentialTable_.FindPtr(name);
}

TString TCredentials::FindCredentialContent(const TStringBuf& name1, const TStringBuf& name2, const TString& defaultContent) const {
    if (auto cred = FindCredential(name1)) {
        return cred->Content;
    }

    if (auto cred = FindCredential(name2)) {
        return cred->Content;
    }

    return defaultContent;
}

void TCredentials::ForEach(const std::function<void(const TString, const TCredential&)>& callback) const {
    for (const auto& x : CredentialTable_) {
        callback(x.first, x.second);
    }
}

} // namespace NYql