Skip to content

Ability to disable hooks #726

@verdel

Description

@verdel

We want to use a universal shell-operator image that contains a set of hooks. In different Kubernetes clusters, different sets of hooks need to be activated.

This can be done, for example, through environment variables, but if we return an empty JSON object or exit code 0 when calling a hook with the --config flag, we get the following error:

hook::config() {
if [ "$ENABLE_HOOK_CUSTOM_LOGGING_FLOW" == "true" ]; then
  cat <<EOF
{
  "configVersion":"v1",
  "kubernetes": [
    {
      "apiVersion": "logging.banzaicloud.io/v1beta1",
      "kind": "flow",
      "executeHookOnEvent": [
        "Added",
        "Modified"
      ],
    }
  ]
}
EOF
else
  exit 0
fi
}
{"level":"fatal","logger":"shell-operator","msg":"assemble shell operator","error":"initialize HookManager fail: MAIN Fatal: initialize hook manager: creating hook '100-custom-logging-flow/add_or_update_flow.sh': load hook '100-custom-logging-flow/add_or_update_flow.sh' config: 1 error occurred:\n\t*  should have at least 1 property\n\n\nhook --config output: ","time":"2025-03-09T11:50:25Z"}

Could a parameter like enabled be added in the hook-level settings to allow disabling specific hooks?

A similar question is present in the discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions