diff --git a/bcs-services/bcs-helm-manager/cmd/bcs-helm-manager-migrator/main.go b/bcs-services/bcs-helm-manager/cmd/bcs-helm-manager-migrator/main.go index 8594219741..77d7898c2a 100644 --- a/bcs-services/bcs-helm-manager/cmd/bcs-helm-manager-migrator/main.go +++ b/bcs-services/bcs-helm-manager/cmd/bcs-helm-manager-migrator/main.go @@ -43,7 +43,7 @@ import ( microRgt "go-micro.dev/v4/registry" "gorm.io/driver/mysql" "gorm.io/gorm" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/component/project" @@ -389,12 +389,12 @@ func (r *release) toEntity() (*entity.Release, error) { } } - status := helmrelease.StatusDeployed + status := releaseCom.StatusDeployed if r.Status != 1 { - status = helmrelease.StatusFailed + status = releaseCom.StatusFailed } if r.StringStatus != "" { - status = helmrelease.Status(r.StringStatus) + status = releaseCom.Status(r.StringStatus) } // init release struct return &entity.Release{ diff --git a/bcs-services/bcs-helm-manager/go.mod b/bcs-services/bcs-helm-manager/go.mod index d1f0177718..47c251f6af 100644 --- a/bcs-services/bcs-helm-manager/go.mod +++ b/bcs-services/bcs-helm-manager/go.mod @@ -1,92 +1,90 @@ module github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager -go 1.23.0 +go 1.25.0 replace ( // github.com/databus23/helm-diff/v3 limit by go 1.23 github.com/databus23/helm-diff/v3 => github.com/databus23/helm-diff/v3 v3.9.11 - helm.sh/helm/v3 => github.com/adevjoe/helm/v3 v3.17.3-tx.1 - k8s.io/api => k8s.io/api v0.32.2 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.32.2 - k8s.io/apimachinery => k8s.io/apimachinery v0.32.2 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.32.2 - k8s.io/client-go => k8s.io/client-go v0.32.2 - k8s.io/kubectl => k8s.io/kubectl v0.32.2 - k8s.io/kubernetes => k8s.io/kubernetes v1.13.0 + helm.sh/helm/v4 => github.com/dove0012/helm/v4 v4.0.0-20260514005734-37758d875245 + k8s.io/kubernetes => k8s.io/kubernetes v1.26.5 ) require ( github.com/Tencent/bk-bcs/bcs-common/common/encryptv2 v0.0.0-20230911112816-85f490b1c029 github.com/chartmuseum/helm-push v0.7.1 - github.com/envoyproxy/protoc-gen-validate v1.0.4 + github.com/envoyproxy/protoc-gen-validate v1.3.0 github.com/go-micro/plugins/v4/config/encoder/yaml v1.2.0 github.com/go-micro/plugins/v4/registry/etcd v1.1.0 github.com/go-micro/plugins/v4/server/grpc v1.2.0 - github.com/goccy/go-yaml v1.9.6 + github.com/goccy/go-yaml v1.18.0 github.com/golang-jwt/jwt/v4 v4.5.0 - github.com/golang/glog v1.2.1 + github.com/golang/glog v1.2.5 github.com/golang/protobuf v1.5.4 github.com/google/uuid v1.6.0 - github.com/gorilla/mux v1.8.0 - github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/gorilla/mux v1.8.1 + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 github.com/parnurzeal/gorequest v0.2.16 github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/prometheus/client_golang v1.19.1 - github.com/spf13/cobra v1.8.1 - github.com/spf13/pflag v1.0.5 + github.com/prometheus/client_golang v1.23.2 + github.com/spf13/cobra v1.10.2 + github.com/spf13/pflag v1.0.10 github.com/spf13/viper v1.10.0 - github.com/stretchr/testify v1.10.0 - github.com/tidwall/pretty v1.0.0 + github.com/stretchr/testify v1.11.1 + github.com/tidwall/pretty v1.2.1 github.com/urfave/cli/v2 v2.3.0 // indirect github.com/vmware-tanzu/carvel-ytt v0.40.1 go-micro.dev/v4 v4.9.0 go.mongodb.org/mongo-driver v1.7.5 go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.27.0 // indirect - golang.org/x/sync v0.12.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 - google.golang.org/grpc v1.65.0 - google.golang.org/protobuf v1.35.1 + go.uber.org/zap v1.27.1 // indirect + golang.org/x/sync v0.20.0 + google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 + google.golang.org/grpc v1.80.0 + google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/mysql v1.3.6 gorm.io/gorm v1.23.8 - k8s.io/api v0.32.2 - k8s.io/apimachinery v0.32.2 - k8s.io/cli-runtime v0.32.2 - k8s.io/client-go v11.0.0+incompatible + k8s.io/api v0.35.1 + k8s.io/apimachinery v0.35.1 + k8s.io/cli-runtime v0.35.1 + k8s.io/client-go v0.35.1 k8s.io/klog v1.0.0 - k8s.io/klog/v2 v2.130.1 + k8s.io/klog/v2 v2.140.0 ) require ( github.com/Tencent/bk-bcs/bcs-common v0.0.0-20250710101644-24c34c9b3919 github.com/Tencent/bk-bcs/bcs-services/pkg v0.0.0-20250710101644-24c34c9b3919 github.com/databus23/helm-diff/v3 v3.0.0-00010101000000-000000000000 + github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/samber/lo v1.49.1 - helm.sh/helm/v3 v3.16.1 + helm.sh/helm/v4 v4.1.4 k8s.io/helm v2.17.0+incompatible ) +require ( + github.com/google/go-cmp v0.7.0 // indirect + github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect +) + require ( dario.cat/mergo v1.0.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect - github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect - github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/BurntSushi/toml v1.4.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect + github.com/BurntSushi/toml v1.6.0 // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver v1.5.0 // indirect - github.com/Masterminds/semver/v3 v3.3.0 // indirect + github.com/Masterminds/semver/v3 v3.5.0 // indirect github.com/Masterminds/sprig/v3 v3.3.0 // indirect github.com/Masterminds/squirrel v1.5.4 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/ProtonMail/go-crypto v1.1.3 // indirect + github.com/ProtonMail/go-crypto v1.4.1 // indirect github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/kubernetes/common v0.0.0-20220330120237-0bbed74dcf6d // indirect - github.com/Tencent/bk-bcs/bcs-scenarios/kourse v0.0.0-20230620131944-108c92952073 // indirect + github.com/Tencent/bk-bcs/bcs-scenarios/kourse v0.0.0-20260513011542-f29addf3782e // indirect github.com/TencentBlueKing/bk-audit-go-sdk v0.0.6 // indirect github.com/TencentBlueKing/crypto-golang-sdk v1.0.0 // indirect github.com/TencentBlueKing/gopkg v1.1.0 // indirect @@ -96,51 +94,41 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bitly/go-simplejson v0.5.0 // indirect github.com/blang/semver/v4 v4.0.0 // indirect - github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/cenkalti/backoff/v5 v5.0.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect - github.com/cloudflare/circl v1.3.7 // indirect - github.com/containerd/containerd v1.7.24 // indirect - github.com/containerd/errdefs v0.3.0 // indirect - github.com/containerd/log v0.1.0 // indirect - github.com/containerd/platforms v0.2.1 // indirect + github.com/cloudflare/circl v1.6.3 // indirect github.com/coreos/go-semver v0.3.1 // indirect - github.com/coreos/go-systemd/v22 v22.5.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect - github.com/cyphar/filepath-securejoin v0.3.6 // indirect + github.com/coreos/go-systemd/v22 v22.7.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect + github.com/cyphar/filepath-securejoin v0.6.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect - github.com/distribution/reference v0.6.0 // indirect - github.com/docker/cli v25.0.1+incompatible // indirect - github.com/docker/distribution v2.8.3+incompatible // indirect - github.com/docker/docker v25.0.6+incompatible // indirect - github.com/docker/docker-credential-helpers v0.7.0 // indirect - github.com/docker/go-connections v0.5.0 // indirect - github.com/docker/go-metrics v0.0.1 // indirect + github.com/dgraph-io/ristretto v0.2.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a // indirect + github.com/emicklei/go-restful/v3 v3.13.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect - github.com/evanphx/json-patch v5.9.0+incompatible // indirect - github.com/evanphx/json-patch/v5 v5.9.0 // indirect + github.com/evanphx/json-patch/v5 v5.9.11 // indirect github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect - github.com/fatih/color v1.13.0 // indirect + github.com/extism/go-sdk v1.7.1 // indirect + github.com/fatih/color v1.19.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/fxamacker/cbor/v2 v2.7.0 // indirect + github.com/fluxcd/cli-utils v0.37.2-flux.1 // indirect + github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/go-acme/lego/v4 v4.4.0 // indirect - github.com/go-errors/errors v1.4.2 // indirect + github.com/go-errors/errors v1.5.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.6.0 // indirect github.com/go-git/go-git/v5 v5.13.0 // indirect github.com/go-gorp/gorp/v3 v3.1.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/jsonpointer v0.21.0 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.23.0 // indirect + github.com/go-openapi/jsonpointer v0.21.1 // indirect + github.com/go-openapi/jsonreference v0.21.0 // indirect + github.com/go-openapi/swag v0.23.1 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.19.0 // indirect @@ -151,6 +139,7 @@ require ( github.com/gobwas/httphead v0.1.0 // indirect github.com/gobwas/pool v0.2.1 // indirect github.com/gobwas/ws v1.2.1 // indirect + github.com/gofrs/flock v0.13.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-migrate/migrate/v4 v4.17.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -161,22 +150,18 @@ require ( github.com/gonvenience/text v1.0.7 // indirect github.com/gonvenience/wrap v1.2.0 // indirect github.com/gonvenience/ytbx v1.4.4 // indirect - github.com/google/btree v1.0.1 // indirect - github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/gorilla/handlers v1.5.1 // indirect - github.com/gorilla/websocket v1.5.0 // indirect + github.com/google/btree v1.1.3 // indirect + github.com/google/gnostic-models v0.7.0 // indirect + github.com/gorilla/handlers v1.5.2 // indirect github.com/gosuri/uitable v0.0.4 // indirect - github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-version v1.4.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/homeport/dyff v1.9.0 // indirect github.com/huandu/xstrings v1.5.0 // indirect + github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect @@ -188,18 +173,18 @@ require ( github.com/juju/ratelimit v1.0.1 // indirect github.com/k14s/starlark-go v0.0.0-20200720175618-3a5c849cc368 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.16.7 // indirect + github.com/klauspost/compress v1.18.4 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect github.com/leodido/go-urn v1.4.0 // indirect - github.com/lib/pq v1.10.9 // indirect + github.com/lib/pq v1.12.3 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/magiconair/properties v1.8.5 // indirect - github.com/mailru/easyjson v0.7.7 // indirect + github.com/mailru/easyjson v0.9.0 // indirect github.com/mattbaird/jsonpatch v0.0.0-20200820163806-098863c1fc24 // indirect github.com/mattn/go-ciede2000 v0.0.0-20170301095244-782e8c62fec3 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/miekg/dns v1.1.57 // indirect @@ -209,17 +194,14 @@ require ( github.com/mitchellh/hashstructure v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/moby/locker v1.0.1 // indirect - github.com/moby/spdystream v0.5.0 // indirect - github.com/moby/term v0.5.0 // indirect + github.com/moby/term v0.5.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0 // indirect + github.com/opencontainers/image-spec v1.1.1 // indirect github.com/openzipkin/zipkin-go v0.3.0 // indirect github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect github.com/pelletier/go-toml v1.9.5 // indirect @@ -227,22 +209,25 @@ require ( github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect - github.com/rivo/uniseg v0.2.0 // indirect - github.com/rubenv/sql-migrate v1.7.1 // indirect + github.com/prometheus/client_model v0.6.2 // indirect + github.com/prometheus/common v0.67.5 // indirect + github.com/prometheus/procfs v0.20.1 // indirect + github.com/rivo/uniseg v0.4.7 // indirect + github.com/rubenv/sql-migrate v1.8.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414 // indirect - github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect + github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect + github.com/sergi/go-diff v1.4.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect + github.com/sirupsen/logrus v1.9.4 // indirect github.com/skeema/knownhosts v1.3.0 // indirect github.com/smartystreets/assertions v1.2.0 // indirect github.com/spf13/afero v1.10.0 // indirect github.com/spf13/cast v1.7.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/subosito/gotenv v1.2.0 // indirect + github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 // indirect + github.com/tetratelabs/wazero v1.11.0 // indirect github.com/texttheater/golang-levenshtein v1.0.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 // indirect @@ -251,53 +236,54 @@ require ( github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.1 // indirect github.com/xdg-go/stringprep v1.0.3 // indirect - github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect - github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect - github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xlab/treeprint v1.2.0 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect - go.etcd.io/etcd/api/v3 v3.5.16 // indirect - go.etcd.io/etcd/client/pkg/v3 v3.5.16 // indirect - go.etcd.io/etcd/client/v3 v3.5.16 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect - go.opentelemetry.io/otel v1.28.0 // indirect + go.etcd.io/etcd/api/v3 v3.6.8 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.6.8 // indirect + go.etcd.io/etcd/client/v3 v3.6.8 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.67.0 // indirect + go.opentelemetry.io/otel v1.43.0 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.3.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.42.0 // indirect go.opentelemetry.io/otel/exporters/zipkin v1.3.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect - go.opentelemetry.io/otel/sdk v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect - go.opentelemetry.io/proto/otlp v1.3.1 // indirect - golang.org/x/crypto v0.36.0 // indirect - golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.37.0 // indirect - golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sys v0.31.0 // indirect - golang.org/x/term v0.30.0 // indirect - golang.org/x/text v0.23.0 // indirect - golang.org/x/time v0.7.0 // indirect - golang.org/x/tools v0.26.0 // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + go.opentelemetry.io/otel/metric v1.43.0 // indirect + go.opentelemetry.io/otel/sdk v1.43.0 // indirect + go.opentelemetry.io/otel/trace v1.43.0 // indirect + go.opentelemetry.io/proto/otlp v1.10.0 // indirect + go.yaml.in/yaml/v2 v2.4.3 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/crypto v0.50.0 // indirect + golang.org/x/mod v0.34.0 // indirect + golang.org/x/net v0.52.0 // indirect + golang.org/x/oauth2 v0.36.0 // indirect + golang.org/x/sys v0.43.0 // indirect + golang.org/x/term v0.42.0 // indirect + golang.org/x/text v0.36.0 // indirect + golang.org/x/time v0.15.0 // indirect + golang.org/x/tools v0.43.0 // indirect google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect - gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect + gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.66.2 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect - k8s.io/apiextensions-apiserver v0.32.2 // indirect - k8s.io/apiserver v0.32.2 // indirect - k8s.io/component-base v0.32.2 // indirect - k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect - k8s.io/kubectl v0.32.2 // indirect + k8s.io/apiextensions-apiserver v0.35.1 // indirect + k8s.io/apiserver v0.35.1 // indirect + k8s.io/component-base v0.35.1 // indirect + k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect + k8s.io/kubectl v0.35.1 // indirect k8s.io/kubernetes v1.13.0 // indirect - k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect + k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 // indirect moul.io/http2curl v1.0.0 // indirect - oras.land/oras-go v1.2.5 // indirect - sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/kustomize/api v0.18.0 // indirect - sigs.k8s.io/kustomize/kyaml v0.18.1 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect - sigs.k8s.io/yaml v1.4.0 // indirect + oras.land/oras-go/v2 v2.6.0 // indirect + sigs.k8s.io/controller-runtime v0.23.1 // indirect + sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect + sigs.k8s.io/kustomize/api v0.21.1 // indirect + sigs.k8s.io/kustomize/kyaml v0.21.1 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect ) diff --git a/bcs-services/bcs-helm-manager/internal/actions/addons/get.go b/bcs-services/bcs-helm-manager/internal/actions/addons/get.go index a36b5d7f63..a244eb11f5 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/addons/get.go +++ b/bcs-services/bcs-helm-manager/internal/actions/addons/get.go @@ -19,7 +19,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers" - "helm.sh/helm/v3/pkg/storage/driver" + "helm.sh/helm/v4/pkg/storage/driver" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release" diff --git a/bcs-services/bcs-helm-manager/internal/actions/addons/install.go b/bcs-services/bcs-helm-manager/internal/actions/addons/install.go index 30a5d2277c..b082be514c 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/addons/install.go +++ b/bcs-services/bcs-helm-manager/internal/actions/addons/install.go @@ -17,7 +17,7 @@ import ( "fmt" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" @@ -116,10 +116,10 @@ func (i *InstallAddonsAction) saveDB(ctx context.Context, ns, chartName, release return err } createBy := auth.GetUserFromCtx(ctx) - status := helmrelease.StatusPendingInstall.String() + status := releaseCom.StatusPendingInstall.String() // 对于非 chart 类型的 addons,直接返回成功 if isFakeChart(chartName) { - status = helmrelease.StatusDeployed.String() + status = releaseCom.StatusDeployed.String() } if err := i.model.CreateRelease(ctx, &entity.Release{ Name: releaseName, diff --git a/bcs-services/bcs-helm-manager/internal/actions/addons/list.go b/bcs-services/bcs-helm-manager/internal/actions/addons/list.go index 17ecb3f1f6..8cc7be44fe 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/addons/list.go +++ b/bcs-services/bcs-helm-manager/internal/actions/addons/list.go @@ -20,8 +20,8 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers" "golang.org/x/sync/errgroup" - helmrelease "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/storage/driver" + releaseCom "helm.sh/helm/v4/pkg/release/common" + "helm.sh/helm/v4/pkg/storage/driver" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release" @@ -112,9 +112,9 @@ func (l *ListAddonsAction) Handle(ctx context.Context, mux.Lock() if err != nil { if errors.Is(err, driver.ErrReleaseNotFound) && - *addons[i].Status == helmrelease.StatusDeployed.String() && *addons[i].ChartName != "" { + *addons[i].Status == releaseCom.StatusDeployed.String() && *addons[i].ChartName != "" { // 如果集群中没有改 release,则置为未安装状态 - if *addons[i].Status == helmrelease.StatusDeployed.String() && *addons[i].ChartName != "" { + if *addons[i].Status == releaseCom.StatusDeployed.String() && *addons[i].ChartName != "" { addons[i].Status = common.GetStringP("") addons[i].Message = common.GetStringP("") } diff --git a/bcs-services/bcs-helm-manager/internal/actions/addons/preview.go b/bcs-services/bcs-helm-manager/internal/actions/addons/preview.go index 0e204b577c..0661cbc92c 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/addons/preview.go +++ b/bcs-services/bcs-helm-manager/internal/actions/addons/preview.go @@ -18,7 +18,7 @@ import ( "fmt" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "helm.sh/helm/v3/pkg/storage/driver" + "helm.sh/helm/v4/pkg/storage/driver" actionsrelease "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/actions/release" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" diff --git a/bcs-services/bcs-helm-manager/internal/actions/addons/stop.go b/bcs-services/bcs-helm-manager/internal/actions/addons/stop.go index 3a9ee426ee..bb12b6f68e 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/addons/stop.go +++ b/bcs-services/bcs-helm-manager/internal/actions/addons/stop.go @@ -17,7 +17,7 @@ import ( "fmt" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" @@ -124,7 +124,7 @@ func (s *StopAddonsAction) saveDB(ctx context.Context, ns, chartName, releaseNam s.version = old.ChartVersion rl := entity.M{ entity.FieldKeyUpdateBy: s.updateBy, - entity.FieldKeyStatus: helmrelease.StatusPendingUpgrade.String(), + entity.FieldKeyStatus: releaseCom.StatusPendingUpgrade.String(), entity.FieldKeyMessage: "", } if err := s.model.UpdateRelease(ctx, s.req.GetClusterID(), ns, releaseName, rl); err != nil { diff --git a/bcs-services/bcs-helm-manager/internal/actions/addons/uninstall.go b/bcs-services/bcs-helm-manager/internal/actions/addons/uninstall.go index 732223798e..e5313beba1 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/addons/uninstall.go +++ b/bcs-services/bcs-helm-manager/internal/actions/addons/uninstall.go @@ -19,7 +19,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" @@ -132,7 +132,7 @@ func (u *UninstallAddonsAction) saveDB(ctx context.Context, ns, chartName, relea username := auth.GetUserFromCtx(ctx) rl := entity.M{ entity.FieldKeyUpdateBy: username, - entity.FieldKeyStatus: helmrelease.StatusUninstalling.String(), + entity.FieldKeyStatus: releaseCom.StatusUninstalling.String(), entity.FieldKeyMessage: "", } if err := u.model.UpdateRelease(ctx, u.req.GetClusterID(), ns, releaseName, rl); err != nil { diff --git a/bcs-services/bcs-helm-manager/internal/actions/addons/upgrade.go b/bcs-services/bcs-helm-manager/internal/actions/addons/upgrade.go index 4e54f1fd31..a780581b7f 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/addons/upgrade.go +++ b/bcs-services/bcs-helm-manager/internal/actions/addons/upgrade.go @@ -19,7 +19,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" @@ -130,10 +130,10 @@ func (u *UpgradeAddonsAction) saveDB(ctx context.Context, ns, chartName, release create = true } - status := helmrelease.StatusPendingUpgrade.String() + status := releaseCom.StatusPendingUpgrade.String() // 对于非 chart 类型的 addons,直接返回成功 if isFakeChart(chartName) { - status = helmrelease.StatusDeployed.String() + status = releaseCom.StatusDeployed.String() } createBy := auth.GetUserFromCtx(ctx) if create { diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/detailv1.go b/bcs-services/bcs-helm-manager/internal/actions/release/detailv1.go index 87177168da..ecb9523763 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/detailv1.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/detailv1.go @@ -20,7 +20,7 @@ import ( "time" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "helm.sh/helm/v3/pkg/storage/driver" + "helm.sh/helm/v4/pkg/storage/driver" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release" diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/history.go b/bcs-services/bcs-helm-manager/internal/actions/release/history.go index 295029083c..eac4c8c3f3 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/history.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/history.go @@ -17,7 +17,7 @@ import ( "errors" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "helm.sh/helm/v3/pkg/storage/driver" + "helm.sh/helm/v4/pkg/storage/driver" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release" diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/installv1.go b/bcs-services/bcs-helm-manager/internal/actions/release/installv1.go index 8431c8c8e6..3c71bbe96d 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/installv1.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/installv1.go @@ -18,8 +18,8 @@ import ( "fmt" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - helmrelease "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/storage/driver" + releaseCom "helm.sh/helm/v4/pkg/release/common" + "helm.sh/helm/v4/pkg/storage/driver" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" @@ -150,7 +150,7 @@ func (i *InstallReleaseV1Action) saveDB() error { Values: i.req.GetValues(), Args: i.req.GetArgs(), CreateBy: createBy, - Status: helmrelease.StatusPendingInstall.String(), + Status: releaseCom.StatusPendingInstall.String(), Env: i.req.GetEnv(), }); err != nil { return err diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/listv1.go b/bcs-services/bcs-helm-manager/internal/actions/release/listv1.go index 327dd7793e..6ed751048c 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/listv1.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/listv1.go @@ -24,7 +24,7 @@ import ( authUtils "github.com/Tencent/bk-bcs/bcs-services/pkg/bcs-auth/utils" "go.mongodb.org/mongo-driver/bson/primitive" "golang.org/x/sync/errgroup" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" @@ -194,7 +194,7 @@ func (l *ListReleaseV1Action) mergeReleases(clusterReleases, continue } // 数据库中状态正常的数据,但在集群中不存在,则不展示 - if v.GetStatus() == helmrelease.StatusDeployed.String() { + if v.GetStatus() == releaseCom.StatusDeployed.String() { continue } newReleaseMap[l.getReleaseKey(v.GetNamespace(), v.GetName())] = dbReleases[i] diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/pods.go b/bcs-services/bcs-helm-manager/internal/actions/release/pods.go index ffe121a654..440f1bcd00 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/pods.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/pods.go @@ -18,7 +18,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" _struct "github.com/golang/protobuf/ptypes/struct" - "helm.sh/helm/v3/pkg/storage/driver" + "helm.sh/helm/v4/pkg/storage/driver" corev1 "k8s.io/api/core/v1" "k8s.io/cli-runtime/pkg/resource" diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/preview.go b/bcs-services/bcs-helm-manager/internal/actions/release/preview.go index 4bd0f0db66..5b2fb2dcd3 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/preview.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/preview.go @@ -20,9 +20,9 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "gopkg.in/yaml.v2" - "helm.sh/helm/v3/pkg/chartutil" - helmrelease "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/storage/driver" + chartutil "helm.sh/helm/v4/pkg/chart/common/util" + helmrelease "helm.sh/helm/v4/pkg/release/v1" + "helm.sh/helm/v4/pkg/storage/driver" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/rollbackv1.go b/bcs-services/bcs-helm-manager/internal/actions/release/rollbackv1.go index 18585c3c78..1008ccfef0 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/rollbackv1.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/rollbackv1.go @@ -19,7 +19,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" @@ -130,14 +130,14 @@ func (r *RollbackReleaseV1Action) saveDB() error { Namespace: r.req.GetNamespace(), ClusterID: r.req.GetClusterID(), CreateBy: username, - Status: helmrelease.StatusPendingRollback.String(), + Status: releaseCom.StatusPendingRollback.String(), }); err != nil { return err } } else { rl := entity.M{ entity.FieldKeyUpdateBy: username, - entity.FieldKeyStatus: helmrelease.StatusPendingRollback.String(), + entity.FieldKeyStatus: releaseCom.StatusPendingRollback.String(), entity.FieldKeyMessage: "", } if err = r.model.UpdateRelease(r.ctx, r.req.GetClusterID(), r.req.GetNamespace(), diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/status.go b/bcs-services/bcs-helm-manager/internal/actions/release/status.go index eeb9fa97c1..7144cb8747 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/status.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/status.go @@ -19,7 +19,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" _struct "github.com/golang/protobuf/ptypes/struct" "google.golang.org/protobuf/types/known/structpb" - "helm.sh/helm/v3/pkg/storage/driver" + "helm.sh/helm/v4/pkg/storage/driver" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release" diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/uninstallv1.go b/bcs-services/bcs-helm-manager/internal/actions/release/uninstallv1.go index 1ca04b5fdb..b86c57ba0b 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/uninstallv1.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/uninstallv1.go @@ -19,7 +19,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" @@ -121,14 +121,14 @@ func (u *UninstallReleaseV1Action) saveDB() error { Namespace: u.req.GetNamespace(), ClusterID: u.req.GetClusterID(), CreateBy: username, - Status: helmrelease.StatusUninstalling.String(), + Status: releaseCom.StatusUninstalling.String(), }); err != nil { return err } } else { rl := entity.M{ entity.FieldKeyUpdateBy: username, - entity.FieldKeyStatus: helmrelease.StatusUninstalling.String(), + entity.FieldKeyStatus: releaseCom.StatusUninstalling.String(), entity.FieldKeyMessage: "", } if err = u.model.UpdateRelease(u.ctx, u.req.GetClusterID(), u.req.GetNamespace(), diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/upgradev1.go b/bcs-services/bcs-helm-manager/internal/actions/release/upgradev1.go index a13da3ac02..e4aea0c5bd 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/upgradev1.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/upgradev1.go @@ -19,7 +19,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" @@ -151,7 +151,7 @@ func (u *UpgradeReleaseV1Action) saveDB() error { Values: u.req.GetValues(), Args: u.req.GetArgs(), CreateBy: createBy, - Status: helmrelease.StatusPendingUpgrade.String(), + Status: releaseCom.StatusPendingUpgrade.String(), Env: u.req.GetEnv(), }); err != nil { return err @@ -176,7 +176,7 @@ func (u *UpgradeReleaseV1Action) saveDB() error { entity.FieldKeyValueFile: u.req.GetValueFile(), entity.FieldKeyArgs: u.req.Args, entity.FieldKeyUpdateBy: createBy, - entity.FieldKeyStatus: helmrelease.StatusPendingUpgrade.String(), + entity.FieldKeyStatus: releaseCom.StatusPendingUpgrade.String(), entity.FieldKeyMessage: "", entity.FieldKeyEnv: u.req.GetEnv(), } diff --git a/bcs-services/bcs-helm-manager/internal/actions/release/utils.go b/bcs-services/bcs-helm-manager/internal/actions/release/utils.go index f20d289946..e3b97bb5eb 100644 --- a/bcs-services/bcs-helm-manager/internal/actions/release/utils.go +++ b/bcs-services/bcs-helm-manager/internal/actions/release/utils.go @@ -20,11 +20,11 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "gopkg.in/yaml.v2" - "helm.sh/helm/v3/pkg/releaseutil" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/repo" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/store" helmmanager "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/proto/bcs-helm-manager" + releaseutil "helm.sh/helm/v4/pkg/release/v1/util" ) const ( diff --git a/bcs-services/bcs-helm-manager/internal/client/pkg/client/chart.go b/bcs-services/bcs-helm-manager/internal/client/pkg/client/chart.go index 94680b1a04..18fc0d4d10 100644 --- a/bcs-services/bcs-helm-manager/internal/client/pkg/client/chart.go +++ b/bcs-services/bcs-helm-manager/internal/client/pkg/client/chart.go @@ -27,7 +27,7 @@ import ( "path/filepath" "strconv" - "helm.sh/helm/v3/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/client/pkg" utilschart "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/utils/chart" diff --git a/bcs-services/bcs-helm-manager/internal/common/constant.go b/bcs-services/bcs-helm-manager/internal/common/constant.go index 370b0ae26b..942923d1da 100644 --- a/bcs-services/bcs-helm-manager/internal/common/constant.go +++ b/bcs-services/bcs-helm-manager/internal/common/constant.go @@ -13,7 +13,7 @@ // Package common xxx package common -import "helm.sh/helm/v3/pkg/release" +import "helm.sh/helm/v4/pkg/release/common" const ( // ServiceDomain domain name for service @@ -38,13 +38,13 @@ const ( // ReleaseStatus const ( // ReleaseStatusInstallFailed xxx - ReleaseStatusInstallFailed release.Status = "failed-install" + ReleaseStatusInstallFailed common.Status = "failed-install" // ReleaseStatusUpgradeFailed xxx - ReleaseStatusUpgradeFailed release.Status = "failed-upgrade" + ReleaseStatusUpgradeFailed common.Status = "failed-upgrade" // ReleaseStatusRollbackFailed xxx - ReleaseStatusRollbackFailed release.Status = "failed-rollback" + ReleaseStatusRollbackFailed common.Status = "failed-rollback" // ReleaseStatusUninstallFailed xxx - ReleaseStatusUninstallFailed release.Status = "failed-uninstall" + ReleaseStatusUninstallFailed common.Status = "failed-uninstall" ) const ( diff --git a/bcs-services/bcs-helm-manager/internal/operation/actions/install.go b/bcs-services/bcs-helm-manager/internal/operation/actions/install.go index af83480215..c63a16904e 100644 --- a/bcs-services/bcs-helm-manager/internal/operation/actions/install.go +++ b/bcs-services/bcs-helm-manager/internal/operation/actions/install.go @@ -19,7 +19,7 @@ import ( "strconv" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/component" @@ -237,7 +237,7 @@ func (r *ReleaseInstallAction) Execute(ctx context.Context) error { // Done xxx func (r *ReleaseInstallAction) Done(err error) { - status := helmrelease.StatusDeployed + status := releaseCom.StatusDeployed message := "" if err != nil { status = common.ReleaseStatusInstallFailed diff --git a/bcs-services/bcs-helm-manager/internal/operation/actions/preview.go b/bcs-services/bcs-helm-manager/internal/operation/actions/preview.go index 9916380c19..89cb714621 100644 --- a/bcs-services/bcs-helm-manager/internal/operation/actions/preview.go +++ b/bcs-services/bcs-helm-manager/internal/operation/actions/preview.go @@ -16,7 +16,7 @@ import ( "context" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - pkgrelease "helm.sh/helm/v3/pkg/release" + pkgrelease "helm.sh/helm/v4/pkg/release/v1" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/repo" diff --git a/bcs-services/bcs-helm-manager/internal/operation/actions/rollback.go b/bcs-services/bcs-helm-manager/internal/operation/actions/rollback.go index 646ed94a47..3c4cd0a4c9 100644 --- a/bcs-services/bcs-helm-manager/internal/operation/actions/rollback.go +++ b/bcs-services/bcs-helm-manager/internal/operation/actions/rollback.go @@ -16,7 +16,7 @@ import ( "context" "fmt" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/operation" @@ -102,7 +102,7 @@ func (r *ReleaseRollbackAction) Execute(ctx context.Context) error { // Done xxx func (r *ReleaseRollbackAction) Done(err error) { - status := helmrelease.StatusDeployed + status := releaseCom.StatusDeployed message := "" if err != nil { status = common.ReleaseStatusRollbackFailed diff --git a/bcs-services/bcs-helm-manager/internal/operation/actions/uninstall.go b/bcs-services/bcs-helm-manager/internal/operation/actions/uninstall.go index e0862289d4..e1aa456cee 100644 --- a/bcs-services/bcs-helm-manager/internal/operation/actions/uninstall.go +++ b/bcs-services/bcs-helm-manager/internal/operation/actions/uninstall.go @@ -18,7 +18,7 @@ import ( "fmt" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "helm.sh/helm/v3/pkg/storage/driver" + "helm.sh/helm/v4/pkg/storage/driver" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/operation" diff --git a/bcs-services/bcs-helm-manager/internal/operation/actions/upgrade.go b/bcs-services/bcs-helm-manager/internal/operation/actions/upgrade.go index f6f4445f5c..4e334b7eca 100644 --- a/bcs-services/bcs-helm-manager/internal/operation/actions/upgrade.go +++ b/bcs-services/bcs-helm-manager/internal/operation/actions/upgrade.go @@ -18,7 +18,7 @@ import ( "strconv" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - helmrelease "helm.sh/helm/v3/pkg/release" + releaseCom "helm.sh/helm/v4/pkg/release/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/component" @@ -237,7 +237,7 @@ func (r *ReleaseUpgradeAction) Execute(ctx context.Context) error { // Done xxx func (r *ReleaseUpgradeAction) Done(err error) { - status := helmrelease.StatusDeployed + status := releaseCom.StatusDeployed message := "" if err != nil { status = common.ReleaseStatusUpgradeFailed diff --git a/bcs-services/bcs-helm-manager/internal/release/bcs/get.go b/bcs-services/bcs-helm-manager/internal/release/bcs/get.go index 1a88d5c779..82655faf0b 100644 --- a/bcs-services/bcs-helm-manager/internal/release/bcs/get.go +++ b/bcs-services/bcs-helm-manager/internal/release/bcs/get.go @@ -16,7 +16,7 @@ import ( "context" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "helm.sh/helm/v3/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/common" "k8s.io/apimachinery/pkg/runtime" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" diff --git a/bcs-services/bcs-helm-manager/internal/release/bcs/history.go b/bcs-services/bcs-helm-manager/internal/release/bcs/history.go index 781bd227c6..560ee73721 100644 --- a/bcs-services/bcs-helm-manager/internal/release/bcs/history.go +++ b/bcs-services/bcs-helm-manager/internal/release/bcs/history.go @@ -17,7 +17,7 @@ import ( "sort" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "helm.sh/helm/v3/pkg/chartutil" + chartutil "helm.sh/helm/v4/pkg/chart/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release" diff --git a/bcs-services/bcs-helm-manager/internal/release/bcs/list.go b/bcs-services/bcs-helm-manager/internal/release/bcs/list.go index d1f5df2eb8..61ceb808dc 100644 --- a/bcs-services/bcs-helm-manager/internal/release/bcs/list.go +++ b/bcs-services/bcs-helm-manager/internal/release/bcs/list.go @@ -21,15 +21,15 @@ import ( "time" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - rspb "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/releaseutil" - helmtime "helm.sh/helm/v3/pkg/time" + releaseCom "helm.sh/helm/v4/pkg/release/common" + rspb "helm.sh/helm/v4/pkg/release/v1" v1 "k8s.io/api/core/v1" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/component" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/options" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release" + releaseutil "helm.sh/helm/v4/pkg/release/v1/util" ) func (c *cluster) list(ctx context.Context, option release.ListOption) (int, []*release.Release, error) { @@ -164,8 +164,8 @@ func (c *cluster) getReleases(ctx context.Context, option release.ListOption) ([ releases = append(releases, &rspb.Release{ Name: data.Labels["name"], Info: &rspb.Info{ - LastDeployed: helmtime.Time{Time: parseStringUnixTime(data.Labels["modifiedAt"])}, - Status: rspb.Status(data.Labels["status"])}, + LastDeployed: parseStringUnixTime(data.Labels["modifiedAt"]), + Status: releaseCom.Status(data.Labels["status"])}, Namespace: data.ObjectMeta.Namespace, Version: parseVersion(data.Labels["version"]), }) diff --git a/bcs-services/bcs-helm-manager/internal/release/bcs/sdk/sdk.go b/bcs-services/bcs-helm-manager/internal/release/bcs/sdk/sdk.go index 83342919b7..75be5a20ff 100644 --- a/bcs-services/bcs-helm-manager/internal/release/bcs/sdk/sdk.go +++ b/bcs-services/bcs-helm-manager/internal/release/bcs/sdk/sdk.go @@ -18,6 +18,7 @@ import ( "context" "errors" "fmt" + "log/slog" "net/http" "regexp" "strconv" @@ -29,13 +30,15 @@ import ( "github.com/samber/lo" "github.com/spf13/pflag" yaml3 "gopkg.in/yaml.v3" - "helm.sh/helm/v3/pkg/action" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/chart/loader" - "helm.sh/helm/v3/pkg/cli/values" - rspb "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/storage/driver" - "helm.sh/helm/v3/pkg/strvals" + "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/chart/loader/archive" + chart "helm.sh/helm/v4/pkg/chart/v2" + "helm.sh/helm/v4/pkg/chart/v2/loader" + "helm.sh/helm/v4/pkg/cli/values" + "helm.sh/helm/v4/pkg/kube" + rspb "helm.sh/helm/v4/pkg/release/v1" + "helm.sh/helm/v4/pkg/storage/driver" + "helm.sh/helm/v4/pkg/strvals" "k8s.io/apimachinery/pkg/util/yaml" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/client-go/rest" @@ -144,7 +147,7 @@ type client struct { // Get helm release func (c *client) Get(_ context.Context, namespace, name string, revision int) (*rspb.Release, error) { conf := new(action.Configuration) - if err := conf.Init(c.getConfigFlag(namespace), namespace, "", blog.Infof); err != nil { + if err := conf.Init(c.getConfigFlag(namespace), namespace, ""); err != nil { return nil, err } @@ -154,14 +157,23 @@ func (c *client) Get(_ context.Context, namespace, name string, revision int) (* if err != nil { return nil, err } - re.Config = removeValuesTemplate(re.Config) - return re, nil + + if re == nil { + return nil, errors.New("release not found") + } + + if r, ok := re.(*rspb.Release); ok { + r.Config = removeValuesTemplate(r.Config) + return r, nil + } + + return nil, errors.New("release not found") } // List helm release func (c *client) List(_ context.Context, option release.ListOption) ([]*rspb.Release, error) { conf := new(action.Configuration) - if err := conf.Init(c.getConfigFlag(option.Namespace), option.Namespace, "", blog.Infof); err != nil { + if err := conf.Init(c.getConfigFlag(option.Namespace), option.Namespace, ""); err != nil { return nil, err } @@ -179,10 +191,19 @@ func (c *client) List(_ context.Context, option release.ListOption) ([]*rspb.Rel if err != nil { return nil, err } + + res := make([]*rspb.Release, 0) for i := range releases { - releases[i].Config = removeValuesTemplate(releases[i].Config) + if releases[i] == nil { + continue + } + + if re, ok := releases[i].(*rspb.Release); ok { + re.Config = removeValuesTemplate(re.Config) + res = append(res, re) + } } - return releases, nil + return res, nil } // Install helm release through helm client @@ -191,15 +212,15 @@ func (c *client) Install(ctx context.Context, config release.HelmInstallConfig) config.DryRun) conf := new(action.Configuration) - if err := conf.Init(c.getConfigFlag(config.Namespace), config.Namespace, "", blog.Infof); err != nil { + if err := conf.Init(c.getConfigFlag(config.Namespace), config.Namespace, ""); err != nil { blog.Errorf("sdk client install and init configuration failed, %s, %v", err.Error(), config) return nil, err } installer := action.NewInstall(conf) - installer.DryRun = config.DryRun + installer.DryRunStrategy = config.DryRunStrategy installer.Replace = config.Replace - installer.ClientOnly = config.ClientOnly + //installer.ClientOnly = config.ClientOnly installer.ReleaseName = config.Name installer.Namespace = config.Namespace installer.PostRenderer = newPatcher(c.group.config.PatchTemplates, config.PatchTemplateValues) @@ -238,15 +259,34 @@ func (c *client) Install(ctx context.Context, config release.HelmInstallConfig) } r, err := installer.Run(ctx, chartF, values) + + if r == nil { + err = fmt.Errorf("release is nil") + blog.Errorf("sdk client install failed, %s, "+ + "namespace %s, name %s", err.Error(), config.Namespace, config.Name) + return nil, err + } + + var ( + ok bool + re *rspb.Release + ) + if re, ok = r.(*rspb.Release); !ok { + err = fmt.Errorf("release type error") + blog.Errorf("sdk client install failed, %s, "+ + "namespace %s, name %s", err.Error(), config.Namespace, config.Name) + return nil, err + } + if err != nil { blog.Errorf("sdk client install failed, %s, "+ "namespace %s, name %s", err.Error(), config.Namespace, config.Name) - return getHelmInstallResult(r), err + return getHelmInstallResult(re), err } blog.Infof("sdk client install release successfully name %s, namespace %s, revision: %d, dryrun: %t", - config.Name, config.Namespace, r.Version, config.DryRun) - return getHelmInstallResult(r), nil + config.Name, config.Namespace, re.Version, config.DryRun) + return getHelmInstallResult(re), nil } // Upgrade helm release through helm client @@ -255,13 +295,13 @@ func (c *client) Upgrade(ctx context.Context, config release.HelmUpgradeConfig) config.DryRun) conf := new(action.Configuration) - if err := conf.Init(c.getConfigFlag(config.Namespace), config.Namespace, "", blog.Infof); err != nil { + if err := conf.Init(c.getConfigFlag(config.Namespace), config.Namespace, ""); err != nil { blog.Errorf("sdk client upgrade and init configuration failed, %s, %v", err.Error(), config) return nil, err } upgrader := action.NewUpgrade(conf) - upgrader.DryRun = config.DryRun + upgrader.DryRunStrategy = config.DryRunStrategy upgrader.Namespace = config.Namespace upgrader.PostRenderer = newPatcher(c.group.config.PatchTemplates, config.PatchTemplateValues) valueOpts := &values.Options{} @@ -299,6 +339,25 @@ func (c *client) Upgrade(ctx context.Context, config release.HelmUpgradeConfig) } r, err := upgrader.Run(ctx, config.Name, chartF, values) + + if r == nil { + err = fmt.Errorf("release is nil") + blog.Errorf("sdk client upgrade failed, %s, "+ + "namespace %s, name %s", err.Error(), config.Namespace, config.Name) + return nil, err + } + + var ( + ok bool + re *rspb.Release + ) + if re, ok = r.(*rspb.Release); !ok { + err = fmt.Errorf("release type error") + blog.Errorf("sdk client install failed, %s, "+ + "namespace %s, name %s", err.Error(), config.Namespace, config.Name) + return nil, err + } + if err != nil { // install when upgrade has --install args and release is not exist if e, ok := err.(*driver.StorageDriverError); ok && upgrader.Install && @@ -314,12 +373,12 @@ func (c *client) Upgrade(ctx context.Context, config release.HelmUpgradeConfig) } blog.Errorf("sdk client upgrade failed, %s, "+ "namespace %s, name %s", err.Error(), config.Namespace, config.Name) - return getHelmUpgradeResult(r), err + return getHelmUpgradeResult(re), err } blog.Infof("sdk client upgrade release successfully name %s, namespace %s, revision: %d", - config.Name, config.Namespace, r.Version) - return getHelmUpgradeResult(r), nil + config.Name, config.Namespace, re.Version) + return getHelmUpgradeResult(re), nil } // Uninstall helm release through helm client @@ -327,14 +386,14 @@ func (c *client) Uninstall(_ context.Context, config release.HelmUninstallConfig *release.HelmUninstallResult, error) { conf := new(action.Configuration) - if err := conf.Init(c.getConfigFlag(config.Namespace), config.Namespace, "", blog.Infof); err != nil { + if err := conf.Init(c.getConfigFlag(config.Namespace), config.Namespace, ""); err != nil { blog.Errorf("sdk client uninstall and init configuration failed, %s, %v", err.Error(), config) return nil, err } uninstaller := action.NewUninstall(conf) uninstaller.DryRun = config.DryRun - uninstaller.Wait = true + uninstaller.WaitStrategy = kube.StatusWatcherStrategy uninstaller.Timeout = 10 * time.Minute uninstaller.DisableOpenAPIValidation = true @@ -351,13 +410,13 @@ func (c *client) Uninstall(_ context.Context, config release.HelmUninstallConfig // Rollback helm release through helm client func (c *client) Rollback(_ context.Context, config release.HelmRollbackConfig) (*release.HelmRollbackResult, error) { conf := new(action.Configuration) - if err := conf.Init(c.getConfigFlag(config.Namespace), config.Namespace, "", blog.Infof); err != nil { + if err := conf.Init(c.getConfigFlag(config.Namespace), config.Namespace, ""); err != nil { blog.Errorf("sdk client rollback and init configuration failed, %s, %v", err.Error(), config) return nil, err } rollbacker := action.NewRollback(conf) - rollbacker.DryRun = config.DryRun + rollbacker.DryRunStrategy = config.DryRunStrategy rollbacker.Version = config.Revision if err := rollbacker.Run(config.Name); err != nil { @@ -372,7 +431,7 @@ func (c *client) Rollback(_ context.Context, config release.HelmRollbackConfig) // History get helm release history func (c *client) History(_ context.Context, namespace, name string, max int) ([]*rspb.Release, error) { conf := new(action.Configuration) - if err := conf.Init(c.getConfigFlag(namespace), namespace, "", blog.Infof); err != nil { + if err := conf.Init(c.getConfigFlag(namespace), namespace, ""); err != nil { return nil, err } conf.Releases.MaxHistory = max @@ -381,10 +440,19 @@ func (c *client) History(_ context.Context, namespace, name string, max int) ([] if err != nil { return nil, err } + + res := make([]*rspb.Release, 0) for i := range releases { - releases[i].Config = removeValuesTemplate(releases[i].Config) + if releases[i] == nil { + continue + } + + if re, ok := releases[i].(*rspb.Release); ok { + re.Config = removeValuesTemplate(re.Config) + res = append(res, re) + } } - return releases, nil + return res, nil } // tokenTransport 用于在请求头中添加 Authorization 头 @@ -486,13 +554,13 @@ func (c *client) getVarValue( // getChartFile 从下载的tar包中获取chart数据 func getChartFile(f *release.File) (*chart.Chart, error) { - bufferedFile, err := loader.LoadArchiveFiles(bytes.NewReader(f.Content)) + bufferedFile, err := archive.LoadArchiveFiles(bytes.NewReader(f.Content)) if err != nil { return nil, err } // 忽略 values.schema.json - bufferedFile = lo.Reject(bufferedFile, func(v *loader.BufferedFile, _ int) bool { + bufferedFile = lo.Reject(bufferedFile, func(v *archive.BufferedFile, _ int) bool { return v.Name == "values.schema.json" }) @@ -606,10 +674,10 @@ func parseArgs4Install(install *action.Install, args []string, valueOpts *values "This is unsafe in production") f.DurationVar(&install.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") - f.BoolVar(&install.Wait, "wait", false, - "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, "+ - "StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. "+ - "It will wait for as long as --timeout") + // f.BoolVar(&install.Wait, "wait", false, + // "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, "+ + // "StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. "+ + // "It will wait for as long as --timeout") f.BoolVar(&install.WaitForJobs, "wait-for-jobs", false, "if set and --wait enabled, will wait until all Jobs have been completed before marking the "+ "release as successful. It will wait for as long as --timeout") @@ -624,19 +692,23 @@ func parseArgs4Install(install *action.Install, args []string, valueOpts *values f.BoolVar(&install.DisableOpenAPIValidation, "disable-openapi-validation", true, "if set, the installation process will not validate rendered templates against "+ "the Kubernetes OpenAPI Schema") - f.BoolVar(&install.Atomic, "atomic", false, - "if set, the installation process deletes the installation on failure. "+ - "The --wait flag will be set automatically if --atomic is used") + // f.BoolVar(&install.Atomic, "atomic", false, + // "if set, the installation process deletes the installation on failure. "+ + // "The --wait flag will be set automatically if --atomic is used") + f.BoolVar(&install.RollbackOnFailure, "rollback-on-failure", false, "if set, Helm will rollback (uninstall) the installation upon failure. The --wait flag will be default to \"watcher\" if --rollback-on-failure is set") + f.BoolVar(&install.RollbackOnFailure, "atomic", false, "deprecated") + f.MarkDeprecated("atomic", "use --rollback-on-failure instead") f.IntVar(&_maxHistory, "history-max", defaultMaxHistory, "limit the maximum number of revisions saved "+ "per release. Use 0 for no limit") f.BoolVar(&install.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed. By default, CRDs are installed if not already present") f.BoolVar(&install.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent") - f.BoolVar(&install.ChartPathOptions.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, + f.BoolVar(&install.ChartPathOptions.InsecureSkipTLSVerify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download") addValueOptionsFlags(f, valueOpts) + AddWaitFlag(f, &install.WaitStrategy) return f.Parse(args) } @@ -656,10 +728,13 @@ func parseArgs4Upgrade(upgrade *action.Upgrade, args []string, valueOpts *values f.BoolVar(&_createNamespace, "create-namespace", false, "create the release namespace if not present") f.BoolVar(&upgrade.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored") - f.BoolVar(&upgrade.Recreate, "recreate-pods", false, - "performs pods restart for the resource if applicable") - f.BoolVar(&upgrade.Force, "force", false, - "force resource updates through a replacement strategy") + // f.BoolVar(&upgrade.Recreate, "recreate-pods", false, + // "performs pods restart for the resource if applicable") + // f.BoolVar(&upgrade.Force, "force", false, + // "force resource updates through a replacement strategy") + f.BoolVar(&upgrade.ForceReplace, "force-replace", false, "force resource updates by replacement") + f.BoolVar(&upgrade.ForceReplace, "force", false, "deprecated") + f.MarkDeprecated("force", "use --force-replace instead") f.BoolVar(&upgrade.DisableHooks, "no-hooks", false, "disable pre/post upgrade hooks") f.BoolVar(&upgrade.DisableOpenAPIValidation, "disable-openapi-validation", true, @@ -675,16 +750,19 @@ func parseArgs4Upgrade(upgrade *action.Upgrade, args []string, valueOpts *values f.BoolVar(&upgrade.ReuseValues, "reuse-values", false, "when upgrading, reuse the last release's values and merge in any overrides from the command line via "+ "--set and -f. If '--reset-values' is specified, this is ignored") - f.BoolVar(&upgrade.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, "+ - "and minimum number of Pods of a Deployment, StatefulSet, "+ - "or ReplicaSet are in a ready state before marking the release as successful. "+ - "It will wait for as long as --timeout") + // f.BoolVar(&upgrade.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, "+ + // "and minimum number of Pods of a Deployment, StatefulSet, "+ + // "or ReplicaSet are in a ready state before marking the release as successful. "+ + // "It will wait for as long as --timeout") f.BoolVar(&upgrade.WaitForJobs, "wait-for-jobs", false, "if set and --wait enabled, will wait until all Jobs have been completed before marking "+ "the release as successful. It will wait for as long as --timeout") - f.BoolVar(&upgrade.Atomic, "atomic", false, - "if set, upgrade process rolls back changes made in case of failed upgrade. "+ - "The --wait flag will be set automatically if --atomic is used") + // f.BoolVar(&upgrade.Atomic, "atomic", false, + // "if set, upgrade process rolls back changes made in case of failed upgrade. "+ + // "The --wait flag will be set automatically if --atomic is used") + f.BoolVar(&upgrade.RollbackOnFailure, "rollback-on-failure", false, "if set, Helm will rollback (uninstall) the installation upon failure. The --wait flag will be default to \"watcher\" if --rollback-on-failure is set") + f.BoolVar(&upgrade.RollbackOnFailure, "atomic", false, "deprecated") + f.MarkDeprecated("atomic", "use --rollback-on-failure instead") f.IntVar(&upgrade.MaxHistory, "history-max", defaultMaxHistory, "limit the maximum number of revisions saved "+ "per release. Use 0 for no limit") f.BoolVar(&upgrade.CleanupOnFail, "cleanup-on-fail", false, @@ -692,11 +770,12 @@ func parseArgs4Upgrade(upgrade *action.Upgrade, args []string, valueOpts *values f.BoolVar(&upgrade.SubNotes, "render-subchart-notes", false, "if set, render subchart notes along with the parent") f.StringVar(&upgrade.Description, "description", "", "add a custom description") - f.BoolVar(&upgrade.ChartPathOptions.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, + f.BoolVar(&upgrade.ChartPathOptions.InsecureSkipTLSVerify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download") f.BoolVar(&upgrade.Verify, "verify", false, "verify the package before using it") addValueOptionsFlags(f, valueOpts) + AddWaitFlag(f, &upgrade.WaitStrategy) return f.Parse(args) } @@ -713,6 +792,51 @@ func addValueOptionsFlags(f *pflag.FlagSet, v *values.Options) { "values with commas: key1=path1,key2=path2)") } +func AddWaitFlag(f *pflag.FlagSet, wait *kube.WaitStrategy) { + f.Var( + newWaitValue(kube.HookOnlyStrategy, wait), + "wait", + "wait until resources are ready (up to --timeout). Use '--wait' alone for 'watcher' strategy, or specify one of: 'watcher', 'hookOnly', 'legacy'. Default when flag is omitted: 'hookOnly'.", + ) + f.Lookup("wait").NoOptDefVal = string(kube.StatusWatcherStrategy) +} + +type waitValue kube.WaitStrategy + +func newWaitValue(defaultValue kube.WaitStrategy, ws *kube.WaitStrategy) *waitValue { + *ws = defaultValue + return (*waitValue)(ws) +} + +func (ws *waitValue) String() string { + if ws == nil { + return "" + } + return string(*ws) +} + +func (ws *waitValue) Set(s string) error { + switch s { + case string(kube.StatusWatcherStrategy), string(kube.LegacyStrategy), string(kube.HookOnlyStrategy): + *ws = waitValue(s) + return nil + case "true": + slog.Warn("--wait=true is deprecated (boolean value) and can be replaced with --wait=watcher") + *ws = waitValue(kube.StatusWatcherStrategy) + return nil + case "false": + slog.Warn("--wait=false is deprecated (boolean value) and can be replaced with --wait=hookOnly") + *ws = waitValue(kube.HookOnlyStrategy) + return nil + default: + return fmt.Errorf("invalid wait input %q. Valid inputs are %s, %s, and %s", s, kube.StatusWatcherStrategy, kube.HookOnlyStrategy, kube.LegacyStrategy) + } +} + +func (ws *waitValue) Type() string { + return "WaitStrategy" +} + func getHelmUpgradeResult(rl *rspb.Release) *release.HelmUpgradeResult { if rl == nil { return nil diff --git a/bcs-services/bcs-helm-manager/internal/release/release.go b/bcs-services/bcs-helm-manager/internal/release/release.go index 0300a39b84..8447c9b578 100644 --- a/bcs-services/bcs-helm-manager/internal/release/release.go +++ b/bcs-services/bcs-helm-manager/internal/release/release.go @@ -19,16 +19,17 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "gopkg.in/yaml.v2" - "helm.sh/helm/v3/pkg/chart" - "helm.sh/helm/v3/pkg/release" - helmrelease "helm.sh/helm/v3/pkg/release" - "helm.sh/helm/v3/pkg/releaseutil" + "helm.sh/helm/v4/pkg/action" + chart "helm.sh/helm/v4/pkg/chart/v2" + releaseCom "helm.sh/helm/v4/pkg/release/common" + release "helm.sh/helm/v4/pkg/release/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/cli-runtime/pkg/resource" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/utils/stringx" helmmanager "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/proto/bcs-helm-manager" + releaseutil "helm.sh/helm/v4/pkg/release/v1/util" ) const ( @@ -65,21 +66,21 @@ type Release struct { Description string Values string Manifest string - Hooks []*helmrelease.Hook + Hooks []*release.Hook Infos []*resource.Info Objects []runtime.Object Notes string } // Transfer2Release transfer the data into helm release struct -func (r *Release) Transfer2Release() *helmrelease.Release { +func (r *Release) Transfer2Release() *release.Release { if r == nil { return nil } - return &helmrelease.Release{ + return &release.Release{ Name: r.Name, - Info: &helmrelease.Info{ - Status: helmrelease.Status(r.Status), + Info: &release.Info{ + Status: releaseCom.Status(r.Status), Notes: r.Notes, }, Chart: &chart.Chart{Metadata: &chart.Metadata{Name: r.Chart}}, @@ -200,9 +201,11 @@ type ListOption struct { // HelmInstallConfig 定义了helm执行install时的控制参数 type HelmInstallConfig struct { // simulate a install action - DryRun bool - Replace bool - ClientOnly bool + // DryRun v4版本已废弃,使用DryRunStrategy替代 + DryRun bool + DryRunStrategy action.DryRunStrategy + Replace bool + ClientOnly bool ProjectCode string Name string @@ -254,7 +257,9 @@ type HelmUninstallResult struct { // HelmUpgradeConfig 定义了helm执行upgrade时的控制参数 type HelmUpgradeConfig struct { // simulate a upgrade action - DryRun bool + // DryRun v4版本已废弃,使用DryRunStrategy替代 + DryRun bool + DryRunStrategy action.DryRunStrategy ProjectCode string Name string @@ -293,7 +298,9 @@ type HelmUpgradeResult struct { // HelmRollbackConfig 定义了helm执行rollback时的控制参数 type HelmRollbackConfig struct { // simulate a rollback action - DryRun bool + // DryRun v4版本已废弃,使用DryRunStrategy替代 + DryRun bool + DryRunStrategy action.DryRunStrategy Name string Namespace string diff --git a/bcs-services/bcs-helm-manager/internal/repo/bkrepo/version.go b/bcs-services/bcs-helm-manager/internal/repo/bkrepo/version.go index a5ebae6dc5..842f99b81d 100644 --- a/bcs-services/bcs-helm-manager/internal/repo/bkrepo/version.go +++ b/bcs-services/bcs-helm-manager/internal/repo/bkrepo/version.go @@ -20,7 +20,7 @@ import ( "strconv" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "helm.sh/helm/v3/pkg/registry" + "helm.sh/helm/v4/pkg/registry" "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/repo" )