fix(edge-stack): parse docker compose multi lines json output EE-6317 (#10627)

pull/10665/head
cmeng 1 year ago committed by GitHub
parent ad5a17ac34
commit 57ed6ae6a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,10 @@
package composeplugin
import (
"bytes"
"context"
"fmt"
"io"
"time"
"github.com/portainer/portainer/pkg/libstack"
@ -107,6 +109,7 @@ func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, st
errorMessageCh := make(chan string)
go func() {
OUTER:
for {
select {
case <-ctx.Done():
@ -135,13 +138,23 @@ func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, st
}
var services []service
err = json.Unmarshal(output, &services)
if err != nil {
log.Debug().
Str("project_name", name).
Err(err).
Msg("failed to parse docker compose output")
continue
dec := json.NewDecoder(bytes.NewReader(output))
for {
var svc service
err := dec.Decode(&svc)
if err == io.EOF {
break
}
if err != nil {
log.Debug().
Str("project_name", name).
Err(err).
Msg("failed to parse docker compose output")
continue OUTER
}
services = append(services, svc)
}
if len(services) == 0 && status == libstack.StatusRemoved {

Loading…
Cancel
Save