fgerlits commented on code in PR #2086:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2086#discussion_r2704942878
##########
extensions/gcp/controllerservices/GCPCredentialsControllerService.cpp:
##########
@@ -21,52 +21,32 @@
#include "core/Resource.h"
#include "google/cloud/storage/client.h"
#include "utils/ProcessorConfigUtils.h"
-
-namespace gcs = ::google::cloud::storage;
+#include "utils/file/FileUtils.h"
namespace org::apache::nifi::minifi::extensions::gcp {
void GCPCredentialsControllerService::initialize() {
setSupportedProperties(Properties);
}
-std::shared_ptr<gcs::oauth2::Credentials>
GCPCredentialsControllerService::createDefaultCredentials() const {
- auto default_credentials =
gcs::oauth2::CreateServiceAccountCredentialsFromDefaultPaths();
- if (!default_credentials.ok()) {
- logger_->log_error("{}", default_credentials.status().message());
- return nullptr;
- }
- return *default_credentials;
-}
-
-std::shared_ptr<gcs::oauth2::Credentials>
GCPCredentialsControllerService::createCredentialsFromJsonPath() const {
+std::shared_ptr<google::cloud::Credentials>
GCPCredentialsControllerService::createCredentialsFromJsonPath() const {
const auto json_path = getProperty(JsonFilePath.name);
if (!json_path) {
logger_->log_error("Missing or invalid {}", JsonFilePath.name);
return nullptr;
}
- auto json_path_credentials =
gcs::oauth2::CreateServiceAccountCredentialsFromJsonFilePath(*json_path);
- if (!json_path_credentials.ok()) {
- logger_->log_error("{}", json_path_credentials.status().message());
- return nullptr;
- }
- return *json_path_credentials;
+ return
google::cloud::MakeServiceAccountCredentials(utils::file::get_content(*json_path));
Review Comment:
I think it would be useful to check if the file exists, so the user gets a
different error when they have mistyped the file name and when the file is
empty.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]