Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: improve formatting of string concatenation #62

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nimutils/awsclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ proc newAwsClient*(creds: AwsCredentials, region,
let
# TODO - use some kind of template and compile-time variable to put the correct kernel used to build the sdk in the UA?
httpclient = createHttpClient(
userAgent = "nimaws-sdk/0.3.3; "&defUserAgent.replace(" ", "-").toLower&"; darwin/16.7.0",
userAgent = "nimaws-sdk/0.3.3; " & defUserAgent.replace(" ", "-").toLower() & "; darwin/16.7.0",
)
scope = AwsScope(date: getAmzDateString(), region: region, service: service)

Expand Down
8 changes: 5 additions & 3 deletions nimutils/s3client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ proc newS3Client*(creds: AwsCredentials, region: string = defaultRegion,
host: string = awsURI, timeoutMilliseconds = 1000): S3Client =
let
# TODO - use some kind of template and compile-time variable to put the correct kernel used to build the sdk in the UA?
httpclient = newHttpClient("nimaws-sdk/0.3.3; "&defUserAgent.replace(" ",
"-").toLower&"; darwin/16.7.0", timeout = timeoutMilliseconds)
httpclient = newHttpClient(
"nimaws-sdk/0.3.3; " & defUserAgent.replace(" ", "-").toLower() & "; darwin/16.7.0",
timeout = timeoutMilliseconds,
)
scope = AwsScope(date: getAmzDateString(), region: region, service: "s3")

var
Expand All @@ -40,7 +42,7 @@ proc newS3Client*(creds: AwsCredentials, region: string = defaultRegion,
if mhost.len > 0:
if mhost.find("http") == -1:
echo "host should be a valid URI assuming http://"
mhost = "http://"&host
mhost = "http://" & host
else:
mhost = awsURI
endpoint = parseUri(mhost)
Expand Down
6 changes: 3 additions & 3 deletions nimutils/sigv4.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const

# Some convenience operators, for fun and aesthetics
proc `$`(s: AwsScope): string =
return s.date[0..7]&"/"&s.region&"/"&s.service
return s.date[0..7] & "/" & s.region & "/" & s.service

proc `!$`(s: string): string =
return sha256Hex(s)
Expand Down Expand Up @@ -153,8 +153,8 @@ proc create_signature*(key: string, sts: string): string =
proc create_signing_key*(secret: string, scope: AwsScope,
termination: string = term): string =
# (a ?$ b) => $hmac_sha256(a,b)
return ("AWS4"&secret) ?$ scope.date[0..7] ?$ scope.region ?$ scope.service ?$ termination
# ? cleaner than $hmac_sha256($hmac_sha256($hmac_sha256($hmac_sha256("AWS4"&secret, date[0..7]),region),service),termination) ?
return ("AWS4" & secret) ?$ scope.date[0..7] ?$ scope.region ?$ scope.service ?$ termination
# ? cleaner than $hmac_sha256($hmac_sha256($hmac_sha256($hmac_sha256("AWS4" & secret, date[0..7]),region),service),termination) ?

proc create_authorization_header*(id: string, scope: AwsScope,
signed_head: string, sig: string, opts: (string, string) = (alg,
Expand Down
8 changes: 5 additions & 3 deletions nimutils/stsclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ proc newStsClient*(creds: AwsCredentials,
timeoutMilliseconds = 1000): StsClient =
let
# TODO - use some kind of template and compile-time variable to put the correct kernel used to build the sdk in the UA?
httpclient = newHttpClient("nimaws-sdk/0.3.3; "&defUserAgent.replace(" ", "-").toLower&"; darwin/16.7.0",
timeout = timeoutMilliseconds)
httpclient = newHttpClient(
"nimaws-sdk/0.3.3; " & defUserAgent.replace(" ", "-").toLower() & "; darwin/16.7.0",
timeout = timeoutMilliseconds,
)
scope = AwsScope(date: getAmzDateString(), region: region, service: "sts")

var
Expand All @@ -25,7 +27,7 @@ proc newStsClient*(creds: AwsCredentials,
if mhost.len > 0:
if mhost.find("http") == -1:
echo "host should be a valid URI assuming http://"
mhost = "http://"&host
mhost = "http://" & host
else:
mhost = awsURI
endpoint = parseUri(mhost)
Expand Down