diff --git a/README.md b/README.md index ff0531c..7a46bc6 100644 --- a/README.md +++ b/README.md @@ -107,8 +107,9 @@ Usage: | -version | Print helmify version. | `helmify -version` | | -crd-dir | Place crds in their own folder per Helm 3 [docs](https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#method-1-let-helm-do-it-for-you). Caveat: CRDs templating is not supported by Helm. | `helmify -crd-dir` | | -image-pull-secrets | Allows the user to use existing secrets as imagePullSecrets | `helmify -image-pull-secrets` | +| -original-name | Use the object's original name instead of adding the chart's release name as the common prefix. | `helmify -original-name` | | -cert-manager-as-subchart | Allows the user to install cert-manager as a subchart | `helmify -cert-manager-as-subchart` | -| -cert-manager-version | Allows the user to specify cert-manager subchart version. Only useful with cert-manager-as-subchart. (default "v1.12.2") | `helmify -cert-manager-as-subchart` | +| -cert-manager-version | Allows the user to specify cert-manager subchart version. Only useful with cert-manager-as-subchart. (default "v1.12.2") | `helmify -cert-manager-as-subchart` | ## Status Supported k8s resources: - Deployment, DaemonSet, StatefulSet diff --git a/cmd/helmify/flags.go b/cmd/helmify/flags.go index 4b410d2..79b4c68 100644 --- a/cmd/helmify/flags.go +++ b/cmd/helmify/flags.go @@ -62,10 +62,11 @@ func ReadFlags() config.Config { flag.BoolVar(&result.VeryVerbose, "vv", false, "Enable very verbose output. Same as verbose but with DEBUG. Example: helmify -vv") flag.BoolVar(&crd, "crd-dir", false, "Enable crd install into 'crds' directory.\nWarning: CRDs placed in 'crds' directory will not be templated by Helm.\nSee https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#some-caveats-and-explanations\nExample: helmify -crd-dir") flag.BoolVar(&result.ImagePullSecrets, "image-pull-secrets", false, "Allows the user to use existing secrets as imagePullSecrets in values.yaml") - flag.BoolVar(&result.GenerateDefaults, "generate-defaults", false, "Allows the user to add empty placeholders for tipical customization options in values.yaml. Currently covers: topology constraints, node selectors, tolerances") + flag.BoolVar(&result.GenerateDefaults, "generate-defaults", false, "Allows the user to add empty placeholders for typical customization options in values.yaml. Currently covers: topology constraints, node selectors, tolerances") flag.BoolVar(&result.CertManagerAsSubchart, "cert-manager-as-subchart", false, "Allows the user to add cert-manager as a subchart") flag.StringVar(&result.CertManagerVersion, "cert-manager-version", "v1.12.2", "Allows the user to specify cert-manager subchart version. Only useful with cert-manager-as-subchart.") flag.BoolVar(&result.FilesRecursively, "r", false, "Scan dirs from -f option recursively") + flag.BoolVar(&result.OriginalName, "original-name", false, "Use the object's original name instead of adding the chart's release name as the common prefix.") flag.Var(&files, "f", "File or directory containing k8s manifests") flag.Parse() diff --git a/pkg/config/config.go b/pkg/config/config.go index 6de6cb7..cd6c3fc 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -34,6 +34,8 @@ type Config struct { Files []string // FilesRecursively read Files recursively FilesRecursively bool + // OriginalName retains Kubernetes resource's original name + OriginalName bool } func (c *Config) Validate() error { diff --git a/pkg/metadata/metadata.go b/pkg/metadata/metadata.go index 2237043..6039d95 100644 --- a/pkg/metadata/metadata.go +++ b/pkg/metadata/metadata.go @@ -82,6 +82,9 @@ func (a *Service) ChartName() string { // TemplatedName - converts object name to its Helm templated representation. // Adds chart fullname prefix from _helpers.tpl func (a *Service) TemplatedName(name string) string { + if a.conf.OriginalName { + return name + } _, contains := a.names[name] if !contains { // template only app objects