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 d295e290 [operator] Add Installer and multi errors (#515)
d295e290 is described below

commit d295e29024a554993c1c65bba603765c479d156c
Author: mfordjody <[email protected]>
AuthorDate: Mon Dec 2 12:45:33 2024 +0800

    [operator] Add Installer and multi errors (#515)
---
 operator/pkg/installer/installer.go      | 30 ++++++++++++++++++++++++++++++
 operator/pkg/util/dmultierr/dmultierr.go | 27 +++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/operator/pkg/installer/installer.go 
b/operator/pkg/installer/installer.go
new file mode 100644
index 00000000..d5cb34fb
--- /dev/null
+++ b/operator/pkg/installer/installer.go
@@ -0,0 +1,30 @@
+package installer
+
+import (
+       "github.com/apache/dubbo-kubernetes/operator/manifest"
+       "github.com/apache/dubbo-kubernetes/operator/pkg/util/dmultierr"
+       "github.com/apache/dubbo-kubernetes/operator/pkg/values"
+       "github.com/apache/dubbo-kubernetes/pkg/kube"
+       "sync"
+)
+
+type Installer struct {
+       DryRun   bool
+       SkipWait bool
+       Kube     kube.CLIClient
+       Values   values.Map
+}
+
+func (i Installer) install(manifest []manifest.ManifestSet) error {
+       var _ sync.Mutex
+       var _ sync.WaitGroup
+       errors := dmultierr.NewDMultiErr()
+       if err := errors.ErrorOrNil(); err != nil {
+               return err
+       }
+       return nil
+}
+
+func (i Installer) InstallManifests(manifests []manifest.ManifestSet) error {
+       return nil
+}
diff --git a/operator/pkg/util/dmultierr/dmultierr.go 
b/operator/pkg/util/dmultierr/dmultierr.go
new file mode 100644
index 00000000..e5b428e6
--- /dev/null
+++ b/operator/pkg/util/dmultierr/dmultierr.go
@@ -0,0 +1,27 @@
+package dmultierr
+
+import (
+       "fmt"
+       "github.com/hashicorp/go-multierror"
+       "strings"
+)
+
+func MultiErrorFormat() multierror.ErrorFormatFunc {
+       return func(errors []error) string {
+               if len(errors) == 1 {
+                       return errors[0].Error()
+               }
+               points := make([]string, len(errors))
+               for index, err := range errors {
+                       points[index] = fmt.Sprintf("* %s", err)
+               }
+               return fmt.Sprintf("%d errors occurred:\n\t%s\n",
+                       len(errors), strings.Join(points, "\n\t"))
+       }
+}
+
+func NewDMultiErr() *multierror.Error {
+       return &multierror.Error{
+               ErrorFormat: MultiErrorFormat(),
+       }
+}

Reply via email to