Skip to content

Commit

Permalink
rename ReadAWSWebIdentityTokenFile to ReadAWSTokenFile
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseanttila-cai committed May 8, 2024
1 parent f70f7e6 commit 622ac6a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions port/cpl_aws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,24 +664,22 @@ static EC2InstanceCertainty IsMachinePotentiallyEC2Instance()
}

/************************************************************************/
/* ReadAWSWebIdentityTokenFile() */
/* ReadAWSTokenFile() */
/************************************************************************/

static bool
ReadAWSWebIdentityTokenFile(const std::string &osWebIdentityTokenFile,
std::string &webIdentityToken)
static bool ReadAWSTokenFile(const std::string &osAWSTokenFile,
std::string &awsToken)
{
GByte *pabyOut = nullptr;
if (!VSIIngestFile(nullptr, osWebIdentityTokenFile.c_str(), &pabyOut,
nullptr, -1))
if (!VSIIngestFile(nullptr, osAWSTokenFile.c_str(), &pabyOut, nullptr, -1))
return false;

webIdentityToken = reinterpret_cast<char *>(pabyOut);
awsToken = reinterpret_cast<char *>(pabyOut);
VSIFree(pabyOut);
// Remove trailing end-of-line character
if (!webIdentityToken.empty() && webIdentityToken.back() == '\n')
webIdentityToken.resize(webIdentityToken.size() - 1);
return !webIdentityToken.empty();
if (!awsToken.empty() && awsToken.back() == '\n')
awsToken.resize(awsToken.size() - 1);
return !awsToken.empty();
}

/************************************************************************/
Expand Down Expand Up @@ -753,7 +751,7 @@ bool VSIS3HandleHelper::GetConfigurationFromAssumeRoleWithWebIdentity(

// Get token from web identity token file
std::string webIdentityToken;
if (!ReadAWSWebIdentityTokenFile(webIdentityTokenFile, webIdentityToken))
if (!ReadAWSTokenFile(webIdentityTokenFile, webIdentityToken))
{
CPLDebug("AWS", "%s is empty", webIdentityTokenFile.c_str());
return false;
Expand Down Expand Up @@ -879,7 +877,7 @@ bool VSIS3HandleHelper::GetConfigurationFromEC2(
std::string osECSToken;
if (!osECSTokenFile.empty())
{
if (!ReadAWSWebIdentityTokenFile(osECSTokenFile, osECSToken))
if (!ReadAWSTokenFile(osECSTokenFile, osECSToken))
{
CPLDebug("AWS", "%s is empty", osECSTokenFile.c_str());
}
Expand Down

0 comments on commit 622ac6a

Please sign in to comment.