aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-09-30 12:11:22 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-09-30 13:35:56 +0200
commit20a1e20d9194527d725898c745d1243d3de16277 (patch)
treec2c7ef47bf1f47edf1d6cfcc437de6263cbe3838 /src
parent274357eb6acd9a0812872f32dd487354d51f0f13 (diff)
Style
Diffstat (limited to 'src')
-rw-r--r--src/libfetchers/github.cc19
-rw-r--r--src/libstore/globals.hh8
2 files changed, 15 insertions, 12 deletions
diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc
index 42eb346a5..8610fe447 100644
--- a/src/libfetchers/github.cc
+++ b/src/libfetchers/github.cc
@@ -140,15 +140,16 @@ struct GitArchiveInputScheme : InputScheme
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 pat = tokens.find(host);
- if (pat == tokens.end())
- return std::nullopt;
- return pat->second;
+ if (auto token = get(tokens, host))
+ return *token;
+ return {};
}
- Headers makeHeadersWithAuthTokens(const std::string & host) const {
+ Headers makeHeadersWithAuthTokens(const std::string & host) const
+ {
Headers headers;
auto accessToken = getAccessToken(host);
if (accessToken) {
@@ -214,7 +215,8 @@ struct GitHubInputScheme : GitArchiveInputScheme
{
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
// Authentication. The former simply specifies the token, the
// 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::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
// relevant here: OAuth2 and PAT (Private Access Token). The
// user can indicate which token is used by specifying the
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index 0f0c0fe6f..8c63c5b34 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -893,10 +893,10 @@ public:
```nix
input.foo = {
- type="gitlab";
- host="gitlab.mycompany.com";
- owner="mycompany";
- repo="pro";
+ type = "gitlab";
+ host = "gitlab.mycompany.com";
+ owner = "mycompany";
+ repo = "pro";
};
```