Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Shipper uses Helm v3
Browse files Browse the repository at this point in the history
This commit bumps Helm rendering engine version to v3 from v2. The
new verison is a major update and therefore is partially incompatible
with the former head version. This commit brings the version to the
latest stable one.

Signed-off-by: Oleg Sidorov <[email protected]>
  • Loading branch information
Oleg Sidorov authored and Oleg Sidorov committed Feb 3, 2020
1 parent 9234121 commit be20322
Show file tree
Hide file tree
Showing 1,480 changed files with 225,350 additions and 52,360 deletions.
55 changes: 13 additions & 42 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,25 @@ go 1.13
require (
cloud.google.com/go v0.39.0 // indirect
github.com/Masterminds/semver v1.4.0
github.com/Masterminds/sprig v2.14.1+incompatible // indirect
github.com/OneOfOne/xxhash v1.2.5 // indirect
github.com/aokoli/goutils v1.0.1 // indirect
github.com/cespare/xxhash v1.1.0
github.com/evanphx/json-patch v4.2.0+incompatible // indirect
github.com/gobwas/glob v0.2.2 // indirect
github.com/gogo/protobuf v1.2.1 // indirect
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/google/go-cmp v0.3.0
github.com/google/gofuzz v1.0.0 // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gophercloud/gophercloud v0.1.0 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/huandu/xstrings v0.0.0-20171208101919-37469d0c81a7 // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/json-iterator/go v1.1.6 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/mitchellh/go-homedir v1.0.0
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/google/go-cmp v0.3.1
github.com/mitchellh/go-homedir v1.1.0
github.com/pmezard/go-difflib v1.0.0
github.com/prometheus/client_golang v0.9.3
github.com/satori/go.uuid v1.2.0 // indirect
github.com/prometheus/client_golang v1.2.1
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 // indirect
github.com/spf13/cobra v0.0.5
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522 // indirect
golang.org/x/net v0.0.0-20190603091049-60506f45cf65 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
golang.org/x/tools v0.0.0-20190603231351-8aaa1484dc10 // indirect
google.golang.org/appengine v1.6.0 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/api v0.0.0-20190602205700-9b8cae951d65
k8s.io/apiextensions-apiserver v0.0.0-20190602131520-451a9c13a3c8
k8s.io/apimachinery v0.0.0-20190602183612-63a6072eb563
k8s.io/client-go v0.0.0-20190602130007-e65ca70987a6
k8s.io/code-generator v0.0.0-20190531131525-17d711082421
k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a // indirect
k8s.io/helm v2.8.0+incompatible
k8s.io/klog v0.3.2
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 // indirect
k8s.io/utils v0.0.0-20190529001817-6999998975a7 // indirect
helm.sh/helm/v3 v3.0.3
k8s.io/api v0.0.0-20191016110408-35e52d86657a
k8s.io/apiextensions-apiserver v0.0.0-20191016113550-5357c4baaf65
k8s.io/apimachinery v0.0.0-20191004115801-a2eda9f80ab8
k8s.io/client-go v0.0.0-20191016111102-bec269661e48
k8s.io/code-generator v0.0.0-20191004115455-8e001e5d1894
k8s.io/klog v1.0.0
sigs.k8s.io/yaml v1.1.0
)

replace k8s.io/apimachinery v0.0.0-20190602113612-63a6072eb563 => k8s.io/apimachinery v0.0.0-20190602183612-63a6072eb563

replace github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309
431 changes: 320 additions & 111 deletions go.sum

Large diffs are not rendered by default.

52 changes: 21 additions & 31 deletions pkg/chart/chart.go
Original file line number Diff line number Diff line change
@@ -1,57 +1,47 @@
package chart

import (
"fmt"
"regexp"
"sort"
"strings"

"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/engine"
helmchart "k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/timeconv"

shipper "github.com/bookingcom/shipper/pkg/apis/shipper/v1alpha1"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/engine"
)

// Render renders a chart, with the given values. It returns a list of rendered
// Kubernetes objects.
func Render(chart *helmchart.Chart, name, ns string, shipperValues *shipper.ChartValues) ([]string, error) {
chartConfig := &helmchart.Config{}
if shipperValues != nil {
values := chartutil.Values(*shipperValues)

var yaml string
yaml, err := values.YAML()
if err != nil {
return nil, err
}
chartConfig = &helmchart.Config{Raw: yaml}
func Render(chart *chart.Chart, name, ns string, shipperValues *shipper.ChartValues) ([]string, error) {
options := chartutil.ReleaseOptions{
Name: name,
Namespace: ns,
IsInstall: true,
}

if err := chartutil.ProcessRequirementsEnabled(chart, chartConfig); err != nil {
return nil, err
var values map[string]interface{}
if shipperValues != nil {
values = *shipperValues
}

if err := chartutil.ProcessRequirementsImportValues(chart); err != nil {
renderValues, err := chartutil.ToRenderValues(
chart,
values,
options,
chartutil.DefaultCapabilities,
)
if err != nil {
return nil, err
}

chartOptions := chartutil.ReleaseOptions{
Name: name,
Time: timeconv.Now(),
Namespace: ns,
IsInstall: true,
}

helmValues, err := chartutil.ToRenderValues(chart, chartConfig, chartOptions)
if err != nil {
if err := chartutil.ProcessDependencies(chart, renderValues); err != nil {
return nil, err
}

rendered, err := engine.New().Render(chart, helmValues)
rendered, err := engine.Render(chart, renderValues)
if err != nil {
return nil, fmt.Errorf("could not render the chart: %s", err)
return nil, err
}

objects := CollectObjects(rendered)
Expand Down
5 changes: 2 additions & 3 deletions pkg/chart/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"reflect"
"testing"

"k8s.io/helm/pkg/chartutil"

shipper "github.com/bookingcom/shipper/pkg/apis/shipper/v1alpha1"
"helm.sh/helm/v3/pkg/chart/loader"
)

func TestRender(t *testing.T) {
Expand All @@ -18,7 +17,7 @@ func TestRender(t *testing.T) {
t.Fatal(err)
}

chart, err := chartutil.LoadArchive(chartFile)
chart, err := loader.LoadArchive(chartFile)
if err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/chart/repo/handlers.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package repo

import (
helmchart "k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/repo"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/repo"

shipper "github.com/bookingcom/shipper/pkg/apis/shipper/v1alpha1"
errors "github.com/bookingcom/shipper/pkg/errors"
)

type ChartVersionResolver func(*shipper.Chart) (*repo.ChartVersion, error)

type ChartFetcher func(*shipper.Chart) (*helmchart.Chart, error)
type ChartFetcher func(*shipper.Chart) (*chart.Chart, error)

func ResolveChartVersionFunc(c *Catalog) ChartVersionResolver {
return func(chartspec *shipper.Chart) (*repo.ChartVersion, error) {
Expand All @@ -24,7 +24,7 @@ func ResolveChartVersionFunc(c *Catalog) ChartVersionResolver {
}

func FetchChartFunc(c *Catalog) ChartFetcher {
return func(chartspec *shipper.Chart) (*helmchart.Chart, error) {
return func(chartspec *shipper.Chart) (*chart.Chart, error) {
repo, err := c.CreateRepoIfNotExist(chartspec.RepoURL)
if err != nil {
return nil, err
Expand Down
14 changes: 7 additions & 7 deletions pkg/chart/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"sigs.k8s.io/yaml"

"github.com/Masterminds/semver"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/repo"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/repo"
"k8s.io/klog"

shipper "github.com/bookingcom/shipper/pkg/apis/shipper/v1alpha1"
Expand Down Expand Up @@ -330,7 +330,7 @@ func loadChartData(data []byte) (*chart.Chart, error) {
return nil, fmt.Errorf("no body content")
}

return chartutil.LoadArchive(bytes.NewBuffer(data))
return loader.LoadArchive(bytes.NewBuffer(data))

}

Expand All @@ -344,7 +344,7 @@ func url2name(v string) string {
}

func chart2file(cv *repo.ChartVersion) string {
name, version := cv.GetName(), cv.GetVersion()
name, version := cv.Name, cv.Version
name = strings.Replace(name, "/", "-", -1)
version = strings.Replace(version, "/", "-", -1)

Expand All @@ -356,8 +356,8 @@ func newChart(cv *repo.ChartVersion) (*shipper.Chart, error) {
return nil, fmt.Errorf("chart version is missing URLs")
}
return &shipper.Chart{
Name: cv.GetName(),
Version: cv.GetVersion(),
Name: cv.Name,
Version: cv.Version,
RepoURL: cv.URLs[0],
}, nil
}
7 changes: 7 additions & 0 deletions pkg/client/clientset/versioned/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions pkg/controller/application/application_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"time"

"github.com/Masterminds/semver"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/repo"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait"
kubetesting "k8s.io/client-go/testing"
"k8s.io/client-go/tools/record"
helmchart "k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/repo"

shipper "github.com/bookingcom/shipper/pkg/apis/shipper/v1alpha1"
shipperrepo "github.com/bookingcom/shipper/pkg/chart/repo"
Expand Down Expand Up @@ -51,7 +51,7 @@ var localResolveChartVersion = func(chartspec *shipper.Chart) (*repo.ChartVersio
}
}
return &repo.ChartVersion{
Metadata: &helmchart.Metadata{
Metadata: &chart.Metadata{
Name: chartspec.Name,
Version: resolvedVer,
},
Expand Down Expand Up @@ -1185,9 +1185,6 @@ func newApplication(name string) *shipper.Application {
Strategy: &vanguard,
},
},
Status: shipper.ApplicationStatus{
History: []string{},
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/installation/installation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"sort"
"time"

"helm.sh/helm/v3/pkg/chart"
corev1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -18,7 +19,6 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/klog"

shipper "github.com/bookingcom/shipper/pkg/apis/shipper/v1alpha1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/installation/testdata/service-baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: reviews-api
chart: reviews-api-0.0.1
release: reviews-api
heritage: Tiller
heritage: Helm
shipper-lb: production
shipper-app: reviews-api
shipper-owned-by: reviews-api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: reviews-api
chart: reviews-api-0.1.0
release: 0.0.1
heritage: Tiller
heritage: Helm
ownerReferences:
- uid: deadbeef
name: 0.0.1-reviews-api-anchor
Expand All @@ -21,4 +21,4 @@ spec:
name: nginx
selector:
app: reviews-api
release: 0.0.1
release: 0.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
shipper-lb: production
shipper-app: nginx
shipper-owned-by: nginx
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: nginx
app.kubernetes.io/instance: nginx
helm.sh/chart: nginx-0.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Service
metadata:
name: nginx-staging
labels:
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: nginx
app.kubernetes.io/instance: nginx
helm.sh/chart: nginx-0.1.0
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/installation/testdata/service-no-owners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: reviews-api
chart: reviews-api-0.1.0
release: 0.0.1
heritage: Tiller
heritage: Helm
spec:
type: ClusterIP
ports:
Expand All @@ -16,4 +16,4 @@ spec:
name: nginx
selector:
app: reviews-api
release: 0.0.1
release: 0.0.1
6 changes: 3 additions & 3 deletions pkg/controller/installation/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"regexp"
"sort"

"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/proto/hapi/chart"

shipper "github.com/bookingcom/shipper/pkg/apis/shipper/v1alpha1"
shippertesting "github.com/bookingcom/shipper/pkg/testing"
Expand Down Expand Up @@ -81,7 +81,7 @@ var localFetchChart = func(chartspec *shipper.Chart) (*chart.Chart, error) {
return nil, err
}
buf := bytes.NewBuffer(data)
return chartutil.LoadArchive(buf)
return loader.LoadArchive(buf)
}

func loadService(variant string) *corev1.Service {
Expand Down
Loading

0 comments on commit be20322

Please sign in to comment.