Skip to content

Upgrade helm-operator to Helm v3 #2080

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

Merged
merged 12 commits into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Changed

- Replace usage of `github.com/operator-framework/operator-sdk/pkg/restmapper.DynamicRESTMapper` with `sigs.k8s.io/controller-runtime/pkg/client/apiutil.DynamicRESTMapper`. ([#2309](https://github.com/operator-framework/operator-sdk/pull/2309))
- Upgraded Helm operator packages and base image from Helm v2 to Helm v3. Cluster state for pre-existing CRs using Helm v2-based operators will be automatically migrated to Helm v3's new release storage format, and existing releases may be upgraded due to changes in Helm v3's label injection. ([#2080](https://github.com/operator-framework/operator-sdk/pull/2080))

### Deprecated

Expand Down
18 changes: 12 additions & 6 deletions cmd/operator-sdk/new/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/operator-framework/operator-sdk/internal/scaffold/input"
"github.com/operator-framework/operator-sdk/internal/util/projutil"

"github.com/ghodss/yaml"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -311,11 +312,16 @@ func doHelmScaffold() error {

resource, chart, err := helm.CreateChart(cfg.AbsProjectPath, createOpts)
if err != nil {
return fmt.Errorf("failed to create helm chart: %s", err)
return fmt.Errorf("failed to create helm chart: %w", err)
}

valuesPath := filepath.Join("<project_dir>", helm.HelmChartsDir, chart.GetMetadata().GetName(), "values.yaml")
crSpec := fmt.Sprintf("# Default values copied from %s\n\n%s", valuesPath, chart.GetValues().GetRaw())
valuesPath := filepath.Join("<project_dir>", helm.HelmChartsDir, chart.Name(), "values.yaml")

rawValues, err := yaml.Marshal(chart.Values)
if err != nil {
return fmt.Errorf("failed to get raw chart values: %w", err)
}
crSpec := fmt.Sprintf("# Default values copied from %s\n\n%s", valuesPath, rawValues)

roleScaffold := helm.DefaultRoleScaffold
if k8sCfg, err := config.GetConfig(); err != nil {
Expand All @@ -331,7 +337,7 @@ func doHelmScaffold() error {
&helm.Dockerfile{},
&helm.WatchesYAML{
Resource: resource,
ChartName: chart.GetMetadata().GetName(),
ChartName: chart.Name(),
},
&scaffold.ServiceAccount{},
&roleScaffold,
Expand All @@ -344,11 +350,11 @@ func doHelmScaffold() error {
},
)
if err != nil {
return fmt.Errorf("new helm scaffold failed: (%v)", err)
return fmt.Errorf("new helm scaffold failed: %w", err)
}

if err := scaffold.UpdateRoleForResource(resource, cfg.AbsProjectPath); err != nil {
return fmt.Errorf("failed to update the RBAC manifest for resource (%v, %v): (%v)", resource.APIVersion, resource.Kind, err)
return fmt.Errorf("failed to update the RBAC manifest for resource (%v, %v): %w", resource.APIVersion, resource.Kind, err)
}
return nil
}
Expand Down
Loading