Merge pull request #918 from docker/fix914

Use json to marshall ecs-local enhanced docker-compose config
This commit is contained in:
Nicolas De loof 2020-11-17 12:01:55 +01:00 committed by GitHub
commit f68495fcfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"context" "context"
"encoding/json"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -57,7 +58,7 @@ func (e ecsLocalSimulation) Up(ctx context.Context, project *types.Project, deta
return fmt.Errorf("ECS simulation mode require Docker-compose 1.27, found %s", version) return fmt.Errorf("ECS simulation mode require Docker-compose 1.27, found %s", version)
} }
converted, err := e.Convert(ctx, project, "yaml") converted, err := e.Convert(ctx, project, "json")
if err != nil { if err != nil {
return err return err
} }
@ -137,7 +138,15 @@ func (e ecsLocalSimulation) Convert(ctx context.Context, project *types.Project,
"secrets": project.Secrets, "secrets": project.Secrets,
"configs": project.Configs, "configs": project.Configs,
} }
return yaml.Marshal(config) switch format {
case "json":
return json.MarshalIndent(config, "", " ")
case "yaml":
return yaml.Marshal(config)
default:
return nil, fmt.Errorf("unsupported format %q", format)
}
} }
func (e ecsLocalSimulation) Down(ctx context.Context, projectName string) error { func (e ecsLocalSimulation) Down(ctx context.Context, projectName string) error {