This is an automated email from the ASF dual-hosted git repository. szaszm pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 4431f959bca0a340ea357599c0df2327c7080ae5 Author: Gabor Gyimesi <[email protected]> AuthorDate: Wed Mar 12 22:13:31 2025 +0100 MINIFICPP-2508 Generate PARAMETER_PROVIDERS.md `minifi --docs` now generates PARAMETER_PROVIDERS.md in the same way as CONTROLLERS.md and PROCESSORS.md. Closes #1939 Signed-off-by: Marton Szasz <[email protected]> --- PARAMETER_PROVIDERS.md | 14 ++++++++------ libminifi/include/core/ParameterProvider.h | 2 +- .../EnvironmentVariableParameterProvider.h | 10 +++++++--- minifi-api/include/minifi-cpp/agent/agent_docs.h | 3 ++- minifi_main/AgentDocs.cpp | 22 ++++++++++++++++------ utils/include/agent/agent_docs.h | 8 ++++++++ 6 files changed, 42 insertions(+), 17 deletions(-) diff --git a/PARAMETER_PROVIDERS.md b/PARAMETER_PROVIDERS.md index fe6598a56..27daa655d 100644 --- a/PARAMETER_PROVIDERS.md +++ b/PARAMETER_PROVIDERS.md @@ -12,26 +12,28 @@ 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. --> + ## Table of Contents - [EnvironmentVariableParameterProvider](#EnvironmentVariableParameterProvider) + ## EnvironmentVariableParameterProvider ### Description -Fetches parameters from environment variables +Fetches parameters from environment variables. + +This provider generates a single Parameter Context with the name specified in the `Parameter Group Name` property, if it doesn't exist yet. The parameters generated match the name of the environment variables that are included. ### Properties -In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values. +In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language. | Name | Default Value | Allowable Values | Description | |---------------------------------------------|---------------|--------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **Sensitive Parameter Scope** | none | none<br/>all<br/>selected | Define which parameters are considered sensitive. If 'selected' is chosen, the 'Sensitive Parameter List' property must be set. | +| Sensitive Parameter List | | | List of sensitive parameters, if 'Sensitive Parameter Scope' is set to 'selected'. | | **Environment Variable Inclusion Strategy** | Include All | Include All<br/>Comma-Separated<br/>Regular Expression | Indicates how Environment Variables should be included | | Include Environment Variables | | | Specifies comma separated environment variable names or regular expression (depending on the Environment Variable Inclusion Strategy) that should be used to fetch environment variables. | | **Parameter Group Name** | | | The name of the parameter group that will be fetched. This indicates the name of the Parameter Context that may receive the fetched parameters. | - -### Generated Parameter Contexts - -This provider generates a single Parameter Context with the name specified in the `Parameter Group Name` property, if it doesn't exist yet. The parameters generated match the name of the environment variables that are included. diff --git a/libminifi/include/core/ParameterProvider.h b/libminifi/include/core/ParameterProvider.h index 62bdc253d..f756feb10 100644 --- a/libminifi/include/core/ParameterProvider.h +++ b/libminifi/include/core/ParameterProvider.h @@ -60,7 +60,7 @@ class ParameterProvider : public ConfigurableComponentImpl, public CoreComponent ~ParameterProvider() override = default; MINIFIAPI static constexpr auto SensitiveParameterScope = core::PropertyDefinitionBuilder<magic_enum::enum_count<SensitiveParameterScopeOptions>()>::createProperty("Sensitive Parameter Scope") - .withDescription("Define which parameters are considered sensitive, being either 'none', 'all' or 'selected'. If 'selected' is chosen, the 'Sensitive Parameter List' property must be set.") + .withDescription("Define which parameters are considered sensitive. If 'selected' is chosen, the 'Sensitive Parameter List' property must be set.") .isRequired(true) .withDefaultValue(magic_enum::enum_name(SensitiveParameterScopeOptions::none)) .withAllowedValues(magic_enum::enum_names<SensitiveParameterScopeOptions>()) diff --git a/libminifi/include/parameter-providers/EnvironmentVariableParameterProvider.h b/libminifi/include/parameter-providers/EnvironmentVariableParameterProvider.h index 4a374f77e..7ed3c6d4b 100644 --- a/libminifi/include/parameter-providers/EnvironmentVariableParameterProvider.h +++ b/libminifi/include/parameter-providers/EnvironmentVariableParameterProvider.h @@ -52,7 +52,9 @@ class EnvironmentVariableParameterProvider final : public core::ParameterProvide public: using ParameterProvider::ParameterProvider; - MINIFIAPI static constexpr const char* Description = "Fetches parameters from environment variables"; + MINIFIAPI static constexpr const char* Description = "Fetches parameters from environment variables.\n\n" + "This provider generates a single Parameter Context with the name specified in the `Parameter Group Name` property, if it doesn't exist yet. " + "The parameters generated match the name of the environment variables that are included."; MINIFIAPI static constexpr auto EnvironmentVariableInclusionStrategy = core::PropertyDefinitionBuilder<magic_enum::enum_count<EnvironmentVariableInclusionStrategyOptions>()>::createProperty("Environment Variable Inclusion Strategy") @@ -70,9 +72,11 @@ class EnvironmentVariableParameterProvider final : public core::ParameterProvide .isRequired(true) .build(); + MINIFIAPI static constexpr auto Properties = minifi::utils::array_cat(core::ParameterProvider::Properties, + std::to_array<core::PropertyReference>({EnvironmentVariableInclusionStrategy, IncludeEnvironmentVariables, ParameterGroupName})); + void initialize() override { - setSupportedProperties(minifi::utils::array_cat(core::ParameterProvider::Properties, - std::to_array<core::PropertyReference>({EnvironmentVariableInclusionStrategy, IncludeEnvironmentVariables, ParameterGroupName}))); + setSupportedProperties(Properties); } private: diff --git a/minifi-api/include/minifi-cpp/agent/agent_docs.h b/minifi-api/include/minifi-cpp/agent/agent_docs.h index ccbf100d5..21106cec1 100644 --- a/minifi-api/include/minifi-cpp/agent/agent_docs.h +++ b/minifi-api/include/minifi-cpp/agent/agent_docs.h @@ -52,10 +52,11 @@ struct ClassDescription { struct Components { std::vector<ClassDescription> processors_; std::vector<ClassDescription> controller_services_; + std::vector<ClassDescription> parameter_providers_; std::vector<ClassDescription> other_components_; [[nodiscard]] bool empty() const noexcept { - return processors_.empty() && controller_services_.empty() && other_components_.empty(); + return processors_.empty() && controller_services_.empty() && parameter_providers_.empty() && other_components_.empty(); } }; diff --git a/minifi_main/AgentDocs.cpp b/minifi_main/AgentDocs.cpp index 97a609dd4..eeb8afe96 100644 --- a/minifi_main/AgentDocs.cpp +++ b/minifi_main/AgentDocs.cpp @@ -17,13 +17,12 @@ #include "AgentDocs.h" +#include <algorithm> #include <iostream> #include <string> #include <utility> #include <vector> -#include "range/v3/algorithm.hpp" -#include "range/v3/action/transform.hpp" #include "range/v3/algorithm/lexicographical_compare.hpp" #include "range/v3/range/conversion.hpp" #include "range/v3/view/transform.hpp" @@ -32,11 +31,9 @@ #include "agent/agent_docs.h" #include "agent/agent_version.h" #include "core/Core.h" -#include "core/PropertyValue.h" #include "core/PropertyType.h" #include "core/Relationship.h" #include "TableFormatter.h" -#include "utils/file/FileUtils.h" #include "utils/StringUtils.h" namespace { @@ -190,6 +187,7 @@ namespace org::apache::nifi::minifi::docs { void AgentDocs::generate(const std::filesystem::path& docs_dir) { std::vector<std::pair<std::string, minifi::ClassDescription>> controller_services; std::vector<std::pair<std::string, minifi::ClassDescription>> processors; + std::vector<std::pair<std::string, minifi::ClassDescription>> parameter_providers; for (const auto &group : minifi::AgentBuild::getExtensions()) { struct Components descriptions = build_description_.getClassDescriptions(group); for (const auto &controller_service_description : descriptions.controller_services_) { @@ -198,9 +196,13 @@ void AgentDocs::generate(const std::filesystem::path& docs_dir) { for (const auto &processor_description : descriptions.processors_) { processors.emplace_back(extractClassName(processor_description.full_name_), processor_description); } + for (const auto& parameter_provider_description : descriptions.parameter_providers_) { + parameter_providers.emplace_back(extractClassName(parameter_provider_description.full_name_), parameter_provider_description); + } } - ranges::sort(controller_services, std::less(), lowercaseFirst); - ranges::sort(processors, std::less(), lowercaseFirst); + std::ranges::sort(controller_services, std::less(), lowercaseFirst); + std::ranges::sort(processors, std::less(), lowercaseFirst); + std::ranges::sort(parameter_providers, std::less(), lowercaseFirst); std::ofstream controllers_md(docs_dir / "CONTROLLERS.md"); writeHeader(controllers_md, controller_services); @@ -220,6 +222,14 @@ void AgentDocs::generate(const std::filesystem::path& docs_dir) { writeRelationships(processors_md, documentation); writeOutputAttributes(processors_md, documentation); } + + std::ofstream parameter_providers_md(docs_dir / "PARAMETER_PROVIDERS.md"); + writeHeader(parameter_providers_md, parameter_providers); + for (const auto& [name, documentation] : parameter_providers) { + writeName(parameter_providers_md, name); + writeDescription(parameter_providers_md, documentation); + writeProperties(parameter_providers_md, documentation); + } } } // namespace org::apache::nifi::minifi::docs diff --git a/utils/include/agent/agent_docs.h b/utils/include/agent/agent_docs.h index 2073b8e9c..a3282d2fd 100644 --- a/utils/include/agent/agent_docs.h +++ b/utils/include/agent/agent_docs.h @@ -80,6 +80,14 @@ void AgentDocs::createClassDescription(const std::string& group, const std::stri .class_properties_ = detail::toVector(Class::Properties), .supports_dynamic_properties_ = Class::SupportsDynamicProperties, }); + } else if constexpr (Type == ResourceType::ParameterProvider) { + components.parameter_providers_.push_back(ClassDescription{ + .type_ = Type, + .short_name_ = name, + .full_name_ = detail::classNameWithDots<Class>(), + .description_ = Class::Description, + .class_properties_ = detail::toVector(Class::Properties) + }); } else if constexpr (Type == ResourceType::DescriptionOnly) { components.other_components_.push_back(ClassDescription{ .type_ = Type,
