Skip to content

Commit

Permalink
added cert-manager-install-crd flag
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonAleksandrov13 authored and arttor committed Jul 18, 2024
1 parent 31b2889 commit 60b13eb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/helmify/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (i *arrayFlags) Set(value string) error {
func ReadFlags() config.Config {
files := arrayFlags{}
result := config.Config{}
var h, help, version, crd , preservens bool
var h, help, version, crd, preservens bool
flag.BoolVar(&h, "h", false, "Print help. Example: helmify -h")
flag.BoolVar(&help, "help", false, "Print help. Example: helmify -help")
flag.BoolVar(&version, "version", false, "Print helmify version. Example: helmify -version")
Expand All @@ -65,6 +65,7 @@ func ReadFlags() config.Config {
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.CertManagerInstallCRD, "cert-manager-install-crd", true, "Allows the user to install cert-manager CRD. 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")
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (c *appContext) CreateHelm(stop <-chan struct{}) error {
default:
}
}
return c.output.Create(c.config.ChartDir, c.config.ChartName, c.config.Crd, c.config.CertManagerAsSubchart, c.config.CertManagerVersion , templates, filenames)
return c.output.Create(c.config.ChartDir, c.config.ChartName, c.config.Crd, c.config.CertManagerAsSubchart, c.config.CertManagerVersion, c.config.CertManagerInstallCRD, templates, filenames)
}

func (c *appContext) process(obj *unstructured.Unstructured) (helmify.Template, error) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type Config struct {
CertManagerAsSubchart bool
// CertManagerVersion sets cert-manager version in dependency
CertManagerVersion string
// CertManagerVersion enables installation of cert-manager CRD
CertManagerInstallCRD bool
// Files - directories or files with k8s manifests
Files []string
// FilesRecursively read Files recursively
Expand Down
8 changes: 4 additions & 4 deletions pkg/helm/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type output struct{}
// └── _helpers.tp # Helm default template partials
//
// Overwrites existing values.yaml and templates in templates dir on every run.
func (o output) Create(chartDir, chartName string, crd bool, certManagerAsSubchart bool, certManagerVersion string, templates []helmify.Template, filenames []string) error {
func (o output) Create(chartDir, chartName string, crd bool, certManagerAsSubchart bool, certManagerVersion string, certManagerInstallCRD bool, templates []helmify.Template, filenames []string) error {
err := initChartDir(chartDir, chartName, crd, certManagerAsSubchart, certManagerVersion)
if err != nil {
return err
Expand All @@ -56,7 +56,7 @@ func (o output) Create(chartDir, chartName string, crd bool, certManagerAsSubcha
return err
}
}
err = overwriteValuesFile(cDir, values, certManagerAsSubchart)
err = overwriteValuesFile(cDir, values, certManagerAsSubchart, certManagerInstallCRD)
if err != nil {
return err
}
Expand Down Expand Up @@ -101,9 +101,9 @@ func overwriteTemplateFile(filename, chartDir string, crd bool, templates []helm
return nil
}

func overwriteValuesFile(chartDir string, values helmify.Values, certManagerAsSubchart bool) error {
func overwriteValuesFile(chartDir string, values helmify.Values, certManagerAsSubchart bool, certManagerInstallCRD bool) error {
if certManagerAsSubchart {
_, err := values.Add(true, "certmanager", "installCRDs")
_, err := values.Add(certManagerInstallCRD, "certmanager", "installCRDs")
if err != nil {
return fmt.Errorf("%w: unable to add cert-manager.installCRDs", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/helmify/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Template interface {

// Output - converts Template into helm chart on disk.
type Output interface {
Create(chartName, chartDir string, Crd bool, certManagerAsSubchart bool, certManagerVersion string, templates []Template, filenames []string) error
Create(chartName, chartDir string, Crd bool, certManagerAsSubchart bool, certManagerVersion string, certManagerInstallCRD bool, templates []Template, filenames []string) error
}

// AppMetadata handle common information about K8s objects in the chart.
Expand Down

0 comments on commit 60b13eb

Please sign in to comment.