This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new 159330f2 [dubboctl] Optimize code content (#641)
159330f2 is described below
commit 159330f2998393b88edfdc947b453c74027bdec6
Author: Jian Zhong <[email protected]>
AuthorDate: Fri Mar 14 12:02:11 2025 +0800
[dubboctl] Optimize code content (#641)
---
operator/cmd/cluster/manifest.go | 2 +-
operator/cmd/cluster/uninstall.go | 2 +-
operator/pkg/apis/validation/validation.go | 10 +++++-----
operator/pkg/helm/helm.go | 4 ++--
operator/pkg/install/installer.go | 6 +++++-
5 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/operator/cmd/cluster/manifest.go b/operator/cmd/cluster/manifest.go
index 456fa881..972a7e54 100644
--- a/operator/cmd/cluster/manifest.go
+++ b/operator/cmd/cluster/manifest.go
@@ -44,7 +44,7 @@ func (a *manifestGenerateArgs) String() string {
}
func addManifestGenerateFlags(cmd *cobra.Command, args *manifestGenerateArgs) {
- cmd.PersistentFlags().StringSliceVarP(&args.filenames, "filename", "f",
nil, ``)
+ cmd.PersistentFlags().StringSliceVarP(&args.filenames, "filenames",
"f", nil, ``)
cmd.PersistentFlags().StringArrayVarP(&args.sets, "set", "s", nil, ``)
}
diff --git a/operator/cmd/cluster/uninstall.go
b/operator/cmd/cluster/uninstall.go
index 99c031b9..f7d5ba33 100644
--- a/operator/cmd/cluster/uninstall.go
+++ b/operator/cmd/cluster/uninstall.go
@@ -40,7 +40,7 @@ type uninstallArgs struct {
}
func addUninstallFlags(cmd *cobra.Command, args *uninstallArgs) {
- cmd.PersistentFlags().StringVarP(&args.filenames, "filename", "f", "",
"The filename of the DubboOperator CR.")
+ cmd.PersistentFlags().StringVarP(&args.filenames, "filenames", "f", "",
"The filename of the DubboOperator CR.")
cmd.PersistentFlags().StringArrayVarP(&args.sets, "set", "s", nil,
`Override dubboOperator values, such as selecting profiles, etc.`)
cmd.PersistentFlags().BoolVar(&args.remove, "remove", false, `Remove
all dubbo related source code.`)
cmd.PersistentFlags().BoolVarP(&args.skipConfirmation,
"skip-confirmation", "y", false, `The skipConfirmation determines whether the
user is prompted for confirmation.`)
diff --git a/operator/pkg/apis/validation/validation.go
b/operator/pkg/apis/validation/validation.go
index 9fbcdf40..b1f5cc32 100644
--- a/operator/pkg/apis/validation/validation.go
+++ b/operator/pkg/apis/validation/validation.go
@@ -30,9 +30,9 @@ import (
type Warnings = util.Errors
-func ParseAndValidateDubboOperator(dopm values.Map, client kube.CLIClient)
(Warnings, util.Errors) {
+func ParseAndValidateDubboOperator(dopMap values.Map, _ kube.CLIClient)
(Warnings, util.Errors) {
iop := &apis.DubboOperator{}
- dec := json.NewDecoder(bytes.NewBufferString(dopm.JSON()))
+ dec := json.NewDecoder(bytes.NewBufferString(dopMap.JSON()))
dec.DisallowUnknownFields()
if err := dec.Decode(iop); err != nil {
return nil, util.NewErrs(fmt.Errorf("could not unmarshal: %v",
err))
@@ -62,11 +62,11 @@ func validateFeatures(values *apis.Values, spec
apis.DubboOperatorSpec) (Warning
}
func validateValues(raw *apis.DubboOperator) (Warnings, util.Errors) {
- values := &apis.Values{}
- if err := yaml.Unmarshal(raw.Spec.Values, values); err != nil {
+ vls := &apis.Values{}
+ if err := yaml.Unmarshal(raw.Spec.Values, vls); err != nil {
return nil, util.NewErrs(fmt.Errorf("could not unmarshal: %v",
err))
}
- warnings, errs := validateFeatures(values, raw.Spec)
+ warnings, errs := validateFeatures(vls, raw.Spec)
return warnings, errs
}
diff --git a/operator/pkg/helm/helm.go b/operator/pkg/helm/helm.go
index 03515614..86032c2c 100644
--- a/operator/pkg/helm/helm.go
+++ b/operator/pkg/helm/helm.go
@@ -51,8 +51,8 @@ func Reader(namespace string, directory string, dop
values.Map) ([]manifest.Mani
return nil, nil, fmt.Errorf("failed to get values from dop:
%v", ok)
}
path := pathJoin("charts", directory)
- pkgPath := dop.GetPathString("spec.packagePath")
- f := manifests.BuiltinDir(pkgPath)
+ // pkgPath := dop.GetPathString("spec.packagePath")
+ f := manifests.BuiltinDir("")
chrt, err := loadChart(f, path)
output, warnings, err := readerChart(namespace, vals, chrt)
if err != nil {
diff --git a/operator/pkg/install/installer.go
b/operator/pkg/install/installer.go
index 1b1d9ba3..0c278f25 100644
--- a/operator/pkg/install/installer.go
+++ b/operator/pkg/install/installer.go
@@ -63,6 +63,7 @@ func (i Installer) install(manifests []manifest.ManifestSet)
error {
})...)
dependencyWaitCh := dependenciesChannels()
for _, mfs := range manifests {
+ mfs := mfs
c := mfs.Components
m := mfs.Manifests
disabledComponents.Delete(c)
@@ -209,7 +210,9 @@ func (i Installer) prune(manifests []manifest.ManifestSet)
error {
if err != nil {
return err
}
- objs, err := dc.List(context.Background(),
metav1.ListOptions{LabelSelector: selector.String()})
+ objs, err := dc.List(context.Background(), metav1.ListOptions{
+ LabelSelector: selector.String(),
+ })
if objs == nil {
continue
}
@@ -263,6 +266,7 @@ func getOwnerLabels(dop values.Map, c string)
map[string]string {
if n := dop.GetPathString("metadata.namespace"); n != "" {
labels[manifest.OwningResourceNamespace] = n
}
+
if c != "" {
labels[manifest.DubboComponentLabel] = c
}