-
Notifications
You must be signed in to change notification settings - Fork 161
Description
Bug
The -preserve-ns flag is supposed to preserve the original namespace in generated Helm templates, but several processors silently drop the namespace because they use hardcoded templates instead of the shared ProcessObjMeta helper.
Affected Processors
pkg/processor/webhook/cert.go— Certificatepkg/processor/webhook/issuer.go— Issuerpkg/processor/rbac/serviceaccount.go— ServiceAccount
These processors build their metadata using inline format strings that never include a namespace field, regardless of the -preserve-ns flag.
All other processors (Deployment, DaemonSet, StatefulSet, ConfigMap, Secret, Service, Ingress, Role, RoleBinding, ClusterRoleBinding, Job, CronJob, PDB, PVC, and the default processor) use ProcessObjMeta which correctly respects -preserve-ns.
Reproduction
Given a Certificate with an explicit namespace:
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: my-cert
namespace: my-system
spec:
dnsNames:
- my-service.my-system.svc
issuerRef:
kind: Issuer
name: my-issuer
secretName: my-certRunning:
cat cert.yaml | helmify -preserve-ns mychartExpected: The generated template includes namespace: my-system in metadata.
Actual: The namespace is silently dropped from the generated template.
Suggested Fix
Refactor Certificate, Issuer, and ServiceAccount processors to use ProcessObjMeta for metadata generation instead of hardcoded templates. This would give them namespace, label, and annotation handling for free and ensure consistency with all other processors.
The cert-manager-specific behavior (helm hook annotations when -cert-manager-as-subchart is set, webhook conditional wrapping when -add-webhook-option is set) can be layered on after the ProcessObjMeta call via string manipulation on the returned metadata string.