feat(dtc-install): waitFor改列表

pull/31674/head
huanghong 10 months ago
parent 92ff2e7343
commit df0ee22be7

@ -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,18 +1026,20 @@ func (i *Install) performCustomInstall(c chan<- resultMessage, rel *release.Rele
}
// 自定义 waitFor
if item.WaitFor != "" {
if err := i.executeWaitFor(item.ChartName, item.WaitFor); err != nil {
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
}
}
}
//if item.WaitFor != "" {
// fmt.Fprintf(os.Stdout, "Executing waitFor: %s\n", 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
}

@ -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
}

@ -86,7 +86,7 @@ type Metadata struct {
type ChartInstance struct {
Name string `json:"name,omitempty"`
WaitFor string `json:"waitFor,omitempty"`
WaitFor []string `json:"waitFor,omitempty"`
}
// Validate checks the metadata for known issues and sanitizes string

Loading…
Cancel
Save