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 — Certificate
pkg/processor/webhook/issuer.go — Issuer
pkg/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-cert
Running:
cat cert.yaml | helmify -preserve-ns mychart
Expected: 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.
Bug
The
-preserve-nsflag 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 sharedProcessObjMetahelper.Affected Processors
pkg/processor/webhook/cert.go— Certificatepkg/processor/webhook/issuer.go— Issuerpkg/processor/rbac/serviceaccount.go— ServiceAccountThese processors build their metadata using inline format strings that never include a
namespacefield, regardless of the-preserve-nsflag.All other processors (Deployment, DaemonSet, StatefulSet, ConfigMap, Secret, Service, Ingress, Role, RoleBinding, ClusterRoleBinding, Job, CronJob, PDB, PVC, and the default processor) use
ProcessObjMetawhich correctly respects-preserve-ns.Reproduction
Given a Certificate with an explicit namespace:
Running:
cat cert.yaml | helmify -preserve-ns mychartExpected: The generated template includes
namespace: my-systemin metadata.Actual: The namespace is silently dropped from the generated template.
Suggested Fix
Refactor Certificate, Issuer, and ServiceAccount processors to use
ProcessObjMetafor 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-subchartis set, webhook conditional wrapping when-add-webhook-optionis set) can be layered on after theProcessObjMetacall via string manipulation on the returned metadata string.