Skip to content

feat: add profile reload expression to filter reload events#108

Merged
MacroPower merged 1 commit intomainfrom
feat/skip-reload-expr
Aug 9, 2025
Merged

feat: add profile reload expression to filter reload events#108
MacroPower merged 1 commit intomainfrom
feat/skip-reload-expr

Conversation

@MacroPower
Copy link
Copy Markdown
Owner

@MacroPower MacroPower commented Aug 9, 2025

ref: #84

This PR adds a new reload field to profiles that allows users to filter reload events using CEL expressions:

profiles:
  helm:
    command: helm
    args: [template, .]
    source: >-
      files.filter(f, pathExt(f) in [".yaml", ".yml", ".tpl"])
    reload: >-
      fs.event.has(fs.WRITE) &&
      render.stage < render.STAGE_POST_RENDER &&
      render.result != render.RESULT_CANCEL

If no reload expression is provided, profiles will continue to work as before (reloading on all events). Note: existing path functions are also available.

New CEL EnvOptions

New CEL functions and constants are available for these expressions.

File System Variables:

  • file - The subject of the event.
  • fs.event - The triggering file system event.

File System Functions:

  • has(event, flag...): Check if file system events contain specific flags

File System Constants:

  • fs.CREATE, fs.WRITE, fs.REMOVE, fs.RENAME, fs.CHMOD: Event type constants

Render Status Variables:

  • render.stage - The current render stage.
  • render.result - The last render result.

Render Status Constants:

  • render.STAGE_*: Track current render stage (NONE, PRE_RENDER, RENDER, POST_RENDER)
  • render.RESULT_*: Track last render result (NONE, OK, ERROR, CANCEL)

Example Use Cases

# Skip reloads for certain files
reload: >-
  pathBase(file) != "kustomization.yaml"

# Only reload on write events
reload: >-
  fs.event.has(fs.WRITE)

# Prevent reloads during active rendering
reload: >-
  render.stage < render.STAGE_RENDER

# Skip reloads if last operation was canceled
reload: >-
  render.result != render.RESULT_CANCEL

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 9, 2025

Codecov Report

❌ Patch coverage is 76.12732% with 90 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.77%. Comparing base (b660df4) to head (3640ab4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/expr/lib.go 77.83% 32 Missing and 15 partials ⚠️
pkg/command/runner.go 25.92% 16 Missing and 4 partials ⚠️
pkg/profile/profile.go 80.00% 11 Missing and 4 partials ⚠️
pkg/profile/status.go 93.75% 1 Missing and 2 partials ⚠️
pkg/rule/rule.go 62.50% 2 Missing and 1 partial ⚠️
pkg/expr/expr.go 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #108      +/-   ##
==========================================
+ Coverage   54.35%   54.77%   +0.42%     
==========================================
  Files          43       45       +2     
  Lines        5365     5586     +221     
==========================================
+ Hits         2916     3060     +144     
- Misses       2357     2413      +56     
- Partials       92      113      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MacroPower MacroPower force-pushed the feat/skip-reload-expr branch 4 times, most recently from 5c92efa to 1b5d654 Compare August 9, 2025 15:32
@MacroPower MacroPower force-pushed the feat/skip-reload-expr branch from 1b5d654 to 3640ab4 Compare August 9, 2025 15:33
@MacroPower MacroPower marked this pull request as ready for review August 9, 2025 15:35
@MacroPower MacroPower enabled auto-merge (squash) August 9, 2025 15:36
@MacroPower MacroPower merged commit a28d8c0 into main Aug 9, 2025
5 checks passed
@MacroPower MacroPower deleted the feat/skip-reload-expr branch August 9, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant