Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
szaszm merged PR #2153: URL: https://github.com/apache/nifi-minifi-cpp/pull/2153 -- 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]
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
szaszm commented on PR #2153: URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#issuecomment-4708940472 removed the ready-to-merge label due to merge conflicts -- 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]
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
martinzink commented on code in PR #2153:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#discussion_r3413162454
##
extensions/gcp/processors/GCSProcessor.cpp:
##
@@ -17,45 +17,43 @@
#include "GCSProcessor.h"
-#include "utils/ProcessorConfigUtils.h"
-
#include "../controllerservices/GCPCredentialsControllerService.h"
-#include "minifi-cpp/core/ProcessContext.h"
-#include "core/ProcessSession.h"
+#include "api/utils/ProcessorConfigUtils.h"
namespace gcs = ::google::cloud::storage;
namespace org::apache::nifi::minifi::extensions::gcp {
-std::shared_ptr
GCSProcessor::getCredentials(core::ProcessContext& context) const {
- auto gcp_credentials_controller_service =
utils::parseOptionalControllerService(context,
GCSProcessor::GCPCredentials, getUUID());
- if (gcp_credentials_controller_service) {
+std::shared_ptr GCSProcessor::getCredentials(const
api::core::ProcessContext& context) {
+ if (const auto gcp_credentials_controller_service =
api::utils::parseOptionalControllerService(context,
+ GCPCredentials)) {
Review Comment:
i sidestepped the issue and went to single line instead
https://github.com/apache/nifi-minifi-cpp/commit/ef5127edb96e2fb6b2976d6e9a765a6edfe4dce4#diff-d387dcbcbd30ca566a5c8ca88d05059558b265cf3fb1f923e45299873245a66bR28
--
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]
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
martinzink commented on code in PR #2153:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#discussion_r3413158000
##
extensions/gcp/processors/FetchGCSObject.cpp:
##
@@ -82,80 +80,78 @@ class FetchFromGCSCallback {
};
} // namespace
-
-void FetchGCSObject::initialize() {
- setSupportedProperties(Properties);
- setSupportedRelationships(Relationships);
-}
-
-void FetchGCSObject::onSchedule(core::ProcessContext& context,
core::ProcessSessionFactory& session_factory) {
- GCSProcessor::onSchedule(context, session_factory);
- if (auto encryption_key = context.getProperty(EncryptionKey)) {
+MinifiStatus FetchGCSObject::onScheduleImpl(api::core::ProcessContext&
context) {
+ const auto status = GCSProcessor::onScheduleImpl(context);
+ if (MINIFI_STATUS_SUCCESS != status) {
+return status;
+ }
+ if (auto encryption_key = context.getProperty(EncryptionKey, nullptr)) {
try {
encryption_key_ = gcs::EncryptionKey::FromBase64Key(*encryption_key);
} catch (const google::cloud::RuntimeStatusError&) {
- throw minifi::Exception(ExceptionType::PROCESS_SCHEDULE_EXCEPTION,
"Could not decode the base64-encoded encryption key from property " +
std::string(EncryptionKey.name));}
+ logger_->log_error("Could not decode the base64-encoded encryption key
from property {}", std::string(EncryptionKey.name));
+ return MINIFI_STATUS_UNKNOWN_ERROR;
+}
}
+ return MINIFI_STATUS_SUCCESS;
}
-void FetchGCSObject::onTrigger(core::ProcessContext& context,
core::ProcessSession& session) {
+MinifiStatus FetchGCSObject::onTriggerImpl(api::core::ProcessContext& context,
api::core::ProcessSession& session) {
gsl_Expects(gcp_credentials_);
auto flow_file = session.get();
if (!flow_file) {
-context.yield();
-return;
+return MINIFI_STATUS_PROCESSOR_YIELD;
}
- auto bucket = context.getProperty(Bucket, flow_file.get());
+ auto bucket = api::utils::parseOptionalProperty(context, Bucket, &flow_file);
if (!bucket || bucket->empty()) {
logger_->log_error("Missing bucket name");
-session.transfer(flow_file, Failure);
-return;
+session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
- auto object_name = context.getProperty(Key, flow_file.get());
+ auto object_name = api::utils::parseOptionalProperty(context, Key,
&flow_file);
if (!object_name || object_name->empty()) {
logger_->log_error("Missing object name");
-session.transfer(flow_file, Failure);
-return;
+session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
gcs::Client client = getClient();
FetchFromGCSCallback callback(client, *bucket, *object_name);
callback.setEncryptionKey(encryption_key_);
- if (const auto object_generation_str =
context.getProperty(ObjectGeneration, flow_file.get()); object_generation_str
&& !object_generation_str->empty()) {
+ if (const auto object_generation_str =
api::utils::parseOptionalProperty(context, ObjectGeneration, &flow_file);
object_generation_str && !object_generation_str->empty()) {
if (const auto geni64 =
parsing::parseIntegral(*object_generation_str)) {
gcs::Generation generation = gcs::Generation{*geni64};
callback.setGeneration(generation);
} else {
logger_->log_error("Invalid generation: {}", *object_generation_str);
- session.transfer(flow_file, Failure);
- return;
+ session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
}
session.write(flow_file, std::ref(callback));
if (!callback.getStatus().ok()) {
-flow_file->setAttribute(GCS_STATUS_MESSAGE,
callback.getStatus().message());
-flow_file->setAttribute(GCS_ERROR_REASON,
callback.getStatus().error_info().reason());
-flow_file->setAttribute(GCS_ERROR_DOMAIN,
callback.getStatus().error_info().domain());
+session.setAttribute(flow_file, GCS_STATUS_MESSAGE,
callback.getStatus().message());
+session.setAttribute(flow_file, GCS_ERROR_REASON,
callback.getStatus().error_info().reason());
+session.setAttribute(flow_file, GCS_ERROR_DOMAIN,
callback.getStatus().error_info().domain());
logger_->log_error("Failed to fetch from Google Cloud Storage {} {}",
callback.getStatus().message(), callback.getStatus().error_info().reason());
-session.transfer(flow_file, Failure);
-return;
+session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
if (auto generation = callback.getGeneration())
-flow_file->setAttribute(GCS_GENERATION, std::to_string(*generation));
+session.setAttribute(flow_file, GCS_GENERATION,
std::to_string(*generation));
if (auto meta_generation = callback.getMetaGeneration())
-flow_file->setAttribute(GCS_META_GENERATION,
std::to_string(*meta_generation));
+session.setAttribute(flow_file, GCS_META_GENERATION,
std::to_string(*meta_generation));
if (auto storag
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
martinzink commented on code in PR #2153:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#discussion_r3413156542
##
extensions/gcp/processors/FetchGCSObject.cpp:
##
@@ -82,80 +80,78 @@ class FetchFromGCSCallback {
};
} // namespace
-
-void FetchGCSObject::initialize() {
- setSupportedProperties(Properties);
- setSupportedRelationships(Relationships);
-}
-
-void FetchGCSObject::onSchedule(core::ProcessContext& context,
core::ProcessSessionFactory& session_factory) {
- GCSProcessor::onSchedule(context, session_factory);
- if (auto encryption_key = context.getProperty(EncryptionKey)) {
+MinifiStatus FetchGCSObject::onScheduleImpl(api::core::ProcessContext&
context) {
+ const auto status = GCSProcessor::onScheduleImpl(context);
+ if (MINIFI_STATUS_SUCCESS != status) {
+return status;
+ }
+ if (auto encryption_key = context.getProperty(EncryptionKey, nullptr)) {
try {
encryption_key_ = gcs::EncryptionKey::FromBase64Key(*encryption_key);
} catch (const google::cloud::RuntimeStatusError&) {
- throw minifi::Exception(ExceptionType::PROCESS_SCHEDULE_EXCEPTION,
"Could not decode the base64-encoded encryption key from property " +
std::string(EncryptionKey.name));}
+ logger_->log_error("Could not decode the base64-encoded encryption key
from property {}", std::string(EncryptionKey.name));
+ return MINIFI_STATUS_UNKNOWN_ERROR;
+}
}
+ return MINIFI_STATUS_SUCCESS;
}
-void FetchGCSObject::onTrigger(core::ProcessContext& context,
core::ProcessSession& session) {
+MinifiStatus FetchGCSObject::onTriggerImpl(api::core::ProcessContext& context,
api::core::ProcessSession& session) {
gsl_Expects(gcp_credentials_);
auto flow_file = session.get();
if (!flow_file) {
-context.yield();
-return;
+return MINIFI_STATUS_PROCESSOR_YIELD;
}
- auto bucket = context.getProperty(Bucket, flow_file.get());
+ auto bucket = api::utils::parseOptionalProperty(context, Bucket, &flow_file);
if (!bucket || bucket->empty()) {
logger_->log_error("Missing bucket name");
-session.transfer(flow_file, Failure);
-return;
+session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
- auto object_name = context.getProperty(Key, flow_file.get());
+ auto object_name = api::utils::parseOptionalProperty(context, Key,
&flow_file);
if (!object_name || object_name->empty()) {
logger_->log_error("Missing object name");
-session.transfer(flow_file, Failure);
-return;
+session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
gcs::Client client = getClient();
FetchFromGCSCallback callback(client, *bucket, *object_name);
callback.setEncryptionKey(encryption_key_);
- if (const auto object_generation_str =
context.getProperty(ObjectGeneration, flow_file.get()); object_generation_str
&& !object_generation_str->empty()) {
+ if (const auto object_generation_str =
api::utils::parseOptionalProperty(context, ObjectGeneration, &flow_file);
object_generation_str && !object_generation_str->empty()) {
if (const auto geni64 =
parsing::parseIntegral(*object_generation_str)) {
gcs::Generation generation = gcs::Generation{*geni64};
callback.setGeneration(generation);
} else {
logger_->log_error("Invalid generation: {}", *object_generation_str);
- session.transfer(flow_file, Failure);
- return;
+ session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
Review Comment:
https://github.com/apache/nifi-minifi-cpp/commit/ef5127edb96e2fb6b2976d6e9a765a6edfe4dce4#diff-83c70f4cfe2b0c8cdef254a079398bb7f6b386c9a5dd55367239ab33d257f991R130
--
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]
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
martinzink commented on code in PR #2153:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#discussion_r3413155069
##
extensions/gcp/processors/DeleteGCSObject.cpp:
##
@@ -17,69 +17,62 @@
#include "DeleteGCSObject.h"
-#include "utils/ProcessorConfigUtils.h"
#include "../GCPAttributes.h"
-#include "minifi-cpp/core/FlowFile.h"
-#include "minifi-cpp/core/ProcessContext.h"
-#include "core/ProcessSession.h"
-#include "core/Resource.h"
+#include "api/core/ProcessContext.h"
+#include "api/core/ProcessSession.h"
+#include "api/core/Resource.h"
+#include "api/utils/ProcessorConfigUtils.h"
namespace gcs = ::google::cloud::storage;
namespace org::apache::nifi::minifi::extensions::gcp {
-void DeleteGCSObject::initialize() {
- setSupportedProperties(Properties);
- setSupportedRelationships(Relationships);
-}
-void DeleteGCSObject::onTrigger(core::ProcessContext& context,
core::ProcessSession& session) {
+MinifiStatus DeleteGCSObject::onTriggerImpl(api::core::ProcessContext&
context, api::core::ProcessSession& session) {
gsl_Expects(gcp_credentials_);
auto flow_file = session.get();
if (!flow_file) {
-context.yield();
-return;
+return MINIFI_STATUS_PROCESSOR_YIELD;
}
- auto bucket = context.getProperty(Bucket, flow_file.get());
+ auto bucket = api::utils::parseOptionalProperty(context, Bucket, &flow_file);
if (!bucket || bucket->empty()) {
logger_->log_error("Missing bucket name");
-session.transfer(flow_file, Failure);
-return;
+session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
- auto object_name = context.getProperty(Key, flow_file.get());
+ auto object_name = api::utils::parseOptionalProperty(context, Key,
&flow_file);
if (!object_name || object_name->empty()) {
logger_->log_error("Missing object name");
-session.transfer(flow_file, Failure);
-return;
+session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
gcs::Generation generation;
- if (const auto object_generation_str =
context.getProperty(ObjectGeneration, flow_file.get()); object_generation_str
&& !object_generation_str->empty()) {
+ if (auto object_generation_str = api::utils::parseOptionalProperty(context,
ObjectGeneration, &flow_file); object_generation_str &&
!object_generation_str->empty()) {
if (const auto geni64 =
parsing::parseIntegral(*object_generation_str)) {
generation = gcs::Generation{*geni64};
} else {
logger_->log_error("Invalid generation: {}", *object_generation_str);
- session.transfer(flow_file, Failure);
- return;
+ session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
Review Comment:
https://github.com/apache/nifi-minifi-cpp/commit/ef5127edb96e2fb6b2976d6e9a765a6edfe4dce4#diff-66aefae52dc810cf9ca83e1aa50e15c8c9d6f2f168ac0ac46e2612c24b1d7e83R58
--
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]
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
martinzink commented on code in PR #2153:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#discussion_r3413152227
##
extension-framework/cpp-extension-lib/include/api/utils/Proxy.h:
##
@@ -0,0 +1,42 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+#pragma once
+
+#include
+#include
+#include
+
+namespace org::apache::nifi::minifi::api::utils {
+
+enum class ProxyType {
+ DIRECT,
+ HTTP
+};
+
+struct BasicAuthCredentials {
+ std::string username;
+ std::string password;
+};
+
+struct ProxyData {
+ std::string host;
+ uint16_t port;
+ std::optional proxy_credentials;
+ ProxyType proxy_type;
Review Comment:
https://github.com/apache/nifi-minifi-cpp/pull/2153/changes/ef5127edb96e2fb6b2976d6e9a765a6edfe4dce4#diff-1b8d97f99d7ac1ca8ded029ba21165d25db336ee3f351ed20377d87e806aca55R36
--
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]
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
szaszm commented on code in PR #2153:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#discussion_r3365891531
##
extension-framework/cpp-extension-lib/include/api/utils/Proxy.h:
##
@@ -0,0 +1,42 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+#pragma once
+
+#include
+#include
+#include
+
+namespace org::apache::nifi::minifi::api::utils {
+
+enum class ProxyType {
+ DIRECT,
+ HTTP
+};
+
+struct BasicAuthCredentials {
+ std::string username;
+ std::string password;
+};
+
+struct ProxyData {
+ std::string host;
+ uint16_t port;
+ std::optional proxy_credentials;
+ ProxyType proxy_type;
Review Comment:
I'd move the type to be the first member just out of personal preference,
because it depends on the type whether the rest of the struct members are
meaningful at all.
##
extensions/gcp/processors/FetchGCSObject.cpp:
##
@@ -82,80 +80,78 @@ class FetchFromGCSCallback {
};
} // namespace
-
-void FetchGCSObject::initialize() {
- setSupportedProperties(Properties);
- setSupportedRelationships(Relationships);
-}
-
-void FetchGCSObject::onSchedule(core::ProcessContext& context,
core::ProcessSessionFactory& session_factory) {
- GCSProcessor::onSchedule(context, session_factory);
- if (auto encryption_key = context.getProperty(EncryptionKey)) {
+MinifiStatus FetchGCSObject::onScheduleImpl(api::core::ProcessContext&
context) {
+ const auto status = GCSProcessor::onScheduleImpl(context);
+ if (MINIFI_STATUS_SUCCESS != status) {
+return status;
+ }
+ if (auto encryption_key = context.getProperty(EncryptionKey, nullptr)) {
try {
encryption_key_ = gcs::EncryptionKey::FromBase64Key(*encryption_key);
} catch (const google::cloud::RuntimeStatusError&) {
- throw minifi::Exception(ExceptionType::PROCESS_SCHEDULE_EXCEPTION,
"Could not decode the base64-encoded encryption key from property " +
std::string(EncryptionKey.name));}
+ logger_->log_error("Could not decode the base64-encoded encryption key
from property {}", std::string(EncryptionKey.name));
+ return MINIFI_STATUS_UNKNOWN_ERROR;
+}
}
+ return MINIFI_STATUS_SUCCESS;
}
-void FetchGCSObject::onTrigger(core::ProcessContext& context,
core::ProcessSession& session) {
+MinifiStatus FetchGCSObject::onTriggerImpl(api::core::ProcessContext& context,
api::core::ProcessSession& session) {
gsl_Expects(gcp_credentials_);
auto flow_file = session.get();
if (!flow_file) {
-context.yield();
-return;
+return MINIFI_STATUS_PROCESSOR_YIELD;
}
- auto bucket = context.getProperty(Bucket, flow_file.get());
+ auto bucket = api::utils::parseOptionalProperty(context, Bucket, &flow_file);
if (!bucket || bucket->empty()) {
logger_->log_error("Missing bucket name");
-session.transfer(flow_file, Failure);
-return;
+session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
- auto object_name = context.getProperty(Key, flow_file.get());
+ auto object_name = api::utils::parseOptionalProperty(context, Key,
&flow_file);
if (!object_name || object_name->empty()) {
logger_->log_error("Missing object name");
-session.transfer(flow_file, Failure);
-return;
+session.transfer(std::move(flow_file), Failure);
+return MINIFI_STATUS_SUCCESS;
}
gcs::Client client = getClient();
FetchFromGCSCallback callback(client, *bucket, *object_name);
callback.setEncryptionKey(encryption_key_);
- if (const auto object_generation_str =
context.getProperty(ObjectGeneration, flow_file.get()); object_generation_str
&& !object_generation_str->empty()) {
+ if (const auto object_generation_str =
api::utils::parseOptionalProperty(context, ObjectGeneration, &flow_file);
object_generation_str && !object_generation_str->empty()) {
if (const auto geni64 =
parsing::parseIntegral(*object_generation_str)) {
gcs::Generation generation = gcs::Generation{*geni64};
callback.setGeneration(generation);
} else {
logger_->log_error("Invalid generation: {}", *object_generation_str);
- session.transfer(flow_file, Failure);
- return;
+ session.transfer(std::move(flow_file), Failure);
+
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
martinzink commented on code in PR #2153:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#discussion_r3201405076
##
core-framework/common/include/core/PropertyDefinitionBuilder.h:
##
@@ -27,7 +27,21 @@ namespace org::apache::nifi::minifi::core {
namespace detail {
template
inline constexpr auto TypeNames = std::array{core::className()...};
-}
+
+template
+struct StringLiteral {
+ char value[N];
+ constexpr StringLiteral(const char (&str)[N]) { // NOLINT(runtime/explicit)
+for (size_t i = 0; i < N; ++i) {
+ value[i] = str[i];
+}
+ }
+};
+
+// A variable template that creates permanent static memory for the span to
point to
+template
+inline constexpr auto StaticAllowedType = std::array{std::string_view{str.value, sizeof(str.value) - 1}};
+} // namespace detail
Review Comment:
This is required for this to work
https://github.com/apache/nifi-minifi-cpp/pull/2153/changes#diff-0404937d5b253fb100b47ee1ae38b62125eb24f0461acb2faa431d236713933bR56
--
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]
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
martinzink commented on PR #2153: URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#issuecomment-4280092923 I'll draft it until https://github.com/apache/nifi-minifi-cpp/pull/2112 merges -- 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]
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
martinzink commented on code in PR #2153:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#discussion_r3022821925
##
extensions/gcp/controllerservices/GCPCredentialsControllerService.cpp:
##
@@ -18,34 +18,36 @@
#include "GCPCredentialsControllerService.h"
-#include "core/Resource.h"
#include "google/cloud/storage/client.h"
-#include "utils/ProcessorConfigUtils.h"
-#include "utils/file/FileUtils.h"
namespace org::apache::nifi::minifi::extensions::gcp {
-void GCPCredentialsControllerService::initialize() {
- setSupportedProperties(Properties);
+namespace {
+// TODO(MINIFICPP-2763) use utils::file::get_content instead
+std::string get_content(const std::filesystem::path& file_name) {
+ std::ifstream file(file_name, std::ifstream::binary);
+ std::string content((std::istreambuf_iterator(file)),
std::istreambuf_iterator());
+ return content;
+}
Review Comment:
its not regression so we dont care about that there is already a ticket to
refactor fileutils
##
extensions/gcp/controllerservices/GCPCredentialsControllerService.cpp:
##
@@ -18,34 +18,36 @@
#include "GCPCredentialsControllerService.h"
-#include "core/Resource.h"
#include "google/cloud/storage/client.h"
-#include "utils/ProcessorConfigUtils.h"
-#include "utils/file/FileUtils.h"
namespace org::apache::nifi::minifi::extensions::gcp {
-void GCPCredentialsControllerService::initialize() {
- setSupportedProperties(Properties);
+namespace {
+// TODO(MINIFICPP-2763) use utils::file::get_content instead
+std::string get_content(const std::filesystem::path& file_name) {
+ std::ifstream file(file_name, std::ifstream::binary);
+ std::string content((std::istreambuf_iterator(file)),
std::istreambuf_iterator());
+ return content;
+}
}
-std::shared_ptr
GCPCredentialsControllerService::createCredentialsFromJsonPath() const {
- const auto json_path = getProperty(JsonFilePath.name);
+std::shared_ptr
GCPCredentialsControllerService::createCredentialsFromJsonPath(api::core::ControllerServiceContext&
ctx) const {
+ const auto json_path = ctx.getProperty(JsonFilePath.name);
if (!json_path) {
logger_->log_error("Missing or invalid {}", JsonFilePath.name);
return nullptr;
}
- if (!utils::file::exists(*json_path)) {
+ if (std::error_code ec; !std::filesystem::exists(*json_path, ec) || ec) {
logger_->log_error("JSON file for GCP credentials '{}' does not exist",
*json_path);
return nullptr;
}
- return
google::cloud::MakeServiceAccountCredentials(utils::file::get_content(*json_path));
+ return google::cloud::MakeServiceAccountCredentials(get_content(*json_path));
Review Comment:
its not regression so we dont care about that there is already a ticket to
refactor fileutils
--
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]
Re: [PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
Copilot commented on code in PR #2153:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2153#discussion_r3022772389
##
extensions/gcp/controllerservices/GCPCredentialsControllerService.cpp:
##
@@ -18,34 +18,36 @@
#include "GCPCredentialsControllerService.h"
-#include "core/Resource.h"
#include "google/cloud/storage/client.h"
-#include "utils/ProcessorConfigUtils.h"
-#include "utils/file/FileUtils.h"
namespace org::apache::nifi::minifi::extensions::gcp {
-void GCPCredentialsControllerService::initialize() {
- setSupportedProperties(Properties);
+namespace {
+// TODO(MINIFICPP-2763) use utils::file::get_content instead
+std::string get_content(const std::filesystem::path& file_name) {
+ std::ifstream file(file_name, std::ifstream::binary);
+ std::string content((std::istreambuf_iterator(file)),
std::istreambuf_iterator());
+ return content;
+}
Review Comment:
get_content() does not validate that the file opened successfully or that
reading succeeded. If opening fails, it will return an empty string and
MakeServiceAccountCredentials() will be called with empty/partial content,
which can produce misleading failures. Add an explicit open/read failure check
and return nullptr (or an error status) from createCredentialsFromJsonPath()
when the file cannot be read.
##
extensions/gcp/controllerservices/GCPCredentialsControllerService.cpp:
##
@@ -18,34 +18,36 @@
#include "GCPCredentialsControllerService.h"
-#include "core/Resource.h"
#include "google/cloud/storage/client.h"
-#include "utils/ProcessorConfigUtils.h"
-#include "utils/file/FileUtils.h"
namespace org::apache::nifi::minifi::extensions::gcp {
-void GCPCredentialsControllerService::initialize() {
- setSupportedProperties(Properties);
+namespace {
+// TODO(MINIFICPP-2763) use utils::file::get_content instead
+std::string get_content(const std::filesystem::path& file_name) {
+ std::ifstream file(file_name, std::ifstream::binary);
+ std::string content((std::istreambuf_iterator(file)),
std::istreambuf_iterator());
+ return content;
+}
}
-std::shared_ptr
GCPCredentialsControllerService::createCredentialsFromJsonPath() const {
- const auto json_path = getProperty(JsonFilePath.name);
+std::shared_ptr
GCPCredentialsControllerService::createCredentialsFromJsonPath(api::core::ControllerServiceContext&
ctx) const {
+ const auto json_path = ctx.getProperty(JsonFilePath.name);
if (!json_path) {
logger_->log_error("Missing or invalid {}", JsonFilePath.name);
return nullptr;
}
- if (!utils::file::exists(*json_path)) {
+ if (std::error_code ec; !std::filesystem::exists(*json_path, ec) || ec) {
logger_->log_error("JSON file for GCP credentials '{}' does not exist",
*json_path);
return nullptr;
}
- return
google::cloud::MakeServiceAccountCredentials(utils::file::get_content(*json_path));
+ return google::cloud::MakeServiceAccountCredentials(get_content(*json_path));
Review Comment:
get_content() does not validate that the file opened successfully or that
reading succeeded. If opening fails, it will return an empty string and
MakeServiceAccountCredentials() will be called with empty/partial content,
which can produce misleading failures. Add an explicit open/read failure check
and return nullptr (or an error status) from createCredentialsFromJsonPath()
when the file cannot be read.
##
extensions/gcp/processors/GCSProcessor.cpp:
##
@@ -17,47 +17,43 @@
#include "GCSProcessor.h"
-#include "utils/ProcessorConfigUtils.h"
-
#include "../controllerservices/GCPCredentialsControllerService.h"
-#include "minifi-cpp/core/ProcessContext.h"
-#include "core/ProcessSession.h"
+#include "api/utils/ProcessorConfigUtils.h"
namespace gcs = ::google::cloud::storage;
namespace org::apache::nifi::minifi::extensions::gcp {
-std::shared_ptr
GCSProcessor::getCredentials(core::ProcessContext& context) const {
- auto gcp_credentials_controller_service =
utils::parseOptionalControllerService(context,
GCSProcessor::GCPCredentials, getUUID());
- if (gcp_credentials_controller_service) {
+std::shared_ptr GCSProcessor::getCredentials(const
api::core::ProcessContext& context) {
+ if (const auto gcp_credentials_controller_service =
api::utils::parseOptionalControllerService(context,
+ GCPCredentials)) {
return gcp_credentials_controller_service->getCredentials();
}
return nullptr;
}
-void GCSProcessor::onSchedule(core::ProcessContext& context,
core::ProcessSessionFactory&) {
- if (auto number_of_retries = utils::parseOptionalU64Property(context,
NumberOfRetries)) {
+MinifiStatus GCSProcessor::onScheduleImpl(api::core::ProcessContext& context) {
+ if (const auto number_of_retries =
api::utils::parseOptionalU64Property(context, NumberOfRetries)) {
retry_policy_ =
std::make_shared(gsl::narrow(*number_of_retries));
}
gcp_credentials_ = getCredentials(context);
if (!gcp_credentials_) {
-th
[PR] MINIFICPP-2765 Move GCP Extension to stable C API [nifi-minifi-cpp]
martinzink opened a new pull request, #2153: URL: https://github.com/apache/nifi-minifi-cpp/pull/2153 Thank you for submitting a contribution to Apache NiFi - MiNiFi C++. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### For all changes: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFICPP- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] Have you ensured that format looks appropriate for the output in which it is rendered? ### Note: Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible. -- 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]
