Skip to content

Commit a9a3bf0

Browse files
committed
update to use getglobalendpointurl to match rest of sdk
1 parent 59f5ae9 commit a9a3bf0

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

src/aws-cpp-sdk-core/include/aws/core/config/AWSProfileConfig.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ namespace Aws
103103
inline void SetSourceProfile(const Aws::String& value ) { m_sourceProfile = value; }
104104
inline const Aws::String& GetCredentialProcess() const { return m_credentialProcess; }
105105
inline void SetCredentialProcess(const Aws::String& value ) { m_credentialProcess = value; }
106+
inline Aws::String GetGlobalEndpointUrl() const { return m_endpointUrl; }
107+
inline void SetGlobalEndpointUrl(const Aws::String& value) { m_endpointUrl = value; }
108+
inline Services GetServices() const { return m_services; }
109+
inline void SetServices(Services&& services) { m_services = std::move(services); }
106110
inline void SetAllKeyValPairs(const Aws::Map<Aws::String, Aws::String>& map) { m_allKeyValPairs = map; }
107111
inline void SetAllKeyValPairs(Aws::Map<Aws::String, Aws::String>&& map) { m_allKeyValPairs = std::move(map); }
108112
inline const Aws::String GetValue(const Aws::String& key) const
@@ -112,14 +116,6 @@ namespace Aws
112116
return iter->second;
113117
}
114118

115-
inline const Services& GetServices() const { return m_services; }
116-
inline void SetServices(Services&& services) { m_services = std::move(services); }
117-
118-
inline Aws::Crt::Optional<Aws::String> GetGlobalEndpointUrl() const {
119-
const Aws::String& endpoint = GetValue("endpoint_url");
120-
return endpoint.empty() ? Aws::Crt::Optional<Aws::String>() : Aws::Crt::Optional<Aws::String>(endpoint);
121-
}
122-
123119
inline bool IsSsoSessionSet() const { return m_ssoSessionSet; }
124120
inline const SsoSession& GetSsoSession() const { return m_ssoSession; }
125121
inline void SetSsoSession(const SsoSession& value) { m_ssoSessionSet = true; m_ssoSession = value; }
@@ -138,6 +134,7 @@ namespace Aws
138134
Aws::String m_ssoAccountId;
139135
Aws::String m_ssoRoleName;
140136
Aws::String m_defaultsMode;
137+
Aws::String m_endpointUrl;
141138
Aws::Map<Aws::String, Aws::String> m_allKeyValPairs;
142139
Services m_services;
143140

src/aws-cpp-sdk-core/source/config/AWSConfigFileProfileConfigLoader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ namespace Aws
7777
{EXTERNAL_ID_KEY, &Profile::SetExternalId, &Profile::GetExternalId},
7878
{CREDENTIAL_PROCESS_COMMAND, &Profile::SetCredentialProcess, &Profile::GetCredentialProcess},
7979
{SOURCE_PROFILE_KEY, &Profile::SetSourceProfile, &Profile::GetSourceProfile},
80-
{DEFAULTS_MODE_KEY, &Profile::SetDefaultsMode, &Profile::GetDefaultsMode}};
80+
{DEFAULTS_MODE_KEY, &Profile::SetDefaultsMode, &Profile::GetDefaultsMode},
81+
{ENDPOINT_URL_KEY, &Profile::SetGlobalEndpointUrl, &Profile::GetGlobalEndpointUrl}};
8182

8283
template<typename EntryT, size_t N>
8384
const EntryT* FindInStaticArray(const EntryT (&array)[N], const Aws::String& searchKey)

tests/aws-cpp-sdk-core-tests/aws/config/ServiceEndpointsConfigFileLoaderTest.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ TEST_F(ServiceEndpointsConfigFileLoaderTest, TestServiceSpecificEndpoints)
4343
ASSERT_NE(profiles.end(), profileIt);
4444
const auto& profile = profileIt->second;
4545
auto globalEndpoint = profile.GetGlobalEndpointUrl();
46-
ASSERT_TRUE(globalEndpoint.has_value());
47-
ASSERT_STREQ("https://global.example.com", globalEndpoint->c_str());
46+
ASSERT_FALSE(globalEndpoint.empty());
47+
ASSERT_STREQ("https://global.example.com", globalEndpoint.c_str());
4848

4949
// Test services endpoints are parsed correctly
5050
const auto& services = profile.GetServices();
@@ -76,7 +76,7 @@ TEST_F(ServiceEndpointsConfigFileLoaderTest, TestServiceSpecificEndpointsOnly)
7676

7777
// Test that global endpoint is null when not set
7878
auto globalEndpoint = profile.GetGlobalEndpointUrl();
79-
ASSERT_FALSE(globalEndpoint.has_value());
79+
ASSERT_TRUE(globalEndpoint.empty());
8080

8181
// Test services endpoints are parsed correctly
8282
const auto& services = profile.GetServices();
@@ -104,8 +104,8 @@ TEST_F(ServiceEndpointsConfigFileLoaderTest, TestGlobalEndpointOnly)
104104

105105
// Test global endpoint
106106
auto globalEndpoint = profile.GetGlobalEndpointUrl();
107-
ASSERT_TRUE(globalEndpoint.has_value());
108-
ASSERT_STREQ("https://play.min.io:9000", globalEndpoint->c_str());
107+
ASSERT_FALSE(globalEndpoint.empty());
108+
ASSERT_STREQ("https://play.min.io:9000", globalEndpoint.c_str());
109109

110110
// Test that services endpoints are not set
111111
const auto& services = profile.GetServices();
@@ -141,8 +141,8 @@ TEST_F(ServiceEndpointsConfigFileLoaderTest, TestServiceSpecificAndGlobalEndpoin
141141

142142
// Test global endpoint
143143
auto globalEndpoint = profile.GetGlobalEndpointUrl();
144-
ASSERT_TRUE(globalEndpoint.has_value());
145-
ASSERT_STREQ("http://localhost:1234", globalEndpoint->c_str());
144+
ASSERT_FALSE(globalEndpoint.empty());
145+
ASSERT_STREQ("http://localhost:1234", globalEndpoint.c_str());
146146
}
147147

148148
TEST_F(ServiceEndpointsConfigFileLoaderTest, TestMultipleServicesInDefinition)
@@ -195,7 +195,7 @@ TEST_F(ServiceEndpointsConfigFileLoaderTest, TestIgnoreGlobalEndpointInServicesS
195195

196196
// Test that global endpoint in services section is ignored
197197
auto globalEndpoint = profile.GetGlobalEndpointUrl();
198-
ASSERT_FALSE(globalEndpoint.has_value());
198+
ASSERT_TRUE(globalEndpoint.empty());
199199

200200
// Test that services endpoints are empty (global endpoint_url ignored)
201201
const auto& services = profile.GetServices();
@@ -240,12 +240,12 @@ TEST_F(ServiceEndpointsConfigFileLoaderTest, TestSourceProfileEndpointIsolation)
240240

241241
// Test that profile B has no global endpoint (doesn't inherit from profile A)
242242
auto globalEndpointB = profileB.GetGlobalEndpointUrl();
243-
ASSERT_FALSE(globalEndpointB.has_value());
243+
ASSERT_TRUE(globalEndpointB.empty());
244244

245245
// Test that profile A still has its own global endpoint
246246
auto globalEndpointA = profileA.GetGlobalEndpointUrl();
247-
ASSERT_TRUE(globalEndpointA.has_value());
248-
ASSERT_STREQ("https://profile-a-endpoint.aws/", globalEndpointA->c_str());
247+
ASSERT_FALSE(globalEndpointA.empty());
248+
ASSERT_STREQ("https://profile-a-endpoint.aws/", globalEndpointA.c_str());
249249

250250
// Test that profile A has no services name
251251
const auto& servicesA = profileA.GetServices();
@@ -325,8 +325,8 @@ TEST_F(ServiceEndpointsConfigFileLoaderTest, TestDuplicateGlobalEndpointUrl)
325325

326326
// Test that last value wins for duplicate global endpoint_url
327327
auto globalEndpoint = profile.GetGlobalEndpointUrl();
328-
ASSERT_TRUE(globalEndpoint.has_value());
329-
ASSERT_STREQ("https://play2.min.io:9000", globalEndpoint->c_str());
328+
ASSERT_FALSE(globalEndpoint.empty());
329+
ASSERT_STREQ("https://play2.min.io:9000", globalEndpoint.c_str());
330330
}
331331

332332
TEST_F(ServiceEndpointsConfigFileLoaderTest, TestDuplicateServiceEndpointUrl)
@@ -385,8 +385,8 @@ TEST_F(ServiceEndpointsConfigFileLoaderTest, TestMixedDuplicateEndpoints)
385385

386386
// Test that last global endpoint_url wins
387387
auto globalEndpoint = profile.GetGlobalEndpointUrl();
388-
ASSERT_TRUE(globalEndpoint.has_value());
389-
ASSERT_STREQ("https://global2.example.com", globalEndpoint->c_str());
388+
ASSERT_FALSE(globalEndpoint.empty());
389+
ASSERT_STREQ("https://global2.example.com", globalEndpoint.c_str());
390390

391391
// Test that last service endpoint_url wins, but other services remain
392392
const auto& services = profile.GetServices();

0 commit comments

Comments
 (0)