-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
commands/.../new,pkg/scaffold/helm: source chart flag for new projects #949
commands/.../new,pkg/scaffold/helm: source chart flag for new projects #949
Conversation
…art when creating new helm projects
…r helm CLI, add helm-chart-version flag, general cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall lgtm 👍 Left few suggestions and questions. Thanks for the detailed description of the PR!
…ic with --helm-chart
…atures and add CreateChart godoc comment
…phens in scaffolded chart name
dddd92d
to
b7c93b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, two nits.
@joelanford We can probably mention this feature in the CHANGELOG. Also the godocs for |
@hasbro17 Thanks! I'll go ahead and update the CLI doc so I can reference it in the CHANGELOG. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍
return s.Input, nil | ||
} | ||
|
||
const watchesYAMLTmpl = `--- | ||
- version: {{.Resource.Version}} | ||
group: {{.Resource.FullGroup}} | ||
kind: {{.Resource.Kind}} | ||
chart: /opt/helm/{{.HelmChartsDir}}/{{.Resource.LowerKind}} | ||
chart: /opt/helm/{{.HelmChartsDir}}/{{.ChartName}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question: Can ChartName
be allowed to contain uppercase chars? If yes, should we convert it to lowercase here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the chart name conventions, chart names SHOULD be lower case. However, the directory name MUST match the name in Chart.yaml. It seems the chart name case is not enforced, but the directory matching the name in Chart.yaml is.
$ helm create Test
Creating Test
$ helm package Test
Successfully packaged chart and saved it to: /tmp/Test-0.1.0.tgz
$ mv Test test
$ helm package test
Error: directory name (test) and Chart.yaml name (Test) must match
Since our code works by using Helm's packages to load the chart metadata, .ChartName
is effectively a read-only field provided by Helm. For that reason, I think I lean toward accepting what Helm gives us without modification. I would expect Helm to error out if a user tried to create or fetch an invalid chart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
operator-framework#949) * commands/operator-sdk/cmd/new,pkg/scaffold/helm: allow source helm chart when creating new helm projects * pkg/scaffold/helm/chart.go,commands/.../new.go: remove requirement for helm CLI, add helm-chart-version flag, general cleanup * commands/operator-sdk/cmd/new.go: improve helm-chart flags' help texts * commands/operator-sdk/cmd/new.go: comment to describe verifyFlags logic with --helm-chart * pkg/scaffold/helm/chart.go: revert to using r.LowerKind for scaffolded chart name * commands/.../new.go,pkg/scaffold/helm/chart.go: improve function signatures and add CreateChart godoc comment * pkg/scaffold/helm/chart.go: comment to explain decision not to use hyphens in scaffolded chart name * commands/operator-sdk/cmd/new.go: fix typo in help text * commands/operator-sdk/cmd/new.go: fix helm verify flags logic * pkg/scaffold/helm/chart.go: log tmpDir remove failure * CHANGELOG.md,doc,pkg/scaffold/helm: update docs * vendor: add necessary vendor dirs * CHANGELOG.md: moving updates to Unreleased section * Gopkg.lock,vendor: removing non-go
Description of the change:
This PR adds new flags to the
operator-sdk new
command that enable new Helm projects to be created from existing Helm charts.--helm-chart
- The chart to use when creating the project. Format is:<url>
<repo>/<chart_name>
<chart_name>
(with--helm-chart-repo
specified)/path/to/chart.tgz
(local chart archive)/path/to/chartDir
(local chart directory)--helm-chart-version
- The version of the chart to fetch from a remote repository.--helm-chart-repo
- The URL of the Helm chart repo in which to find the chart specified by--helm-chart
It also makes
--api-version
and--kind
optional if--helm-chart
is set, If left unset,--api-version
is defaulted tocharts.helm.k8s.io/v1alpha1
and--kind
is deduced from the fetched chart.Examples:
From a URL:
From stable repo:
From custom repo:
From local archive:
From a local directory:
Motivation for the change:
At the suggestion of @robszumski, I put together this PR to simplify the UX for building operators from existing Helm charts.
NOTE: This PR exposes only some of the flags that
helm fetch
does, so not all use cases are supported (e.g. users will not be able to authenticate to a remote repo using the operator-sdk CLI from this PR).