Style fix.

This commit is contained in:
Vladimir Chebotarev 2021-04-02 17:31:13 +03:00
parent f85e521e47
commit 71621eb676

View File

@ -119,9 +119,7 @@ public:
AWSEC2MetadataClient& operator =(const AWSEC2MetadataClient && rhs) = delete; AWSEC2MetadataClient& operator =(const AWSEC2MetadataClient && rhs) = delete;
AWSEC2MetadataClient(const AWSEC2MetadataClient && rhs) = delete; AWSEC2MetadataClient(const AWSEC2MetadataClient && rhs) = delete;
virtual ~AWSEC2MetadataClient() override virtual ~AWSEC2MetadataClient() override = default;
{
}
using Aws::Internal::AWSHttpResourceClient::GetResource; using Aws::Internal::AWSHttpResourceClient::GetResource;
@ -130,7 +128,7 @@ public:
return GetResource(endpoint.c_str(), resource_path, nullptr/*authToken*/); return GetResource(endpoint.c_str(), resource_path, nullptr/*authToken*/);
} }
virtual Aws::String GetDefaultCredentials() const virtual Aws::String getDefaultCredentials() const
{ {
String credentials_string; String credentials_string;
{ {
@ -154,7 +152,7 @@ public:
LOG_DEBUG(logger, "Calling EC2MetadataService resource, {} returned credential string {}.", LOG_DEBUG(logger, "Calling EC2MetadataService resource, {} returned credential string {}.",
EC2_SECURITY_CREDENTIALS_RESOURCE, trimmed_credentials_string); EC2_SECURITY_CREDENTIALS_RESOURCE, trimmed_credentials_string);
if (security_credentials.size() == 0) if (security_credentials.empty())
{ {
LOG_WARNING(logger, "Initial call to EC2MetadataService to get credentials failed."); LOG_WARNING(logger, "Initial call to EC2MetadataService to get credentials failed.");
return {}; return {};
@ -166,7 +164,7 @@ public:
return GetResource(ss.str().c_str()); return GetResource(ss.str().c_str());
} }
static Aws::String AWSComputeUserAgentString() static Aws::String awsComputeUserAgentString()
{ {
Aws::StringStream ss; Aws::StringStream ss;
ss << "aws-sdk-cpp/" << Aws::Version::GetVersionString() << " " << Aws::OSVersionInfo::ComputeOSVersionString() ss << "aws-sdk-cpp/" << Aws::Version::GetVersionString() << " " << Aws::OSVersionInfo::ComputeOSVersionString()
@ -174,9 +172,9 @@ public:
return ss.str(); return ss.str();
} }
virtual Aws::String GetDefaultCredentialsSecurely() const virtual Aws::String getDefaultCredentialsSecurely() const
{ {
String user_agent_string = AWSComputeUserAgentString(); String user_agent_string = awsComputeUserAgentString();
String new_token; String new_token;
{ {
@ -200,7 +198,7 @@ public:
else if (result.GetResponseCode() != Aws::Http::HttpResponseCode::OK || new_token.empty()) else if (result.GetResponseCode() != Aws::Http::HttpResponseCode::OK || new_token.empty())
{ {
LOG_TRACE(logger, "Calling EC2MetadataService to get token failed, falling back to less secure way."); LOG_TRACE(logger, "Calling EC2MetadataService to get token failed, falling back to less secure way.");
return GetDefaultCredentials(); return getDefaultCredentials();
} }
token = new_token; token = new_token;
} }
@ -219,7 +217,7 @@ public:
LOG_DEBUG(logger, "Calling EC2MetadataService resource, {} with token returned profile string {}.", LOG_DEBUG(logger, "Calling EC2MetadataService resource, {} with token returned profile string {}.",
EC2_SECURITY_CREDENTIALS_RESOURCE, trimmed_profile_string); EC2_SECURITY_CREDENTIALS_RESOURCE, trimmed_profile_string);
if (security_credentials.size() == 0) if (security_credentials.empty())
{ {
LOG_WARNING(logger, "Calling EC2Metadataservice to get profiles failed."); LOG_WARNING(logger, "Calling EC2Metadataservice to get profiles failed.");
return {}; return {};
@ -236,7 +234,7 @@ public:
return GetResourceWithAWSWebServiceResult(credentials_request).GetPayload(); return GetResourceWithAWSWebServiceResult(credentials_request).GetPayload();
} }
virtual Aws::String GetCurrentRegion() const virtual Aws::String getCurrentRegion() const
{ {
return Aws::Region::AWS_GLOBAL; return Aws::Region::AWS_GLOBAL;
} }
@ -258,14 +256,12 @@ public:
{ {
} }
virtual ~AWSEC2InstanceProfileConfigLoader() override virtual ~AWSEC2InstanceProfileConfigLoader() override = default;
{
}
protected: protected:
virtual bool LoadInternal() override virtual bool LoadInternal() override
{ {
auto credentials_str = use_secure_pull ? client->GetDefaultCredentialsSecurely() : client->GetDefaultCredentials(); auto credentials_str = use_secure_pull ? client->getDefaultCredentialsSecurely() : client->getDefaultCredentials();
/// See EC2InstanceProfileConfigLoader. /// See EC2InstanceProfileConfigLoader.
if (credentials_str.empty()) if (credentials_str.empty())
@ -286,7 +282,7 @@ protected:
secret_key = credentials_view.GetString("SecretAccessKey"); secret_key = credentials_view.GetString("SecretAccessKey");
token = credentials_view.GetString("Token"); token = credentials_view.GetString("Token");
auto region = client->GetCurrentRegion(); auto region = client->getCurrentRegion();
Aws::Config::Profile profile; Aws::Config::Profile profile;
profile.SetCredentials(Aws::Auth::AWSCredentials(access_key, secret_key, token)); profile.SetCredentials(Aws::Auth::AWSCredentials(access_key, secret_key, token));
@ -319,13 +315,13 @@ public:
Aws::Auth::AWSCredentials GetAWSCredentials() override Aws::Auth::AWSCredentials GetAWSCredentials() override
{ {
RefreshIfExpired(); refreshIfExpired();
Aws::Utils::Threading::ReaderLockGuard guard(m_reloadLock); Aws::Utils::Threading::ReaderLockGuard guard(m_reloadLock);
auto profileIter = ec2_metadata_config_loader->GetProfiles().find(Aws::Config::INSTANCE_PROFILE_KEY); auto profile_it = ec2_metadata_config_loader->GetProfiles().find(Aws::Config::INSTANCE_PROFILE_KEY);
if (profileIter != ec2_metadata_config_loader->GetProfiles().end()) if (profile_it != ec2_metadata_config_loader->GetProfiles().end())
{ {
return profileIter->second.GetCredentials(); return profile_it->second.GetCredentials();
} }
return Aws::Auth::AWSCredentials(); return Aws::Auth::AWSCredentials();
@ -340,7 +336,7 @@ protected:
} }
private: private:
void RefreshIfExpired() void refreshIfExpired()
{ {
LOG_DEBUG(logger, "Checking if latest credential pull has expired."); LOG_DEBUG(logger, "Checking if latest credential pull has expired.");
Aws::Utils::Threading::ReaderLockGuard guard(m_reloadLock); Aws::Utils::Threading::ReaderLockGuard guard(m_reloadLock);
@ -358,7 +354,7 @@ private:
} }
std::shared_ptr<AWSEC2InstanceProfileConfigLoader> ec2_metadata_config_loader; std::shared_ptr<AWSEC2InstanceProfileConfigLoader> ec2_metadata_config_loader;
long load_frequency_ms; Int64 load_frequency_ms;
Poco::Logger * logger; Poco::Logger * logger;
}; };