Skip to content

Commit

Permalink
MINIFICPP-2508 Generate PARAMETER_PROVIDERS.md
Browse files Browse the repository at this point in the history
`minifi --docs` now generates PARAMETER_PROVIDERS.md in the same way as
CONTROLLERS.md and PROCESSORS.md.
  • Loading branch information
fgerlits committed Mar 3, 2025
1 parent 2228878 commit 6b14de2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 17 deletions.
14 changes: 8 additions & 6 deletions PARAMETER_PROVIDERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 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. The parameters generated match the name of the environment variables that are included.
2 changes: 1 addition & 1 deletion libminifi/include/core/ParameterProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ParameterProvider : public ConfigurableComponentImpl, public CoreComponent
ParameterProvider &operator=(const ParameterProvider &other) = delete;

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>())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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. "
"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")
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion minifi-api/include/minifi-cpp/agent/agent_docs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

Expand Down
22 changes: 16 additions & 6 deletions minifi_main/AgentDocs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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_) {
Expand All @@ -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);
Expand All @@ -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
8 changes: 8 additions & 0 deletions utils/include/agent/agent_docs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6b14de2

Please sign in to comment.