Skip to content

Commit 08ab8d4

Browse files
committed
fix(S3): asString output and test config [skip ci]
1 parent e1fccb9 commit 08ab8d4

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

src/eckit/io/s3/S3BucketPath.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct S3BucketPath {
3131

3232
S3BucketPath(std::string bucket) : bucket {std::move(bucket)} { }
3333

34-
auto asString() const -> std::string { return '/' + bucket; }
34+
auto asString() const -> std::string { return bucket; }
3535

3636
operator std::string() const { return asString(); }
3737

src/eckit/io/s3/S3Config.cc

+8-5
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,19 @@ auto S3Config::make(std::string path) -> std::vector<S3Config> {
6969
path = Resource<std::string>("s3ConfigFile;$ECKIT_S3_CONFIG_FILE", "~/.config/eckit/S3Config.yaml");
7070
}
7171

72-
PathName configFile(path);
72+
PathName configPath(path);
7373

74-
if (!configFile.exists()) {
75-
Log::debug<LibEcKit>() << "S3 configuration file does not exist: " << configFile << std::endl;
74+
if (!configPath.exists()) {
75+
Log::debug<LibEcKit>() << "S3 configuration file does not exist: " << configPath << std::endl;
7676
return {};
7777
}
7878

79-
LOG_DEBUG_LIB(LibEcKit) << "Reading S3 configuration from: " << configFile << std::endl;
79+
if (configPath.isDir()) {
80+
Log::debug<LibEcKit>() << "Path " << configPath << " is a directory. Expecting a file!" << std::endl;
81+
return {};
82+
}
8083

81-
const auto servers = YAMLConfiguration(configFile).getSubConfigurations("servers");
84+
const auto servers = YAMLConfiguration(configPath).getSubConfigurations("servers");
8285

8386
std::vector<S3Config> result;
8487
result.reserve(servers.size());

src/eckit/io/s3/S3Credential.cc

+9-6
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,21 @@ auto S3Credential::fromFile(std::string path) -> std::vector<S3Credential> {
5151

5252
if (path.empty()) { path = Resource<std::string>("s3CredentialsFile;$ECKIT_S3_CREDENTIALS_FILE", defaultCredFile); }
5353

54-
PathName credFile(path);
54+
PathName credPath(path);
5555

56-
if (!credFile.exists()) {
57-
Log::debug<LibEcKit>() << "S3 credentials file does not exist: " << credFile << std::endl;
56+
if (!credPath.exists()) {
57+
Log::debug<LibEcKit>() << "S3 credentials file does not exist: " << credPath << std::endl;
5858
return {};
5959
}
6060

61-
LOG_DEBUG_LIB(LibEcKit) << "Reading S3 credentials from: " << credFile << std::endl;
61+
if (credPath.isDir()) {
62+
Log::debug<LibEcKit>() << "Path " << credPath << " is a directory. Expecting a file!" << std::endl;
63+
return {};
64+
}
6265

63-
std::vector<S3Credential> result;
66+
const auto creds = YAMLConfiguration(credPath).getSubConfigurations("credentials");
6467

65-
const auto creds = YAMLConfiguration(credFile).getSubConfigurations("credentials");
68+
std::vector<S3Credential> result;
6669
result.reserve(creds.size());
6770
for (const auto& cred : creds) { result.emplace_back(fromYAML(cred)); }
6871

src/eckit/io/s3/S3ObjectPath.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct S3ObjectPath {
3131

3232
S3ObjectPath(std::string bucket, std::string object) : bucket {std::move(bucket)}, object {std::move(object)} { }
3333

34-
auto asString() const -> std::string { return '/' + bucket + '/' + object; }
34+
auto asString() const -> std::string { return bucket + '/' + object; }
3535

3636
operator std::string() const { return asString(); }
3737

tests/io/s3/test_s3_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ inline void cleanup(const std::vector<std::string>& bucketPaths) {
5757
}
5858
}
5959

60-
void writePerformance(S3BucketName& bucket, const int count) {
60+
inline void writePerformance(S3BucketName& bucket, const int count) {
6161
eckit::Timer timer;
6262

6363
Buffer buffer(1024 * 1024);

tests/io/s3/test_s3_config.h.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ inline void cleanup(const std::vector<std::string>& bucketPaths) {
5757
}
5858
}
5959

60-
void writePerformance(S3BucketName& bucket, const int count) {
60+
inline void writePerformance(S3BucketName& bucket, const int count) {
6161
eckit::Timer timer;
6262

6363
Buffer buffer(1024 * 1024);

0 commit comments

Comments
 (0)