diff --git a/.github/workflows/cicd-pull-request.yml b/.github/workflows/cicd-pull-request.yml index c11de4c68..1b01044aa 100644 --- a/.github/workflows/cicd-pull-request.yml +++ b/.github/workflows/cicd-pull-request.yml @@ -7,7 +7,7 @@ on: env: GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} BASE_BRANCH: origin/main - GO_VERSION: "1.24" + GO_VERSION: "1.25" jobs: trigger-mode: @@ -62,7 +62,7 @@ jobs: - name: Install golangci-lint run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.8 + curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.8.0 - name: make module run: | diff --git a/.github/workflows/cicd-push.yml b/.github/workflows/cicd-push.yml index 23265718c..24e57f143 100644 --- a/.github/workflows/cicd-push.yml +++ b/.github/workflows/cicd-push.yml @@ -11,7 +11,7 @@ on: env: GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} BASE_BRANCH: origin/main - GO_VERSION: "1.24" + GO_VERSION: "1.25" jobs: trigger-mode: @@ -139,7 +139,7 @@ jobs: - name: Install golangci-lint run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.8 + curl -sSfL https://golangci-lint.run/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.8.0 - name: make module run: | diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ece6d4162..ba170e03a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -8,7 +8,7 @@ on: env: BASE_BRANCH: origin/main - GO_VERSION: "1.24" + GO_VERSION: "1.25" jobs: trigger-mode: diff --git a/.github/workflows/release-kbcli.yml b/.github/workflows/release-kbcli.yml index fd4fd5f67..0d512a64e 100644 --- a/.github/workflows/release-kbcli.yml +++ b/.github/workflows/release-kbcli.yml @@ -9,7 +9,7 @@ env: GH_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} TAG_NAME: ${{ github.ref_name }} - GO_VERSION: "1.24" + GO_VERSION: "1.25" CLI_NAME: 'kbcli' JIHULAB_KBCLI_PROJECT_ID: 85948 JIHULAB_ACCESS_TOKEN: ${{ secrets.GITLAB_ACCESS_TOKEN }} diff --git a/.golangci.yaml b/.golangci.yaml index 59ada0b79..fd91a56aa 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,52 +1,39 @@ -# options for analysis running +version: "2" run: - # default concurrency is a available CPU number concurrency: 4 - - # timeout for analysis, e.g. 30s, 5m, default is 1m - deadline: 15m - - timeout: 30m - - skip-files: - - "^zz_generated.*" - build-tags: - containers_image_openpgp - -output: - # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: colored-line-number - - # print lines of code with issue, default is true - print-issued-lines: true - - # print linter name in the end of issue text, default is true - print-linter-name: true - -# check available linters @ https://golangci-lint.run/usage/linters/ linters: - disable-all: true - enable: # please keep this alphabetized - # Don't use soon to deprecated[1] linters that lead to false - # https://github.com/golangci/golangci-lint/issues/1841 - # - deadcode - # - gocyclo - # - loggercheck # requires golangci-lint@v1.49.0 - # - structcheck - # - varcheck + default: none + enable: - errcheck - gocritic - # - goconst - - goimports - - gofmt # We enable this as well as goimports for its simplify mode. - govet - ineffassign - - typecheck - misspell - nakedret - unconvert - -linters-settings: - errcheck: - check-blank: false # to keep `_ = viper.BindPFlag(...)` from throwing errors + settings: + errcheck: + check-blank: false + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index 455ba3382..86fcadb16 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ mod-download: ## Run go mod download against go modules. .PHONY: module module: ## Run go mod tidy->verify against go modules. - $(GO) mod tidy -compat=1.24 + $(GO) mod tidy -compat=1.25 $(GO) mod verify TEST_PACKAGES ?= ./pkg/... ./cmd/... @@ -257,16 +257,19 @@ install-docker-buildx: ## Create `docker buildx` builder. fi .PHONY: golangci -golangci: GOLANGCILINT_VERSION = v1.64.8 +golangci: GOLANGCILINT_VERSION = v2.8.0 golangci: ## Download golangci-lint locally if necessary. -ifneq ($(shell which golangci-lint),) +ifeq ($(shell golangci-lint version >/dev/null 2>&1 && echo ok),ok) @echo golangci-lint is already installed GOLANGCILINT=$(shell which golangci-lint) else ifeq (, $(shell which $(GOBIN)/golangci-lint)) @{ \ set -e ;\ echo 'installing golangci-lint-$(GOLANGCILINT_VERSION)' ;\ - curl -sSfL $(GITHUB_PROXY)https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) $(GOLANGCILINT_VERSION) ;\ + tmpfile=$$(mktemp) ;\ + trap 'rm -f "$$tmpfile"' EXIT ;\ + curl -sSfL https://golangci-lint.run/install.sh -o "$$tmpfile" ;\ + sh "$$tmpfile" -b $(GOBIN) $(GOLANGCILINT_VERSION) ;\ echo 'Successfully installed' ;\ } GOLANGCILINT=$(GOBIN)/golangci-lint diff --git a/docs/user_docs/cli/kbcli_cluster_create.md b/docs/user_docs/cli/kbcli_cluster_create.md index cec4d416f..6c3805622 100644 --- a/docs/user_docs/cli/kbcli_cluster_create.md +++ b/docs/user_docs/cli/kbcli_cluster_create.md @@ -55,24 +55,14 @@ kbcli cluster create [ClusterType] [flags] * [kbcli cluster](kbcli_cluster.md) - Cluster command. * [kbcli cluster create apecloud-mysql](kbcli_cluster_create_apecloud-mysql.md) - Create a apecloud-mysql cluster. -* [kbcli cluster create clickhouse](kbcli_cluster_create_clickhouse.md) - Create a clickhouse cluster. * [kbcli cluster create etcd](kbcli_cluster_create_etcd.md) - Create a etcd cluster. -* [kbcli cluster create greptime](kbcli_cluster_create_greptime.md) - Create a greptime cluster. * [kbcli cluster create kafka](kbcli_cluster_create_kafka.md) - Create a kafka cluster. -* [kbcli cluster create loki](kbcli_cluster_create_loki.md) - Create a loki cluster. -* [kbcli cluster create milvus](kbcli_cluster_create_milvus.md) - Create a milvus cluster. -* [kbcli cluster create minio](kbcli_cluster_create_minio.md) - Create a minio cluster. * [kbcli cluster create mongodb](kbcli_cluster_create_mongodb.md) - Create a mongodb cluster. * [kbcli cluster create mysql](kbcli_cluster_create_mysql.md) - Create a mysql cluster. -* [kbcli cluster create oceanbase](kbcli_cluster_create_oceanbase.md) - Create a oceanbase cluster. -* [kbcli cluster create orchestrator](kbcli_cluster_create_orchestrator.md) - Create a orchestrator cluster. -* [kbcli cluster create polardbx](kbcli_cluster_create_polardbx.md) - Create a polardbx cluster. * [kbcli cluster create postgresql](kbcli_cluster_create_postgresql.md) - Create a postgresql cluster. -* [kbcli cluster create pulsar](kbcli_cluster_create_pulsar.md) - Create a pulsar cluster. * [kbcli cluster create qdrant](kbcli_cluster_create_qdrant.md) - Create a qdrant cluster. * [kbcli cluster create rabbitmq](kbcli_cluster_create_rabbitmq.md) - Create a rabbitmq cluster. * [kbcli cluster create redis](kbcli_cluster_create_redis.md) - Create a redis cluster. -* [kbcli cluster create victoria-metrics](kbcli_cluster_create_victoria-metrics.md) - Create a victoria-metrics cluster. #### Go Back to [CLI Overview](cli.md) Homepage. diff --git a/docs/user_docs/cli/kbcli_cluster_create_apecloud-mysql.md b/docs/user_docs/cli/kbcli_cluster_create_apecloud-mysql.md index b8ca2c109..e654ed265 100644 --- a/docs/user_docs/cli/kbcli_cluster_create_apecloud-mysql.md +++ b/docs/user_docs/cli/kbcli_cluster_create_apecloud-mysql.md @@ -21,29 +21,37 @@ kbcli cluster create apecloud-mysql NAME [flags] ### Options ``` - --availability-policy string The availability policy of cluster. Legal values [none, node, zone]. (default "node") - --cpu float CPU cores. Value range [0.5, 64]. (default 0.5) - --disable-exporter Enable or disable monitor. (default true) - --dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none") - --edit Edit the API resource before creating - -h, --help help for apecloud-mysql - --host-network-accessible Specify whether the cluster can be accessed from within the VPC. - --memory float Memory, the unit is Gi. Value range [0.5, 1000]. (default 0.5) - --mode string Cluster topology mode. Legal values [standalone, raftGroup]. (default "standalone") - --node-labels stringToString Node label selector (default []) - -o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml) - --pod-anti-affinity string Pod anti-affinity type, one of: (Preferred, Required) (default "Preferred") - --proxy-enabled Enable proxy or not. - --publicly-accessible Specify whether the cluster can be accessed from the public internet. - --rbac-enabled Specify whether rbac resources will be created by client, otherwise KubeBlocks server will try to create rbac resources. - --replicas int The number of replicas, for standalone mode, the replicas is 1, for raftGroup mode, the default replicas is 3. Value range [1, 5]. (default 1) - --storage float Storage size, the unit is Gi. Value range [1, 10000]. (default 20) - --storage-class-name string Storage class name of the data volume - --tenancy string The tenancy of cluster. Legal values [SharedNode, DedicatedNode]. (default "SharedNode") - --termination-policy string The termination policy of cluster. Legal values [DoNotTerminate, Halt, Delete, WipeOut]. (default "Delete") - --tolerations strings Tolerations for cluster, such as "key=value:effect,key:effect", for example '"engineType=mongo:NoSchedule", "diskType:NoSchedule"' - --topology-keys stringArray Topology keys for affinity - --version string Cluster version. (default "ac-mysql-8.0.30") + --cpu float CPU cores. Value range [0.5, 64]. (default 0.5) + --disable-exporter Enable or disable monitor. (default true) + --dry-run string[="unchanged"] Must be "client", or "server". If with client strategy, only print the object that would be sent, and no data is actually sent. If with server strategy, submit the server-side request, but no data is persistent. (default "none") + --edit Edit the API resource before creating + --etcd.local.etcdctl-api string (default "3") + --etcd.local.replicas int Value range [1, 3]. (default 3) + --etcd.local.resources.storage string (default "20Gi") + --etcd.local.service-version string (default "3.5.6") + --etcd.mode string Legal values [serviceRef, local]. (default "local") + --etcd.service-ref.cluster.component string (default "etcd") + --etcd.service-ref.cluster.credential string + --etcd.service-ref.cluster.name string + --etcd.service-ref.cluster.port string (default "client") + --etcd.service-ref.cluster.service string (default "headless") + --etcd.service-ref.namespace string (default "default") + --etcd.service-ref.service-descriptor string + -h, --help help for apecloud-mysql + --memory float Memory, the unit is Gi. Value range [0.5, 1000]. (default 0.5) + --mode string Cluster topology mode. Legal values [standalone, raftGroup]. (default "standalone") + --node-labels stringToString Node label selector (default []) + -o, --output format Prints the output in the specified format. Allowed values: JSON and YAML (default yaml) + --pod-anti-affinity string Pod anti-affinity type, one of: (Preferred, Required) (default "Preferred") + --proxy-enabled Enable proxy or not. + --replicas int The number of replicas, for standalone mode, the replicas is 1, for raftGroup mode, the default replicas is 3. Value range [1, 5]. (default 1) + --storage float Storage size, the unit is Gi. Value range [1, 10000]. (default 20) + --storage-class-name string Storage class name of the data volume + --tenancy string Tenancy options, one of: (SharedNode, DedicatedNode) (default "SharedNode") + --termination-policy string The termination policy of cluster. Legal values [DoNotTerminate, Delete, WipeOut]. (default "Delete") + --tolerations strings Tolerations for cluster, such as "key=value:effect,key:effect", for example '"engineType=mongo:NoSchedule", "diskType:NoSchedule"' + --topology-keys stringArray Topology keys for affinity + --version string MySQL Service Version. (default "8.0.30") ``` ### Options inherited from parent commands diff --git a/docs/user_docs/cli/kbcli_cluster_custom-ops.md b/docs/user_docs/cli/kbcli_cluster_custom-ops.md index aed0490b9..8bd6e19e2 100644 --- a/docs/user_docs/cli/kbcli_cluster_custom-ops.md +++ b/docs/user_docs/cli/kbcli_cluster_custom-ops.md @@ -57,35 +57,6 @@ kbcli cluster custom-ops OpsDef --cluster [fl ### SEE ALSO * [kbcli cluster](kbcli_cluster.md) - Cluster command. -* [kbcli cluster custom-ops add-arch-for-dm](kbcli_cluster_custom-ops_add-arch-for-dm.md) - Create a custom ops with opsDef add-arch-for-dm -* [kbcli cluster custom-ops hdfs-balancer](kbcli_cluster_custom-ops_hdfs-balancer.md) - Create a custom ops with opsDef hdfs-balancer -* [kbcli cluster custom-ops hive-server2-apply-account](kbcli_cluster_custom-ops_hive-server2-apply-account.md) - Create a custom ops with opsDef hive-server2-apply-account -* [kbcli cluster custom-ops kafka-quota](kbcli_cluster_custom-ops_kafka-quota.md) - Create a custom ops with opsDef kafka-quota -* [kbcli cluster custom-ops kafka-topic](kbcli_cluster_custom-ops_kafka-topic.md) - Create a custom ops with opsDef kafka-topic -* [kbcli cluster custom-ops kafka-user-acl](kbcli_cluster_custom-ops_kafka-user-acl.md) - Create a custom ops with opsDef kafka-user-acl -* [kbcli cluster custom-ops mongodb-shard-toggle-balancer](kbcli_cluster_custom-ops_mongodb-shard-toggle-balancer.md) - Create a custom ops with opsDef mongodb-shard-toggle-balancer -* [kbcli cluster custom-ops mssql-dynamic-modify-member](kbcli_cluster_custom-ops_mssql-dynamic-modify-member.md) - Create a custom ops with opsDef mssql-dynamic-modify-member -* [kbcli cluster custom-ops mssql-dynamic-modify-member-1.0.0](kbcli_cluster_custom-ops_mssql-dynamic-modify-member-1.0.0.md) - Create a custom ops with opsDef mssql-dynamic-modify-member-1.0.0 -* [kbcli cluster custom-ops mssql-dynamic-remove-ag](kbcli_cluster_custom-ops_mssql-dynamic-remove-ag.md) - Create a custom ops with opsDef mssql-dynamic-remove-ag -* [kbcli cluster custom-ops mssql-dynamic-remove-ag-1.0.0](kbcli_cluster_custom-ops_mssql-dynamic-remove-ag-1.0.0.md) - Create a custom ops with opsDef mssql-dynamic-remove-ag-1.0.0 -* [kbcli cluster custom-ops mssql-dynamic-remove-member](kbcli_cluster_custom-ops_mssql-dynamic-remove-member.md) - Create a custom ops with opsDef mssql-dynamic-remove-member -* [kbcli cluster custom-ops mssql-dynamic-remove-member-1.0.0](kbcli_cluster_custom-ops_mssql-dynamic-remove-member-1.0.0.md) - Create a custom ops with opsDef mssql-dynamic-remove-member-1.0.0 -* [kbcli cluster custom-ops nebula-balance-data](kbcli_cluster_custom-ops_nebula-balance-data.md) - Create a custom ops with opsDef nebula-balance-data -* [kbcli cluster custom-ops ob-alter-unit](kbcli_cluster_custom-ops_ob-alter-unit.md) - Create a custom ops with opsDef ob-alter-unit -* [kbcli cluster custom-ops ob-switch-configserver](kbcli_cluster_custom-ops_ob-switch-configserver.md) - Create a custom ops with opsDef ob-switch-configserver -* [kbcli cluster custom-ops pg-update-standby-config](kbcli_cluster_custom-ops_pg-update-standby-config.md) - Create a custom ops with opsDef pg-update-standby-config -* [kbcli cluster custom-ops post-rebuild-for-clickhouse](kbcli_cluster_custom-ops_post-rebuild-for-clickhouse.md) - Create a custom ops with opsDef post-rebuild-for-clickhouse -* [kbcli cluster custom-ops post-scale-for-dmdb](kbcli_cluster_custom-ops_post-scale-for-dmdb.md) - Create a custom ops with opsDef post-scale-for-dmdb -* [kbcli cluster custom-ops post-scale-out-shard-for-clickhouse](kbcli_cluster_custom-ops_post-scale-out-shard-for-clickhouse.md) - Create a custom ops with opsDef post-scale-out-shard-for-clickhouse -* [kbcli cluster custom-ops redis-cluster-rebalance](kbcli_cluster_custom-ops_redis-cluster-rebalance.md) - Create a custom ops with opsDef redis-cluster-rebalance -* [kbcli cluster custom-ops redis-master-account-ops](kbcli_cluster_custom-ops_redis-master-account-ops.md) - Create a custom ops with opsDef redis-master-account-ops -* [kbcli cluster custom-ops redis-reset-master](kbcli_cluster_custom-ops_redis-reset-master.md) - Create a custom ops with opsDef redis-reset-master -* [kbcli cluster custom-ops redis-sentinel-account-ops](kbcli_cluster_custom-ops_redis-sentinel-account-ops.md) - Create a custom ops with opsDef redis-sentinel-account-ops -* [kbcli cluster custom-ops redis-shard-account-ops](kbcli_cluster_custom-ops_redis-shard-account-ops.md) - Create a custom ops with opsDef redis-shard-account-ops -* [kbcli cluster custom-ops remove-remote-arch](kbcli_cluster_custom-ops_remove-remote-arch.md) - Create a custom ops with opsDef remove-remote-arch -* [kbcli cluster custom-ops switchover-for-dm](kbcli_cluster_custom-ops_switchover-for-dm.md) - Create a custom ops with opsDef switchover-for-dm -* [kbcli cluster custom-ops update-license-for-dm](kbcli_cluster_custom-ops_update-license-for-dm.md) - Create a custom ops with opsDef update-license-for-dm -* [kbcli cluster custom-ops update-license-for-kingbase](kbcli_cluster_custom-ops_update-license-for-kingbase.md) - Create a custom ops with opsDef update-license-for-kingbase #### Go Back to [CLI Overview](cli.md) Homepage. diff --git a/go.mod b/go.mod index 4b661d75d..8c0a8f079 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/apecloud/kbcli -go 1.24.0 +go 1.25.0 -toolchain go1.24.9 +toolchain go1.25.10 require ( cuelang.org/go v0.8.0 diff --git a/pkg/cmd/kubeblocks/config.go b/pkg/cmd/kubeblocks/config.go index 56e49ce6f..831a392dd 100644 --- a/pkg/cmd/kubeblocks/config.go +++ b/pkg/cmd/kubeblocks/config.go @@ -107,7 +107,7 @@ func configKBRelease(o *InstallOptions) error { if kbRelease != nil && kbRelease.Chart != nil && kbRelease.Chart.Metadata != nil { kbVersion = kbRelease.Chart.Metadata.Version } - s := spinner.New(o.Out, spinnerMsg("Config KubeBlocks "+kbVersion)) + s := spinner.New(o.Out, spinnerMsg("Config KubeBlocks %s", kbVersion)) defer s.Fail() o.disableHelmPreHookJob() // upgrade KubeBlocks chart diff --git a/pkg/cmd/kubeblocks/install.go b/pkg/cmd/kubeblocks/install.go index 61b2b86ed..8cdcc37b1 100644 --- a/pkg/cmd/kubeblocks/install.go +++ b/pkg/cmd/kubeblocks/install.go @@ -299,7 +299,7 @@ func (o *InstallOptions) Install() error { s.Success() // add helm repo - s = spinner.New(o.Out, spinnerMsg("Add and update repo "+types.KubeBlocksRepoName)) + s = spinner.New(o.Out, spinnerMsg("Add and update repo %s", types.KubeBlocksRepoName)) defer s.Fail() // Add repo, if exists, will update it if err = helm.AddRepo(newHelmRepoEntry()); err != nil { @@ -308,7 +308,7 @@ func (o *InstallOptions) Install() error { s.Success() // install KubeBlocks - s = spinner.New(o.Out, spinnerMsg("Install KubeBlocks "+o.Version)) + s = spinner.New(o.Out, spinnerMsg("Install KubeBlocks %s", o.Version)) defer s.Fail() getImageRegistry := func() string { @@ -460,7 +460,7 @@ func (o *InstallOptions) waitAddonsEnabled() error { msg := "" header := "Wait for addons to be enabled" failedErr := errors.New("some addons are failed to be enabled") - s := spinner.New(o.Out, spinnerMsg(header)) + s := spinner.New(o.Out, spinnerMsg("Wait for addons to be enabled")) var ( spinnerDone = func() { diff --git a/pkg/cmd/kubeblocks/install_1.0.go b/pkg/cmd/kubeblocks/install_1.0.go index edb1951c6..990f224d0 100644 --- a/pkg/cmd/kubeblocks/install_1.0.go +++ b/pkg/cmd/kubeblocks/install_1.0.go @@ -85,7 +85,7 @@ func (o *InstallOptions) preInstallWhenUpgradeFrom09() error { deploy := &kbDeploys[i] kbVersion := deploy.Labels[constant.AppVersionLabelKey] o.kb09Namespace = deploy.Namespace - s := spinner.New(o.Out, spinnerMsg(fmt.Sprintf("Stop %s %s", msgKey, kbVersion))) + s := spinner.New(o.Out, spinnerMsg("Stop %s %s", msgKey, kbVersion)) if err = o.stopDeploymentObject(s, deploy); err != nil { return err } diff --git a/pkg/cmd/kubeblocks/upgrade.go b/pkg/cmd/kubeblocks/upgrade.go index f8c1f2ff2..e9f33e61e 100644 --- a/pkg/cmd/kubeblocks/upgrade.go +++ b/pkg/cmd/kubeblocks/upgrade.go @@ -178,7 +178,7 @@ func (o *InstallOptions) Upgrade() error { } // add helm repo - s := spinner.New(o.Out, spinnerMsg("Add and update repo "+types.KubeBlocksChartName)) + s := spinner.New(o.Out, spinnerMsg("Add and update repo %s", types.KubeBlocksChartName)) defer s.Fail() // Add repo, if exists, will update it if err = helm.AddRepo(newHelmRepoEntry()); err != nil { @@ -200,7 +200,7 @@ func (o *InstallOptions) Upgrade() error { // stop the old version KubeBlocks, otherwise the old version KubeBlocks will reconcile the // new version resources, which may be not compatible. helm will start the new version // KubeBlocks after upgrade. - s = spinner.New(o.Out, spinnerMsg("Stop KubeBlocks "+kbVersion)) + s = spinner.New(o.Out, spinnerMsg("Stop KubeBlocks %s", kbVersion)) if err = o.stopDeployment(s, util.GetKubeBlocksDeploy); err != nil { return err } @@ -244,7 +244,7 @@ func (o *InstallOptions) Upgrade() error { s.Success() } - s = spinner.New(o.Out, spinnerMsg("Upgrading KubeBlocks "+msg)) + s = spinner.New(o.Out, spinnerMsg("Upgrading KubeBlocks %s", msg)) defer s.Fail() o.disableHelmPreHookJob() // upgrade KubeBlocks chart diff --git a/pkg/cmd/playground/destroy.go b/pkg/cmd/playground/destroy.go index 93634811f..8512e695c 100644 --- a/pkg/cmd/playground/destroy.go +++ b/pkg/cmd/playground/destroy.go @@ -104,7 +104,7 @@ func (o *destroyOptions) destroy() error { // destroyLocal destroy local k3d cluster that will destroy all resources func (o *destroyOptions) destroyLocal() error { provider, _ := cp.New(cp.Local, "", o.Out, o.ErrOut) - s := spinner.New(o.Out, spinnerMsg("Delete playground k3d cluster "+o.prevCluster.ClusterName)) + s := spinner.New(o.Out, spinnerMsg("Delete playground k3d cluster %s", o.prevCluster.ClusterName)) defer s.Fail() if err := provider.DeleteK8sCluster(o.prevCluster); err != nil { if !strings.Contains(err.Error(), "no cluster found") && @@ -358,7 +358,7 @@ func (o *destroyOptions) uninstallKubeBlocks(client kubernetes.Interface, dynami } func (o *destroyOptions) removeKubeConfig() error { - s := spinner.New(o.Out, spinnerMsg("Remove kubeconfig from "+defaultKubeConfigPath)) + s := spinner.New(o.Out, spinnerMsg("Remove kubeconfig from %s", defaultKubeConfigPath)) defer s.Fail() if err := kubeConfigRemove(o.prevCluster.KubeConfig, defaultKubeConfigPath); err != nil { if os.IsNotExist(err) { diff --git a/pkg/cmd/playground/init.go b/pkg/cmd/playground/init.go index e2f71ce5a..78ffba48f 100644 --- a/pkg/cmd/playground/init.go +++ b/pkg/cmd/playground/init.go @@ -227,7 +227,7 @@ func (o *initOptions) local() error { } // create a local kubernetes cluster (k3d cluster) to deploy KubeBlocks - s := spinner.New(o.Out, spinnerMsg("Create k3d cluster: "+clusterInfo.ClusterName)) + s := spinner.New(o.Out, spinnerMsg("Create k3d cluster: %s", clusterInfo.ClusterName)) defer s.Fail() if err = provider.CreateK8sCluster(clusterInfo); err != nil { return errors.Wrap(err, "failed to set up k3d cluster") @@ -379,7 +379,7 @@ func (o *initOptions) writeStateFile(provider cp.Interface) (*cp.K8sClusterInfo, // merge created kubernetes cluster kubeconfig to ~/.kube/config and set it as default func (o *initOptions) setKubeConfig(info *cp.K8sClusterInfo) error { - s := spinner.New(o.Out, spinnerMsg("Merge kubeconfig to "+defaultKubeConfigPath)) + s := spinner.New(o.Out, spinnerMsg("Merge kubeconfig to %s", defaultKubeConfigPath)) defer s.Fail() // check if the default kubeconfig file exists, if not, create it @@ -399,7 +399,7 @@ func (o *initOptions) setKubeConfig(info *cp.K8sClusterInfo) error { s.Success() currentContext, err := kubeConfigCurrentContext(info.KubeConfig) - s = spinner.New(o.Out, spinnerMsg("Switch current context to "+currentContext)) + s = spinner.New(o.Out, spinnerMsg("Switch current context to %s", currentContext)) defer s.Fail() if err != nil { return err diff --git a/pkg/cmd/playground/util.go b/pkg/cmd/playground/util.go index a1186e15d..8cced7015 100644 --- a/pkg/cmd/playground/util.go +++ b/pkg/cmd/playground/util.go @@ -123,7 +123,7 @@ func readClusterInfoFromFile(path string) (*cp.K8sClusterInfo, error) { } func writeAndUseKubeConfig(kubeConfig string, kubeConfigPath string, out io.Writer) error { - s := spinner.New(out, spinnerMsg("Write kubeconfig to "+kubeConfigPath)) + s := spinner.New(out, spinnerMsg("Write kubeconfig to %s", kubeConfigPath)) defer s.Fail() if err := kubeConfigWrite(kubeConfig, kubeConfigPath, writeKubeConfigOptions{ UpdateExisting: true,