forked from lix-project/lix
Style
This commit is contained in:
parent
274357eb6a
commit
20a1e20d91
|
@ -140,15 +140,16 @@ struct GitArchiveInputScheme : InputScheme
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getAccessToken(const std::string &host) const {
|
std::optional<std::string> getAccessToken(const std::string & host) const
|
||||||
|
{
|
||||||
auto tokens = settings.accessTokens.get();
|
auto tokens = settings.accessTokens.get();
|
||||||
auto pat = tokens.find(host);
|
if (auto token = get(tokens, host))
|
||||||
if (pat == tokens.end())
|
return *token;
|
||||||
return std::nullopt;
|
return {};
|
||||||
return pat->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Headers makeHeadersWithAuthTokens(const std::string & host) const {
|
Headers makeHeadersWithAuthTokens(const std::string & host) const
|
||||||
|
{
|
||||||
Headers headers;
|
Headers headers;
|
||||||
auto accessToken = getAccessToken(host);
|
auto accessToken = getAccessToken(host);
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
|
@ -214,7 +215,8 @@ struct GitHubInputScheme : GitArchiveInputScheme
|
||||||
{
|
{
|
||||||
std::string type() override { return "github"; }
|
std::string type() override { return "github"; }
|
||||||
|
|
||||||
std::optional<std::pair<std::string, std::string> > accessHeaderFromToken(const std::string & token) const {
|
std::optional<std::pair<std::string, std::string> > accessHeaderFromToken(const std::string & token) const
|
||||||
|
{
|
||||||
// Github supports PAT/OAuth2 tokens and HTTP Basic
|
// Github supports PAT/OAuth2 tokens and HTTP Basic
|
||||||
// Authentication. The former simply specifies the token, the
|
// Authentication. The former simply specifies the token, the
|
||||||
// latter can use the token as the password. Only the first
|
// latter can use the token as the password. Only the first
|
||||||
|
@ -268,7 +270,8 @@ struct GitLabInputScheme : GitArchiveInputScheme
|
||||||
{
|
{
|
||||||
std::string type() override { return "gitlab"; }
|
std::string type() override { return "gitlab"; }
|
||||||
|
|
||||||
std::optional<std::pair<std::string, std::string> > accessHeaderFromToken(const std::string & token) const {
|
std::optional<std::pair<std::string, std::string> > accessHeaderFromToken(const std::string & token) const
|
||||||
|
{
|
||||||
// Gitlab supports 4 kinds of authorization, two of which are
|
// Gitlab supports 4 kinds of authorization, two of which are
|
||||||
// relevant here: OAuth2 and PAT (Private Access Token). The
|
// relevant here: OAuth2 and PAT (Private Access Token). The
|
||||||
// user can indicate which token is used by specifying the
|
// user can indicate which token is used by specifying the
|
||||||
|
|
|
@ -893,10 +893,10 @@ public:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
input.foo = {
|
input.foo = {
|
||||||
type="gitlab";
|
type = "gitlab";
|
||||||
host="gitlab.mycompany.com";
|
host = "gitlab.mycompany.com";
|
||||||
owner="mycompany";
|
owner = "mycompany";
|
||||||
repo="pro";
|
repo = "pro";
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue