diff --git a/pkg/action/install.go b/pkg/action/install.go index f75375661..2b821b3e5 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -130,7 +130,7 @@ type ChartPathOptions struct { type InstallItem struct { ChartName string - WaitFor string + WaitFor []string Manifests []releaseutil.Manifest Resources kube.ResourceList PreInstallHooks []*release.Hook @@ -1026,16 +1026,18 @@ func (i *Install) performCustomInstall(c chan<- resultMessage, rel *release.Rele } // 自定义 waitFor - if item.WaitFor != "" { - if err := i.executeWaitFor(item.ChartName, item.WaitFor); err != nil { - rel.SetStatus(release.StatusFailed, fmt.Sprintf("wait failed for %s: %s", item.ChartName, err.Error())) - if err := i.recordRelease(rel); err != nil { - i.cfg.Log("failed to record the release: %s", err) + if len(item.WaitFor) != 0 { + for _, waitFor := range item.WaitFor { + if err := i.executeWaitFor(item.ChartName, waitFor); err != nil { + rel.SetStatus(release.StatusFailed, fmt.Sprintf("wait failed for %s: %s", item.ChartName, err.Error())) + if err := i.recordRelease(rel); err != nil { + i.cfg.Log("failed to record the release: %s", err) + } + i.reportToRun(c, rel, err) + return } - - i.reportToRun(c, rel, err) - return } + } //if item.WaitFor != "" { @@ -1114,6 +1116,7 @@ func (i *Install) executeWaitFor(chartName, waitFor string) error { if err == nil { i.cfg.Log("Wait completed for %s", chartName) fmt.Fprintf(os.Stdout, "Wait completed for %s\n", chartName) + os.Stdout.Sync() return nil } diff --git a/pkg/action/install_sequence.go b/pkg/action/install_sequence.go index ab36690f2..6c21003e9 100644 --- a/pkg/action/install_sequence.go +++ b/pkg/action/install_sequence.go @@ -18,7 +18,7 @@ func GetInstallSequence(ch *chart.Chart, manifests []releaseutil.Manifest, resou return []InstallItem{ { ChartName: ch.Name(), - WaitFor: "", + WaitFor: []string{}, Resources: resources, }, }, nil @@ -49,7 +49,7 @@ func GetInstallSequence(ch *chart.Chart, manifests []releaseutil.Manifest, resou } // 构建 waitFor 映射 - waitForMap := make(map[string]string) + waitForMap := make(map[string][]string, 0) for _, inst := range ch.Metadata.Install { waitForMap[inst.Name] = inst.WaitFor } diff --git a/pkg/chart/metadata.go b/pkg/chart/metadata.go index f9c7b6a62..befdd02b9 100644 --- a/pkg/chart/metadata.go +++ b/pkg/chart/metadata.go @@ -85,8 +85,8 @@ type Metadata struct { } type ChartInstance struct { - Name string `json:"name,omitempty"` - WaitFor string `json:"waitFor,omitempty"` + Name string `json:"name,omitempty"` + WaitFor []string `json:"waitFor,omitempty"` } // Validate checks the metadata for known issues and sanitizes string