Skip to content

Commit

Permalink
Remove engine package
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Feb 6, 2024
1 parent 1f856f1 commit 5a90816
Show file tree
Hide file tree
Showing 80 changed files with 10,604 additions and 934 deletions.
11 changes: 7 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
golang.org/x/net v0.19.0
gomodules.xyz/encoding v0.0.7
gomodules.xyz/sets v0.2.1
helm.sh/helm/v3 v3.12.0
helm.sh/helm/v3 v3.14.0
k8s.io/api v0.29.0
k8s.io/apiextensions-apiserver v0.29.0
k8s.io/apimachinery v0.29.0
Expand Down Expand Up @@ -56,7 +56,7 @@ require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/Microsoft/hcsshim v0.11.0 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aws/aws-sdk-go-v2 v1.24.0 // indirect
Expand All @@ -76,7 +76,8 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/containerd/containerd v1.7.6 // indirect
github.com/containerd/containerd v1.7.11 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -92,6 +93,7 @@ require (
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fluxcd/pkg/apis/acl v0.1.0 // indirect
github.com/fluxcd/pkg/apis/kustomize v1.2.0 // indirect
github.com/fluxcd/pkg/apis/meta v1.2.0 // indirect
Expand Down Expand Up @@ -176,6 +178,7 @@ require (
github.com/xlab/treeprint v1.2.0 // indirect
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
Expand Down Expand Up @@ -214,4 +217,4 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

replace helm.sh/helm/v3 => github.com/x-helm/helm/v3 v3.12.0-dev.1.0.20240103183938-1cb0c3e11bb5
replace helm.sh/helm/v3 => github.com/x-helm/helm/v3 v3.12.0-dev.1.0.20240206205405-69d3cacf7454
16 changes: 10 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Microsoft/hcsshim v0.11.0 h1:7EFNIY4igHEXUdj1zXgAyU3fLc7QfOKHbkldRVTBdiM=
github.com/Microsoft/hcsshim v0.11.0/go.mod h1:OEthFdQv/AD2RAdzR6Mm1N1KPCztGKDurW1Z8b8VGMM=
github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7fz8=
github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w=
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
Expand Down Expand Up @@ -97,10 +97,12 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw=
github.com/containerd/containerd v1.7.6 h1:oNAVsnhPoy4BTPQivLgTzI9Oleml9l/+eYIDYXRCYo8=
github.com/containerd/containerd v1.7.6/go.mod h1:SY6lrkkuJT40BVNO37tlYTSnKJnP5AXBc0fhx0q+TJ4=
github.com/containerd/containerd v1.7.11 h1:lfGKw3eU35sjV0aG2eYZTiwFEY1pCzxdzicHP3SZILw=
github.com/containerd/containerd v1.7.11/go.mod h1:5UluHxHTX2rdvYuZ5OJTC5m/KJNs0Zs9wVoJm9zf5ZE=
github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM=
github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k=
github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand Down Expand Up @@ -477,8 +479,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8=
github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck=
github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY=
github.com/x-helm/helm/v3 v3.12.0-dev.1.0.20240103183938-1cb0c3e11bb5 h1:UVfx1BkkwZfLQZR9If0fqf1cRKHk+jka53+QYxtGkX4=
github.com/x-helm/helm/v3 v3.12.0-dev.1.0.20240103183938-1cb0c3e11bb5/go.mod h1:rffoolFdjcTCZzGZ++NFyxFNQV1ZlZb8i5v4/yRBNr4=
github.com/x-helm/helm/v3 v3.12.0-dev.1.0.20240206205405-69d3cacf7454 h1:4SmXMfNmVfwqMwIW/JBETsprTwExK2fLUU+m51JcS7o=
github.com/x-helm/helm/v3 v3.12.0-dev.1.0.20240206205405-69d3cacf7454/go.mod h1:2itvvDv2WSZXTllknfQo6j7u3VVgMAvm8POCDgYH424=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
Expand All @@ -499,6 +501,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0/go.mod h1:62CPTSry9QZtOaSsE3tOzhx6LzDhHnXJ6xHeMNNiM6Q=
go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs=
go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY=
go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE=
Expand Down
7 changes: 3 additions & 4 deletions pkg/action/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/storage/driver"
"k8s.io/cli-runtime/pkg/genericclioptions"
"kubepack.dev/lib-helm/pkg/engine"
"kubepack.dev/lib-helm/pkg/repo"
"kubepack.dev/lib-helm/pkg/values"
releasesapi "x-helm.dev/apimachinery/apis/releases/v1alpha1"
Expand Down Expand Up @@ -77,7 +76,7 @@ func (x *Deployer) WithRegistry(reg repo.IRegistry) *Deployer {
return x
}

func (x *Deployer) Run() (*release.Release, *engine.State, error) {
func (x *Deployer) Run() (*release.Release, error) {
// If a release does not exist, install it.
histClient := ha.NewHistory(&x.cfg.Configuration)
histClient.Max = 1
Expand Down Expand Up @@ -107,7 +106,7 @@ func (x *Deployer) Run() (*release.Release, *engine.State, error) {
})
return i.Run()
} else if err != nil {
return nil, nil, err
return nil, err
}

i := NewUpgraderForConfig(x.cfg)
Expand Down Expand Up @@ -137,7 +136,7 @@ func (x *Deployer) Run() (*release.Release, *engine.State, error) {

func (x *Deployer) Do() error {
var err error
x.result, _, err = x.Run()
x.result, err = x.Run()
return err
}

Expand Down
35 changes: 11 additions & 24 deletions pkg/action/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/klog/v2"
libchart "kubepack.dev/lib-helm/pkg/chart"
"kubepack.dev/lib-helm/pkg/engine"
"kubepack.dev/lib-helm/pkg/repo"
"kubepack.dev/lib-helm/pkg/values"
releasesapi "x-helm.dev/apimachinery/apis/releases/v1alpha1"
Expand Down Expand Up @@ -78,19 +77,19 @@ func (x *Installer) WithRegistry(reg repo.IRegistry) *Installer {
return x
}

func (x *Installer) Run() (*release.Release, *engine.State, error) {
func (x *Installer) Run() (*release.Release, error) {
if x.opts.Version == "" && x.opts.Devel {
debug("setting version to >0.0.0-0")
x.opts.Version = ">0.0.0-0"
}

if x.reg == nil {
return nil, nil, errors.New("x.reg is not set")
return nil, errors.New("x.reg is not set")
}

chrt, err := x.reg.GetChart(x.opts.ChartSourceFlatRef.ToAPIObject())
if err != nil {
return nil, nil, err
return nil, err
}
// TODO(tamal): Use constant
setAnnotations(chrt.Chart, "app.kubernetes.io/part-of", x.opts.PartOf)
Expand Down Expand Up @@ -118,7 +117,7 @@ func (x *Installer) Run() (*release.Release, *engine.State, error) {

validInstallableChart, err := libchart.IsChartInstallable(chrt.Chart)
if !validInstallableChart {
return nil, nil, err
return nil, err
}

if chrt.Metadata.Deprecated {
Expand All @@ -130,53 +129,41 @@ func (x *Installer) Run() (*release.Release, *engine.State, error) {
// As of Helm 2.4.0, this is treated as a stopping condition:
// https://github.com/helm/helm/issues/2209
if err := ha.CheckDependencies(chrt.Chart, req); err != nil {
return nil, nil, err
return nil, err
}
}

kc, err := NewUncachedClient(x.cfg.RESTClientGetter)
if err != nil {
return nil, nil, err
return nil, err
}

vals, err := x.opts.Options.MergeValues(chrt.Chart)
if err != nil {
return nil, nil, err
return nil, err
}
if data, ok := chrt.Chart.Metadata.Annotations["meta.x-helm.dev/editor"]; ok && data != "" {
var gvr metav1.GroupVersionResource
if err := json.Unmarshal([]byte(data), &gvr); err != nil {
return nil, nil, fmt.Errorf("failed to parse %s annotation %s", "meta.x-helm.dev/editor", data)
return nil, fmt.Errorf("failed to parse %s annotation %s", "meta.x-helm.dev/editor", data)
}
rls := types.NamespacedName{
Namespace: x.opts.Namespace,
Name: x.opts.ReleaseName,
}
if err := RefillMetadata(kc, chrt.Chart.Values, vals, gvr, rls); err != nil {
return nil, nil, err
return nil, err
}
}
// chartutil.CoalesceValues(chrt, chrtVals) will use vals to render templates
chrt.Chart.Values = map[string]interface{}{}

rls, err := cmd.Run(chrt.Chart, vals)
if err != nil {
return nil, nil, err
}
caps, _ := x.cfg.GetCapabilities()
return rls, &engine.State{
ReleaseName: rls.Name,
Namespace: x.opts.Namespace,
Chrt: rls.Chart,
Values: rls.Config,
IsUpgrade: false,
Capabilities: caps,
}, nil
return cmd.Run(chrt.Chart, vals)
}

func (x *Installer) Do() error {
var err error
x.result, _, err = x.Run()
x.result, err = x.Run()
return err
}

Expand Down
35 changes: 11 additions & 24 deletions pkg/action/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/klog/v2"
libchart "kubepack.dev/lib-helm/pkg/chart"
"kubepack.dev/lib-helm/pkg/engine"
"kubepack.dev/lib-helm/pkg/repo"
"kubepack.dev/lib-helm/pkg/values"
releasesapi "x-helm.dev/apimachinery/apis/releases/v1alpha1"
Expand Down Expand Up @@ -82,19 +81,19 @@ func (x *Upgrader) WithReleaseName(name string) *Upgrader {
return x
}

func (x *Upgrader) Run() (*release.Release, *engine.State, error) {
func (x *Upgrader) Run() (*release.Release, error) {
if x.opts.Version == "" && x.opts.Devel {
debug("setting version to >0.0.0-0")
x.opts.Version = ">0.0.0-0"
}

if x.reg == nil {
return nil, nil, errors.New("x.reg is not set")
return nil, errors.New("x.reg is not set")
}

chrt, err := x.reg.GetChart(x.opts.ChartSourceFlatRef.ToAPIObject())
if err != nil {
return nil, nil, err
return nil, err
}
// TODO(tamal): Use constant
setAnnotations(chrt.Chart, "app.kubernetes.io/part-of", x.opts.PartOf)
Expand All @@ -117,7 +116,7 @@ func (x *Upgrader) Run() (*release.Release, *engine.State, error) {

validInstallableChart, err := libchart.IsChartInstallable(chrt.Chart)
if !validInstallableChart {
return nil, nil, err
return nil, err
}

if chrt.Metadata.Deprecated {
Expand All @@ -129,53 +128,41 @@ func (x *Upgrader) Run() (*release.Release, *engine.State, error) {
// As of Helm 2.4.0, this is treated as a stopping condition:
// https://github.com/helm/helm/issues/2209
if err := ha.CheckDependencies(chrt.Chart, req); err != nil {
return nil, nil, err
return nil, err
}
}

kc, err := NewUncachedClient(x.cfg.RESTClientGetter)
if err != nil {
return nil, nil, err
return nil, err
}

vals, err := x.opts.Options.MergeValues(chrt.Chart)
if err != nil {
return nil, nil, err
return nil, err
}
if data, ok := chrt.Chart.Metadata.Annotations["meta.x-helm.dev/editor"]; ok && data != "" {
var gvr metav1.GroupVersionResource
if err := json.Unmarshal([]byte(data), &gvr); err != nil {
return nil, nil, fmt.Errorf("failed to parse %s annotation %s", "meta.x-helm.dev/editor", data)
return nil, fmt.Errorf("failed to parse %s annotation %s", "meta.x-helm.dev/editor", data)
}
rls := types.NamespacedName{
Namespace: x.opts.Namespace,
Name: x.releaseName,
}
if err := RefillMetadata(kc, chrt.Chart.Values, vals, gvr, rls); err != nil {
return nil, nil, err
return nil, err
}
}
// chartutil.CoalesceValues(chrt, chrtVals) will use vals to render templates
chrt.Chart.Values = map[string]interface{}{}

rls, err := cmd.Run(x.releaseName, chrt.Chart, vals)
if err != nil {
return nil, nil, err
}
caps, _ := x.cfg.GetCapabilities()
return rls, &engine.State{
ReleaseName: rls.Name,
Namespace: x.opts.Namespace,
Chrt: rls.Chart,
Values: rls.Config,
IsUpgrade: true,
Capabilities: caps,
}, nil
return cmd.Run(x.releaseName, chrt.Chart, vals)
}

func (x *Upgrader) Do() error {
var err error
x.result, _, err = x.Run()
x.result, err = x.Run()
return err
}

Expand Down
39 changes: 0 additions & 39 deletions pkg/engine/types.go

This file was deleted.

21 changes: 21 additions & 0 deletions vendor/github.com/containerd/containerd/images/labels.go

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

Loading

0 comments on commit 5a90816

Please sign in to comment.