diff --git a/go.mod b/go.mod index 272b497b..eca6f351 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.11.1 github.com/tidwall/gjson v1.18.0 - github.com/werf/nelm v1.12.3 + github.com/werf/nelm v1.16.2-0.20251106110659-fb3b42bd8fba google.golang.org/protobuf v1.36.5 gopkg.in/alecthomas/kingpin.v2 v2.2.6 gopkg.in/yaml.v3 v3.0.1 @@ -43,12 +43,13 @@ require ( sigs.k8s.io/yaml v1.4.0 ) +require github.com/go-openapi/swag/loading v0.25.1 + require ( github.com/go-openapi/swag/conv v0.25.1 // indirect github.com/go-openapi/swag/fileutils v0.25.1 // indirect github.com/go-openapi/swag/jsonname v0.25.1 // indirect github.com/go-openapi/swag/jsonutils v0.25.1 // indirect - github.com/go-openapi/swag/loading v0.25.1 // indirect github.com/go-openapi/swag/mangling v0.25.1 // indirect github.com/go-openapi/swag/stringutils v0.25.1 // indirect github.com/go-openapi/swag/typeutils v0.25.1 // indirect @@ -200,9 +201,9 @@ require ( github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect github.com/wI2L/jsondiff v0.5.0 // indirect - github.com/werf/3p-helm v0.0.0-20250731134240-58a9eff8ec5b // indirect - github.com/werf/common-go v0.0.0-20251009090833-3d49886e7488 // indirect - github.com/werf/kubedog v0.13.1-0.20250813095923-12d70b6780b0 // indirect + github.com/werf/3p-helm v0.0.0-20251021224308-a90f195bd29a // indirect + github.com/werf/common-go v0.0.0-20251017004901-cb6247f72f1a // indirect + github.com/werf/kubedog v0.13.1-0.20251105104917-8615bb20d8c0 // indirect github.com/werf/lockgate v0.1.1 // indirect github.com/werf/logboek v0.6.1 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect diff --git a/go.sum b/go.sum index 79dfbd01..c80e3bee 100644 --- a/go.sum +++ b/go.sum @@ -522,18 +522,18 @@ github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= github.com/wI2L/jsondiff v0.5.0 h1:RRMTi/mH+R2aXcPe1VYyvGINJqQfC3R+KSEakuU1Ikw= github.com/wI2L/jsondiff v0.5.0/go.mod h1:qqG6hnK0Lsrz2BpIVCxWiK9ItsBCpIZQiv0izJjOZ9s= -github.com/werf/3p-helm v0.0.0-20250731134240-58a9eff8ec5b h1:l9R9CvJLk8uaLmJpyuP5GboqzZaTqwxgfzuTMEbfF28= -github.com/werf/3p-helm v0.0.0-20250731134240-58a9eff8ec5b/go.mod h1:KDjmOsjFiOmj0fB0+q+0gGvlejPMjTgckLC59bX0BLg= -github.com/werf/common-go v0.0.0-20251009090833-3d49886e7488 h1:pNFYma4z3BB9oTzj9s+eF+Fiw9nGE1c8woZmRh0V6+4= -github.com/werf/common-go v0.0.0-20251009090833-3d49886e7488/go.mod h1:MXS0JR9zut+oR9oEM8PEkdXXoEbKDILTmWopt0z1eZs= -github.com/werf/kubedog v0.13.1-0.20250813095923-12d70b6780b0 h1:E7odWm4YBrYee/g9UyDVJ++C6xrKq2orNrkLiNrrN9k= -github.com/werf/kubedog v0.13.1-0.20250813095923-12d70b6780b0/go.mod h1:gu4EY4hxtiYVDy5o6WE2lRZS0YWqrOV0HS//GTYyrUE= +github.com/werf/3p-helm v0.0.0-20251021224308-a90f195bd29a h1:2MQLbG3bB3wx1PaHSKftVIZNmBUNHKjDdD2K+4kHFbE= +github.com/werf/3p-helm v0.0.0-20251021224308-a90f195bd29a/go.mod h1:cJqEbzc97X0/gYYi5pU4RyXDD8o1spkZh7bOxV2+NQ0= +github.com/werf/common-go v0.0.0-20251017004901-cb6247f72f1a h1:merq7OD3hQmgUQBZDQ3cJdirvGBZS9qUB6U+Emdh63I= +github.com/werf/common-go v0.0.0-20251017004901-cb6247f72f1a/go.mod h1:MXS0JR9zut+oR9oEM8PEkdXXoEbKDILTmWopt0z1eZs= +github.com/werf/kubedog v0.13.1-0.20251105104917-8615bb20d8c0 h1:7owKaBiK78CpIBr6tCzhSgcXDD25X6ZH0O4B+koBt+M= +github.com/werf/kubedog v0.13.1-0.20251105104917-8615bb20d8c0/go.mod h1:gu4EY4hxtiYVDy5o6WE2lRZS0YWqrOV0HS//GTYyrUE= github.com/werf/lockgate v0.1.1 h1:S400JFYjtWfE4i4LY9FA8zx0fMdfui9DPrBiTciCrx4= github.com/werf/lockgate v0.1.1/go.mod h1:0yIFSLq9ausy6ejNxF5uUBf/Ib6daMAfXuCaTMZJzIE= github.com/werf/logboek v0.6.1 h1:oEe6FkmlKg0z0n80oZjLplj6sXcBeLleCkjfOOZEL2g= github.com/werf/logboek v0.6.1/go.mod h1:Gez5J4bxekyr6MxTmIJyId1F61rpO+0/V4vjCIEIZmk= -github.com/werf/nelm v1.12.3 h1:RiF0kDjQhmHWcXHgPO+QHdvL8QgW61K8SuhCR0tNMqo= -github.com/werf/nelm v1.12.3/go.mod h1:jsB+vAnwoSXvm3J3+mUsPBGH0XdCqumEsyDIJkcOzRE= +github.com/werf/nelm v1.16.2-0.20251106110659-fb3b42bd8fba h1:1afKGS7rHV14veK0uGFKL62fpBlOYik4bFpRSjvMTII= +github.com/werf/nelm v1.16.2-0.20251106110659-fb3b42bd8fba/go.mod h1:xagTj6aWTBe+EmzWBIhTydrXeiq47uVX8WISjxo9yIE= 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= diff --git a/pkg/helm/nelm/nelm.go b/pkg/helm/nelm/nelm.go index 381e82fe..5190a97a 100644 --- a/pkg/helm/nelm/nelm.go +++ b/pkg/helm/nelm/nelm.go @@ -14,6 +14,7 @@ import ( "github.com/deckhouse/deckhouse/pkg/log" "github.com/werf/nelm/pkg/action" + "github.com/werf/nelm/pkg/common" nelmLog "github.com/werf/nelm/pkg/log" "helm.sh/helm/v3/pkg/cli" "k8s.io/cli-runtime/pkg/genericclioptions" @@ -41,7 +42,7 @@ type NelmActions interface { ReleaseInstall(ctx context.Context, name, namespace string, opts action.ReleaseInstallOptions) error ReleaseUninstall(ctx context.Context, name, namespace string, opts action.ReleaseUninstallOptions) error ReleaseList(ctx context.Context, opts action.ReleaseListOptions) (*action.ReleaseListResultV1, error) - ChartRender(ctx context.Context, opts action.ChartRenderOptions) (*action.ChartRenderResultV1, error) + ChartRender(ctx context.Context, opts action.ChartRenderOptions) (*action.ChartRenderResultV2, error) } type DefaultNelmActions struct{} @@ -62,7 +63,7 @@ func (d *DefaultNelmActions) ReleaseList(ctx context.Context, opts action.Releas return action.ReleaseList(ctx, opts) } -func (d *DefaultNelmActions) ChartRender(ctx context.Context, opts action.ChartRenderOptions) (*action.ChartRenderResultV1, error) { +func (d *DefaultNelmActions) ChartRender(ctx context.Context, opts action.ChartRenderOptions) (*action.ChartRenderResultV2, error) { return action.ChartRender(ctx, opts) } @@ -112,7 +113,9 @@ type NelmClient struct { // GetReleaseLabels returns a specific label value from the release. func (c *NelmClient) GetReleaseLabels(releaseName, labelName string) (string, error) { releaseGetResult, err := c.actions.ReleaseGet(context.TODO(), releaseName, *c.opts.Namespace, action.ReleaseGetOptions{ - KubeContext: c.opts.KubeContext, + KubeConnectionOptions: common.KubeConnectionOptions{ + KubeContextCurrent: c.opts.KubeContext, + }, OutputNoPrint: true, ReleaseStorageDriver: c.opts.HelmDriver, }) @@ -165,7 +168,9 @@ func (c *NelmClient) GetAnnotations() map[string]string { func (c *NelmClient) LastReleaseStatus(releaseName string) (string, string, error) { releaseGetResult, err := c.actions.ReleaseGet(context.TODO(), releaseName, *c.opts.Namespace, action.ReleaseGetOptions{ - KubeContext: c.opts.KubeContext, + KubeConnectionOptions: common.KubeConnectionOptions{ + KubeContextCurrent: c.opts.KubeContext, + }, OutputNoPrint: true, ReleaseStorageDriver: c.opts.HelmDriver, }) @@ -204,7 +209,9 @@ func (c *NelmClient) UpgradeRelease(releaseName, modulePath string, valuesPaths // First check if release exists _, err := c.actions.ReleaseGet(context.Background(), releaseName, namespace, action.ReleaseGetOptions{ - KubeContext: c.opts.KubeContext, + KubeConnectionOptions: common.KubeConnectionOptions{ + KubeContextCurrent: c.opts.KubeContext, + }, OutputNoPrint: true, ReleaseStorageDriver: c.opts.HelmDriver, }) @@ -220,22 +227,28 @@ func (c *NelmClient) UpgradeRelease(releaseName, modulePath string, valuesPaths } if err := c.actions.ReleaseInstall(context.TODO(), releaseName, namespace, action.ReleaseInstallOptions{ - Chart: modulePath, - DefaultChartName: releaseName, - DefaultChartVersion: "0.2.0", - DefaultChartAPIVersion: "v2", - ExtraLabels: c.labels, - ExtraAnnotations: extraAnnotations, - KubeContext: c.opts.KubeContext, - NoInstallCRDs: true, - ReleaseHistoryLimit: int(c.opts.HistoryMax), - ReleaseLabels: releaseLabels, - ReleaseStorageDriver: c.opts.HelmDriver, - Timeout: c.opts.Timeout, - ValuesFilesPaths: valuesPaths, - ValuesSets: setValues, - ForceAdoption: true, - NoPodLogs: true, + KubeConnectionOptions: common.KubeConnectionOptions{ + KubeContextCurrent: c.opts.KubeContext, + }, + ValuesOptions: common.ValuesOptions{ + ValuesFiles: valuesPaths, + ValuesSet: setValues, + }, + TrackingOptions: common.TrackingOptions{ + NoPodLogs: true, + }, + Chart: modulePath, + DefaultChartName: releaseName, + DefaultChartVersion: "0.2.0", + DefaultChartAPIVersion: "v2", + ExtraLabels: c.labels, + ExtraAnnotations: extraAnnotations, + NoInstallStandaloneCRDs: true, + ReleaseHistoryLimit: int(c.opts.HistoryMax), + ReleaseLabels: releaseLabels, + ReleaseStorageDriver: c.opts.HelmDriver, + Timeout: c.opts.Timeout, + ForceAdoption: true, }); err != nil { return fmt.Errorf("install nelm release %q: %w", releaseName, err) } @@ -250,7 +263,9 @@ func (c *NelmClient) UpgradeRelease(releaseName, modulePath string, valuesPaths func (c *NelmClient) GetReleaseValues(releaseName string) (utils.Values, error) { releaseGetResult, err := c.actions.ReleaseGet(context.TODO(), releaseName, *c.opts.Namespace, action.ReleaseGetOptions{ - KubeContext: c.opts.KubeContext, + KubeConnectionOptions: common.KubeConnectionOptions{ + KubeContextCurrent: c.opts.KubeContext, + }, OutputNoPrint: true, ReleaseStorageDriver: c.opts.HelmDriver, }) @@ -278,7 +293,9 @@ func (c *NelmClient) GetReleaseChecksum(releaseName string) (string, error) { logger := c.logger.With(slog.String("release_name", releaseName)) releaseGetResult, err := c.actions.ReleaseGet(context.TODO(), releaseName, *c.opts.Namespace, action.ReleaseGetOptions{ - KubeContext: c.opts.KubeContext, + KubeConnectionOptions: common.KubeConnectionOptions{ + KubeContextCurrent: c.opts.KubeContext, + }, OutputNoPrint: true, ReleaseStorageDriver: c.opts.HelmDriver, }) @@ -309,11 +326,15 @@ func (c *NelmClient) DeleteRelease(releaseName string) error { c.logger.Debug("nelm release: execute nelm uninstall", slog.String("release", releaseName)) if err := c.actions.ReleaseUninstall(context.TODO(), releaseName, *c.opts.Namespace, action.ReleaseUninstallOptions{ - KubeContext: c.opts.KubeContext, + KubeConnectionOptions: common.KubeConnectionOptions{ + KubeContextCurrent: c.opts.KubeContext, + }, + TrackingOptions: common.TrackingOptions{ + NoPodLogs: true, + }, ReleaseHistoryLimit: int(c.opts.HistoryMax), ReleaseStorageDriver: c.opts.HelmDriver, Timeout: c.opts.Timeout, - NoPodLogs: true, }); err != nil { return fmt.Errorf("nelm uninstall release %q: %w", releaseName, err) } @@ -336,7 +357,9 @@ func (c *NelmClient) IsReleaseExists(releaseName string) (bool, error) { func (c *NelmClient) ListReleasesNames() ([]string, error) { releaseListResult, err := c.actions.ReleaseList(context.TODO(), action.ReleaseListOptions{ - KubeContext: c.opts.KubeContext, + KubeConnectionOptions: common.KubeConnectionOptions{ + KubeContextCurrent: c.opts.KubeContext, + }, OutputNoPrint: true, ReleaseStorageDriver: c.opts.HelmDriver, }) @@ -381,6 +404,13 @@ func (c *NelmClient) Render(releaseName, modulePath string, valuesPaths, setValu } chartRenderResult, err := c.actions.ChartRender(context.TODO(), action.ChartRenderOptions{ + KubeConnectionOptions: common.KubeConnectionOptions{ + KubeContextCurrent: c.opts.KubeContext, + }, + ValuesOptions: common.ValuesOptions{ + ValuesFiles: valuesPaths, + ValuesSet: setValues, + }, OutputFilePath: "/dev/null", // No output file, we want to return the manifest as a string Chart: modulePath, DefaultChartName: releaseName, @@ -388,13 +418,10 @@ func (c *NelmClient) Render(releaseName, modulePath string, valuesPaths, setValu DefaultChartAPIVersion: "v2", ExtraLabels: c.labels, ExtraAnnotations: extraAnnotations, - KubeContext: c.opts.KubeContext, ReleaseName: releaseName, ReleaseNamespace: namespace, ReleaseStorageDriver: c.opts.HelmDriver, Remote: true, - ValuesFilesPaths: valuesPaths, - ValuesSets: setValues, ForceAdoption: true, }) if err != nil {