Skip to content

Conversation

@max-frank
Copy link
Contributor

@max-frank max-frank commented Jul 11, 2025

WHAT

Add dummy InitConfig to dummy test to force init config templating logic to run.
Fix the PluginConfigInfo InitiConfig templating to use exported function and directly call it.

This fix is necessary to for example test Falco rules using this pkg when plugins such as the k8smeta plugin are required as the plugin has a few required init config fields.

WHY

The go template logic requires the the field to be exported in order to be able to render it. For unexported fields we otherwise see an error like this:

template: :7:27: executing "" at <$p.initConfigString>: can't evaluate field initConfigString in type *falco.PluginConfigInfo

Similarly it seems that for struct functions evaluating to string the template pkg seems to treat them as fields. So using the call keyword results in the below error:

template: :7:20: executing "" at <call $p.InitConfigString>: error calling call: non-function $p.InitConfigString of type string

Thus fixing this requires exporting the function and removing the call keyword. This can be verified by running the TestDummy_PrometheusMetrics test while 1e56096 is checked out.

Signed-off-by: Maximilian Frank <mfrank@mercari.com>
Signed-off-by: Maximilian Frank <mfrank@mercari.com>
@max-frank max-frank force-pushed the fix-plugin-config-init-config-template branch from c89a1bb to cb069ae Compare July 11, 2025 00:43
Copy link
Member

@leogr leogr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thank you

/approve

@poiana
Copy link

poiana commented Jul 14, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: leogr, max-frank

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana
Copy link

poiana commented Jul 14, 2025

LGTM label has been added.

DetailsGit tree hash: 3c7367ee1fb25198adb34dc57f52bee21296a878

@poiana poiana merged commit da15d88 into falcosecurity:main Jul 14, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants