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 256e7e14 [operator] Supplemental Installer Logic
256e7e14 is described below

commit 256e7e14e002af9f4f966fd4c737c0d5963dda2f
Author: mfordjody <[email protected]>
AuthorDate: Tue Dec 3 20:04:14 2024 +0800

    [operator] Supplemental Installer Logic
---
 operator/pkg/installer/installer.go    | 14 ++++++++++----
 operator/pkg/util/progress/progress.go | 15 ++++++++++++---
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/operator/pkg/installer/installer.go 
b/operator/pkg/installer/installer.go
index c22dc2d1..3c85b2b8 100644
--- a/operator/pkg/installer/installer.go
+++ b/operator/pkg/installer/installer.go
@@ -4,6 +4,7 @@ import (
        "github.com/apache/dubbo-kubernetes/operator/manifest"
        "github.com/apache/dubbo-kubernetes/operator/pkg/component"
        "github.com/apache/dubbo-kubernetes/operator/pkg/util/dmultierr"
+       "github.com/apache/dubbo-kubernetes/operator/pkg/util/progress"
        "github.com/apache/dubbo-kubernetes/operator/pkg/values"
        "github.com/apache/dubbo-kubernetes/pkg/kube"
        "github.com/apache/dubbo-kubernetes/pkg/util/sets"
@@ -13,10 +14,11 @@ import (
 )
 
 type Installer struct {
-       DryRun   bool
-       SkipWait bool
-       Kube     kube.CLIClient
-       Values   values.Map
+       DryRun       bool
+       SkipWait     bool
+       Kube         kube.CLIClient
+       Values       values.Map
+       ProgressInfo *progress.Info
 }
 
 func (i Installer) install(manifests []manifest.ManifestSet) error {
@@ -79,11 +81,15 @@ func (i Installer) InstallManifests(manifests 
[]manifest.ManifestSet) error {
 func (i Installer) applyManifestSet(manifestSet manifest.ManifestSet) error {
        componentNames := string(manifestSet.Components)
        manifests := manifestSet.Manifests
+       pi := i.ProgressInfo.NewComponent(componentNames)
        for _, obj := range manifests {
                if err := i.serverSideApply(obj); err != nil {
+                       pi.ReportError(err.Error())
                        return err
                }
+               pi.ReportProgress()
        }
+       pi.ReportFinished()
        return nil
 }
 
diff --git a/operator/pkg/util/progress/progress.go 
b/operator/pkg/util/progress/progress.go
index a268483f..5c85bce7 100644
--- a/operator/pkg/util/progress/progress.go
+++ b/operator/pkg/util/progress/progress.go
@@ -34,6 +34,15 @@ func NewInfo() *Info {
        }
 }
 
+func (i *Info) NewComponent(comp string) *ManifestInfo {
+       mi := &ManifestInfo{
+               report: i.reportProgress(comp),
+       }
+       i.mu.Lock()
+       defer i.mu.Unlock()
+       i.components[component] = mi
+       return mi
+}
 func (i *Info) reportProgress(componentName string) func() {
        return func() {
                compName := component.Name(componentName)
@@ -112,13 +121,13 @@ type ManifestInfo struct {
        mu       sync.Mutex
 }
 
-func (mi *ManifestInfo) reportProgress() {
+func (mi *ManifestInfo) ReportProgress() {
        if mi == nil {
                return
        }
 }
 
-func (mi *ManifestInfo) reportFinished() {
+func (mi *ManifestInfo) ReportFinished() {
        if mi == nil {
                return
        }
@@ -128,7 +137,7 @@ func (mi *ManifestInfo) reportFinished() {
        mi.report()
 }
 
-func (mi *ManifestInfo) reportError(err string) {
+func (mi *ManifestInfo) ReportError(err string) {
        if mi == nil {
                return
        }

Reply via email to