Skip to content

feat(agent): allow opting into agent mutation#4905

Draft
AustinAbro321 wants to merge 14 commits into
mainfrom
opt-into-mutation
Draft

feat(agent): allow opting into agent mutation#4905
AustinAbro321 wants to merge 14 commits into
mainfrom
opt-into-mutation

Conversation

@AustinAbro321
Copy link
Copy Markdown
Member

Description

This introduces a new flag to init --agent-mutation-mode with values opt-in and opt-out. The default value is opt-out but we will likely change it to opt-in in v1.0. New namespaces created by Zarf during package deploy are labeled with zarf.dev/agent: mutate, so resources are still automaticaly pointed to the zarf agent.

Resource labels always take priority so if the resource has zarf.dev/agent: mutate and the namespace has zarf.dev/agent: ignore the resource will be mutated. If the resource has zarf.dev/agent: ignore and the namespace has zarf.dev/agent: mutate the resource will be mutated.

To my surprise the podinfo-flux example works even when the agent is in opt-in mode. The reason for this is that even though Zarf doesn't deploy any resources to the intended deploy namespace (the flux resources are deployed to flux-system) the manifests.namespacefield is declared topodinfo-git` and so the mutate label is added

    manifests:
      - name: podinfo
        namespace: podinfo-git
        files:
          - git/podinfo-source.yaml
          - git/podinfo-kustomization.yaml

Related Issue

Fixes #4419

Checklist before merging

Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 86a5b6f
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/6a0b83f30bbd1800081e7533

@AustinAbro321 AustinAbro321 changed the title feat(init): opt into mutation feat(agent): allow opting into agent mutation May 15, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 64.33566% with 51 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/internal/agent/hooks/common.go 40.00% 8 Missing and 4 partials ⚠️
src/cmd/initialize.go 25.00% 9 Missing ⚠️
src/internal/agent/start.go 0.00% 9 Missing ⚠️
src/pkg/packager/deploy.go 0.00% 9 Missing ⚠️
src/internal/agent/operations/mutate.go 61.53% 5 Missing ⚠️
src/pkg/state/state.go 0.00% 2 Missing and 1 partial ⚠️
src/pkg/cluster/cluster.go 0.00% 2 Missing ⚠️
src/internal/packager/helm/post-render.go 0.00% 1 Missing ⚠️
src/internal/packager/template/template.go 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/internal/agent/hooks/argocd-application.go 72.22% <100.00%> (+1.01%) ⬆️
src/internal/agent/hooks/argocd-applicationset.go 87.50% <100.00%> (+9.72%) ⬆️
src/internal/agent/hooks/argocd-appproject.go 85.41% <100.00%> (+9.49%) ⬆️
src/internal/agent/hooks/argocd-repository.go 79.72% <100.00%> (+2.22%) ⬆️
src/internal/agent/hooks/flux-gitrepo.go 89.28% <100.00%> (+3.57%) ⬆️
src/internal/agent/hooks/flux-helmrepo.go 73.91% <100.00%> (+1.46%) ⬆️
src/internal/agent/hooks/flux-ocirepo.go 81.75% <100.00%> (+1.11%) ⬆️
src/internal/agent/hooks/pods.go 78.57% <100.00%> (+3.22%) ⬆️
src/pkg/cluster/namespace.go 22.44% <100.00%> (+5.05%) ⬆️
src/internal/packager/helm/post-render.go 10.50% <0.00%> (-0.04%) ⬇️
... and 8 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Add ability to invert the zarf control of namespaces

1 participant