Skip to content

Commit 45806cb

Browse files
committed
Normalize comment length and structure
Signed-off-by: Elijah Zupancic <[email protected]>
1 parent 0bc4425 commit 45806cb

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

common/etc/nginx/include/s3gateway.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ function _credentialsTempFile() {
160160
* @param credentials {{accessKeyId: (string), secretAccessKey: (string), sessionToken: (string), expiration: (string)}} AWS instance profile credentials
161161
*/
162162
function writeCredentials(r, credentials) {
163-
// Do not bother writing credentials if we are running in a mode where we
164-
// do not need instance credentials.
163+
/* Do not bother writing credentials if we are running in a mode where we
164+
do not need instance credentials. */
165165
if (process.env['S3_ACCESS_KEY_ID'] && process.env['S3_SECRET_KEY']) {
166166
return;
167167
}
@@ -205,7 +205,7 @@ function _writeCredentialsToFile(credentials) {
205205
* Get the instance profile credentials needed to authenticated against S3 from
206206
* a backend cache. If the credentials cannot be found, then return undefined.
207207
* @param r {Request} HTTP request object (not used, but required for NGINX configuration)
208-
* @returns {undefined|{accessKeyId: (string), secretAccessKey: (string), sessionToken: (string), expiration: (string)}} AWS instance profile credentials or undefined
208+
* @returns {undefined|{accessKeyId: (string), secretAccessKey: (string), sessionToken: (string|null), expiration: (string|null)}} AWS instance profile credentials or undefined
209209
*/
210210
function readCredentials(r) {
211211
if (process.env['S3_ACCESS_KEY_ID'] && process.env['S3_SECRET_KEY']) {
@@ -382,7 +382,8 @@ function _s3DirQueryParams(uriPath, method) {
382382
return '';
383383
}
384384

385-
// return if static website. We don't want to list the files in the directory, we want to append the index page and get the fil.
385+
/* Return if static website. We don't want to list the files in the
386+
directory, we want to append the index page and get the fil. */
386387
if (provide_index_page){
387388
return '';
388389
}
@@ -917,8 +918,8 @@ var maxValidityOffsetMs = 4.5 * 60 * 1000;
917918
* @returns {Promise<void>}
918919
*/
919920
async function fetchCredentials(r) {
920-
// If we are not using an AWS instance profile to set our credentials we
921-
// exit quickly and don't write a credentials file.
921+
/* If we are not using an AWS instance profile to set our credentials we
922+
exit quickly and don't write a credentials file. */
922923
if (process.env['S3_ACCESS_KEY_ID'] && process.env['S3_SECRET_KEY']) {
923924
r.return(200);
924925
return;
@@ -1025,9 +1026,10 @@ async function _fetchEC2RoleCredentials() {
10251026
'x-aws-ec2-metadata-token': token,
10261027
},
10271028
});
1028-
// This _might_ get multiple possible roles in other scenarios, however, EC2 supports attaching one role only.
1029-
// It should therefore be safe to take the whole output, even given IMDS _might_ (?) be able to return multiple
1030-
// roles.
1029+
/* This _might_ get multiple possible roles in other scenarios, however,
1030+
EC2 supports attaching one role only.It should therefore be safe to take
1031+
the whole output, even given IMDS _might_ (?) be able to return multiple
1032+
roles. */
10311033
var credName = await resp.text();
10321034
if (credName === "") {
10331035
throw 'No credentials available for EC2 instance';
@@ -1060,16 +1062,18 @@ async function _fetchWebIdentityCredentials(r) {
10601062

10611063
var sts_endpoint = process.env['STS_ENDPOINT'];
10621064
if (!sts_endpoint) {
1063-
// On EKS, the ServiceAccount can be annotated with 'eks.amazonaws.com/sts-regional-endpoints' to control
1064-
// the usage of regional endpoints. We are using the same standard environment variable here as
1065-
// the AWS SDK. This is with the exception of replacing the value `legacy` with `global` to match
1066-
// what EKS sets the variable to.
1067-
// https://docs.aws.amazon.com/sdkref/latest/guide/feature-sts-regionalized-endpoints.html
1068-
// https://docs.aws.amazon.com/eks/latest/userguide/configure-sts-endpoint.html
1065+
/* On EKS, the ServiceAccount can be annotated with
1066+
'eks.amazonaws.com/sts-regional-endpoints' to control
1067+
the usage of regional endpoints. We are using the same standard
1068+
environment variable here as the AWS SDK. This is with the exception
1069+
of replacing the value `legacy` with `global` to match what EKS sets
1070+
the variable to.
1071+
See: https://docs.aws.amazon.com/sdkref/latest/guide/feature-sts-regionalized-endpoints.html
1072+
See: https://docs.aws.amazon.com/eks/latest/userguide/configure-sts-endpoint.html */
10691073
var sts_regional = process.env['AWS_STS_REGIONAL_ENDPOINTS'] || 'global';
10701074
if (sts_regional === 'regional') {
1071-
// STS regional endpoints can be derived from the region's name.
1072-
// https://docs.aws.amazon.com/general/latest/gr/sts.html
1075+
/* STS regional endpoints can be derived from the region's name.
1076+
See: https://docs.aws.amazon.com/general/latest/gr/sts.html */
10731077
var region = process.env['AWS_REGION'];
10741078
if (region) {
10751079
sts_endpoint = `https://sts.${region}.amazonaws.com`;

0 commit comments

Comments
 (0)