Skip to content

Conversation

@RottenRat
Copy link
Contributor

@RottenRat RottenRat commented Jan 21, 2026

Added support for application hooks so that app subscriptions can monitor Kubernetes resources only in their namespace, and also performed a minor refactoring of configurations/interfaces for this purpose.

  • Introduced a separate config type for application hooks: switched hook config from HookConfig to ApplicationHookConfig, and KubernetesConfig to ApplicationKubernetesConfig
  • Created a common config interface pkg.Config and migrated places that previously hard-coded *pkg.HookConfig to work through this interface:
  • Executor.Config() now returns pkg.Config (for both module and app executors).
  • In several places in the controller, the transition from direct access to hook.Config().Metadata... to calls via getters and setters.
  • Updated the config mapping to gohook format (remapHookConfigToHookConfig) so that it correctly handles both types of hooks.

Tests:
Command to check triggers:
kubectl run trigger --image=%image-name% --restrat=Never -n %app-ns% --labels=[trigger.io/trigger=trigger](http://trigger.io/trigger=trigger)
Before:
Start:

...
values:
  internal:
    triggers: []
...

Run trigger of other ns:

...
values:
  internal:
    triggers: 
      - trigger
...

Run trigger of app ns:

...
values:
  internal:
    triggers: 
      - trigger
...

After:
Start:

...
values:
  internal:
    triggers: []
...

Run trigger of other ns:

...
values:
  internal:
    triggers: []
...

Run trigger of app ns:

...
values:
  internal:
    triggers: 
      - trigger
...

ipaqsa and others added 4 commits January 17, 2026 23:07
Signed-off-by: Stepan Paksashvili <[email protected]>
Signed-off-by: Stepan Paksashvili <[email protected]>
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Stepan Paksashvili <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
@RottenRat RottenRat self-assigned this Jan 21, 2026
@RottenRat RottenRat changed the base branch from main to feature/application-hooks January 21, 2026 14:20
@ipaqsa ipaqsa requested review from ipaqsa and ldmonster January 21, 2026 18:18
Base automatically changed from feature/application-hooks to main January 22, 2026 12:19
Sinelnikov Michail and others added 16 commits January 22, 2026 15:59
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
fix
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
@ipaqsa ipaqsa changed the title [deckhouse/app] App subscriptions can only monitor resources in their namespace app subscriptions can only monitor resources in their namespace Jan 30, 2026
@ipaqsa ipaqsa changed the title app subscriptions can only monitor resources in their namespace [feature] app subscriptions can only monitor resources in their namespace Jan 30, 2026
@ipaqsa ipaqsa added enhancement New feature or request go Pull requests that update go code labels Jan 30, 2026
@RottenRat RottenRat marked this pull request as ready for review February 2, 2026 07:51
Signed-off-by: Sinelnikov Michail <[email protected]>
@ldmonster ldmonster requested a review from LazarenkoA February 2, 2026 09:37
Signed-off-by: Stepan Paksashvili <[email protected]>
Signed-off-by: Stepan Paksashvili <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces support for application-specific hooks that are automatically scoped to their namespace. It achieves this by creating separate configuration types (ApplicationHookConfig and ApplicationKubernetesConfig) that don't include NamespaceSelector, relying on external components (shell-operator/addon-operator) to inject namespace filtering based on the APPLICATION_NAMESPACE environment variable.

Changes:

  • Introduced ApplicationHookConfig and ApplicationKubernetesConfig types for application hooks that omit namespace selection capabilities
  • Refactored hook configuration handling to support both module and application hooks through a common Config type constraint interface
  • Updated Executor.Config() to return any instead of typed pointer to accommodate both config types
  • Added conversion functions to translate both module and application configs to shell-operator format

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
pkg/hook.go Adds ApplicationHookConfig and ApplicationKubernetesConfig types with validation; removes kebabCaseRegexp validation and NameSelector/NamespaceSelector validation methods
pkg/registry/registry.go Updates hook registration to handle both module and application hooks with generic type parameters; adds validation and type-switching logic
internal/executor/executor.go Changes Config() method to return any instead of typed pointer; adds documentation
internal/executor/module.go Updates to use generic Hook type with both config and input type parameters
internal/executor/application.go Updates to use generic Hook type for application hooks
internal/executor/registry/registry.go Updates method signatures to use new generic Hook types
internal/executor/executor_test.go Updates test to use new generic Hook type signature
internal/controller/controller.go Adds helper functions for metadata extraction and config conversion; implements separate conversion for application vs module kubernetes configs
pkg/registry/registry_test.go Adds test for application hook registration
examples/single-file-app-example/hooks/main.go Updates example to use ApplicationHookConfig and ApplicationKubernetesConfig

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sinelnikov Michail added 4 commits February 11, 2026 10:17
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
Signed-off-by: Sinelnikov Michail <[email protected]>
@ldmonster ldmonster merged commit dc921b1 into main Feb 12, 2026
7 checks passed
@ldmonster ldmonster deleted the feature/application-hooks-namespace-fix branch February 12, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants