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 { type InstallItem struct {
ChartName string ChartName string
WaitFor string WaitFor []string
Manifests []releaseutil.Manifest Manifests []releaseutil.Manifest
Resources kube.ResourceList Resources kube.ResourceList
PreInstallHooks []*release.Hook PreInstallHooks []*release.Hook
@ -1026,18 +1026,20 @@ func (i *Install) performCustomInstall(c chan<- resultMessage, rel *release.Rele
} }
// 自定义 waitFor // 自定义 waitFor
if item.WaitFor != "" { if len(item.WaitFor) != 0 {
if err := i.executeWaitFor(item.ChartName, item.WaitFor); err != nil { 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())) rel.SetStatus(release.StatusFailed, fmt.Sprintf("wait failed for %s: %s", item.ChartName, err.Error()))
if err := i.recordRelease(rel); err != nil { if err := i.recordRelease(rel); err != nil {
i.cfg.Log("failed to record the release: %s", err) i.cfg.Log("failed to record the release: %s", err)
} }
i.reportToRun(c, rel, err) i.reportToRun(c, rel, err)
return return
} }
} }
}
//if item.WaitFor != "" { //if item.WaitFor != "" {
// fmt.Fprintf(os.Stdout, "Executing waitFor: %s\n", 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 { if err == nil {
i.cfg.Log("Wait completed for %s", chartName) i.cfg.Log("Wait completed for %s", chartName)
fmt.Fprintf(os.Stdout, "Wait completed for %s\n", chartName) fmt.Fprintf(os.Stdout, "Wait completed for %s\n", chartName)
os.Stdout.Sync()
return nil return nil
} }

@ -18,7 +18,7 @@ func GetInstallSequence(ch *chart.Chart, manifests []releaseutil.Manifest, resou
return []InstallItem{ return []InstallItem{
{ {
ChartName: ch.Name(), ChartName: ch.Name(),
WaitFor: "", WaitFor: []string{},
Resources: resources, Resources: resources,
}, },
}, nil }, nil
@ -49,7 +49,7 @@ func GetInstallSequence(ch *chart.Chart, manifests []releaseutil.Manifest, resou
} }
// 构建 waitFor 映射 // 构建 waitFor 映射
waitForMap := make(map[string]string) waitForMap := make(map[string][]string, 0)
for _, inst := range ch.Metadata.Install { for _, inst := range ch.Metadata.Install {
waitForMap[inst.Name] = inst.WaitFor waitForMap[inst.Name] = inst.WaitFor
} }

@ -86,7 +86,7 @@ type Metadata struct {
type ChartInstance struct { type ChartInstance struct {
Name string `json:"name,omitempty"` 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 // Validate checks the metadata for known issues and sanitizes string

Loading…
Cancel
Save