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 fb94bf70 [operator] Fix installation error logic
fb94bf70 is described below
commit fb94bf70480fd4687224acf3954fabcbc5a39e07
Author: mfordjody <[email protected]>
AuthorDate: Sat Dec 14 09:58:28 2024 +0800
[operator] Fix installation error logic
---
operator/cmd/cluster/install.go | 12 ++++++------
operator/pkg/{installer => install}/installer.go | 2 +-
operator/pkg/util/clog/clog.go | 8 ++++++++
operator/pkg/util/progress/progress.go | 2 +-
4 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/operator/cmd/cluster/install.go b/operator/cmd/cluster/install.go
index 2ce363cd..41af1d7c 100644
--- a/operator/cmd/cluster/install.go
+++ b/operator/cmd/cluster/install.go
@@ -3,7 +3,7 @@ package cluster
import (
"fmt"
"github.com/apache/dubbo-kubernetes/dubboctl/pkg/cli"
- "github.com/apache/dubbo-kubernetes/operator/pkg/installer"
+ "github.com/apache/dubbo-kubernetes/operator/pkg/install"
"github.com/apache/dubbo-kubernetes/operator/pkg/render"
"github.com/apache/dubbo-kubernetes/operator/pkg/util/clog"
"github.com/apache/dubbo-kubernetes/operator/pkg/util/clog/log"
@@ -59,15 +59,15 @@ func InstallCmdWithArgs(ctx cli.Context, rootArgs
*RootArgs, iArgs *installArgs)
p := NewPrinterForWriter(cmd.OutOrStderr())
cl := clog.NewConsoleLogger(cmd.OutOrStdout(),
cmd.ErrOrStderr(), installerScope)
p.Printf("%v\n", art.DubboArt())
- return install(kubeClient, rootArgs, iArgs, cl,
cmd.OutOrStdout(), p)
+ return Install(kubeClient, rootArgs, iArgs, cl,
cmd.OutOrStdout(), p)
},
}
return ic
}
-func install(kubeClient kube.CLIClient, rootArgs *RootArgs, iArgs
*installArgs, cl clog.Logger, stdOut io.Writer, p Printer) error {
- setFlags := applyFlagAliases(iArgs.Set, iArgs.ManifestsPath,
iArgs.Revision)
- manifests, vals, err := render.GenerateManifest(iArgs.Files, setFlags)
+func Install(kubeClient kube.CLIClient, rootArgs *RootArgs, iArgs
*installArgs, cl clog.Logger, stdOut io.Writer, p Printer) error {
+ setFlags := applyFlagAliases(iArgs.Sets, iArgs.ManifestPath,
iArgs.Revision)
+ manifests, vals, err := render.GenerateManifest(iArgs.Files, setFlags,
cl)
if err != nil {
return fmt.Errorf("generate config: %v", err)
}
@@ -79,7 +79,7 @@ func install(kubeClient kube.CLIClient, rootArgs *RootArgs,
iArgs *installArgs,
os.Exit(1)
}
}
- i := installer.Installer{
+ i := install.Installer{
DryRun: rootArgs.DryRun,
SkipWait: false,
Kube: kubeClient,
diff --git a/operator/pkg/installer/installer.go
b/operator/pkg/install/installer.go
similarity index 99%
rename from operator/pkg/installer/installer.go
rename to operator/pkg/install/installer.go
index 2eee4d22..36fd9689 100644
--- a/operator/pkg/installer/installer.go
+++ b/operator/pkg/install/installer.go
@@ -1,4 +1,4 @@
-package installer
+package install
import (
"github.com/apache/dubbo-kubernetes/operator/pkg/component"
diff --git a/operator/pkg/util/clog/clog.go b/operator/pkg/util/clog/clog.go
index d9153aa4..f83c315e 100644
--- a/operator/pkg/util/clog/clog.go
+++ b/operator/pkg/util/clog/clog.go
@@ -13,6 +13,14 @@ type ConsoleLogger struct {
scope *log.Scope
}
+func (l *ConsoleLogger) LogAndPrint(v ...any) {
+ if len(v) == 0 {
+ return
+ }
+ s := fmt.Sprint(v...)
+ l.Print(s + "\n")
+ l.scope.Infof(s)
+}
func (l *ConsoleLogger) LogAndError(v ...any) {
if len(v) == 0 {
return
diff --git a/operator/pkg/util/progress/progress.go
b/operator/pkg/util/progress/progress.go
index 5c85bce7..b09ae59d 100644
--- a/operator/pkg/util/progress/progress.go
+++ b/operator/pkg/util/progress/progress.go
@@ -40,7 +40,7 @@ func (i *Info) NewComponent(comp string) *ManifestInfo {
}
i.mu.Lock()
defer i.mu.Unlock()
- i.components[component] = mi
+ i.components[comp] = mi
return mi
}
func (i *Info) reportProgress(componentName string) func() {