fix code style
1. add .clang-format code style file. 2. format code of core. use `clang-format -i -style=file ./core/*/*.cc ./core/*/*.h` command to format
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* Copyright 1999-2019 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright 1999-2019 Alibaba Cloud All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <alibabacloud/core/StsAssumeRoleCredentialsProvider.h>
|
||||
#include <iomanip>
|
||||
@@ -21,25 +21,15 @@
|
||||
namespace AlibabaCloud {
|
||||
|
||||
StsAssumeRoleCredentialsProvider::StsAssumeRoleCredentialsProvider(
|
||||
const Credentials &credentials,
|
||||
const ClientConfiguration &configuration,
|
||||
const std::string & roleArn,
|
||||
const std::string & roleSessionName,
|
||||
const std::string & policy,
|
||||
int durationSeconds):
|
||||
CredentialsProvider(),
|
||||
StsClient(credentials, configuration),
|
||||
roleArn_(roleArn),
|
||||
roleSessionName_(roleSessionName),
|
||||
policy_(policy),
|
||||
durationSeconds_(durationSeconds),
|
||||
cachedMutex_(),
|
||||
cachedCredentials_("", ""),
|
||||
expiry_() {
|
||||
}
|
||||
const Credentials &credentials, const ClientConfiguration &configuration,
|
||||
const std::string &roleArn, const std::string &roleSessionName,
|
||||
const std::string &policy, int durationSeconds)
|
||||
: CredentialsProvider(), StsClient(credentials, configuration),
|
||||
roleArn_(roleArn), roleSessionName_(roleSessionName), policy_(policy),
|
||||
durationSeconds_(durationSeconds), cachedMutex_(),
|
||||
cachedCredentials_("", ""), expiry_() {}
|
||||
|
||||
StsAssumeRoleCredentialsProvider::~StsAssumeRoleCredentialsProvider() {
|
||||
}
|
||||
StsAssumeRoleCredentialsProvider::~StsAssumeRoleCredentialsProvider() {}
|
||||
|
||||
Credentials StsAssumeRoleCredentialsProvider::getCredentials() {
|
||||
loadCredentials();
|
||||
@@ -47,10 +37,10 @@ Credentials StsAssumeRoleCredentialsProvider::getCredentials() {
|
||||
return cachedCredentials_;
|
||||
}
|
||||
|
||||
bool StsAssumeRoleCredentialsProvider::checkExpiry()const {
|
||||
bool StsAssumeRoleCredentialsProvider::checkExpiry() const {
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto diff =
|
||||
std::chrono::duration_cast<std::chrono::seconds>(now - expiry_).count();
|
||||
std::chrono::duration_cast<std::chrono::seconds>(now - expiry_).count();
|
||||
|
||||
return (diff > 0 - 60);
|
||||
}
|
||||
@@ -69,8 +59,8 @@ void StsAssumeRoleCredentialsProvider::loadCredentials() {
|
||||
if (assumeRoleOutcome.isSuccess()) {
|
||||
const auto stsCredentials = assumeRoleOutcome.result().credentials();
|
||||
cachedCredentials_ = Credentials(stsCredentials.accessKeyId,
|
||||
stsCredentials.accessKeySecret,
|
||||
stsCredentials.securityToken);
|
||||
stsCredentials.accessKeySecret,
|
||||
stsCredentials.securityToken);
|
||||
|
||||
std::tm tm = {};
|
||||
#if defined(__GNUG__) && __GNUC__ < 5
|
||||
@@ -85,4 +75,4 @@ void StsAssumeRoleCredentialsProvider::loadCredentials() {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AlibabaCloud
|
||||
} // namespace AlibabaCloud
|
||||
|
||||
Reference in New Issue
Block a user