Skip to content

Commit 0deff7c

Browse files
committed
Keep the yaml
1 parent b3451af commit 0deff7c

File tree

6 files changed

+1153
-1058
lines changed

6 files changed

+1153
-1058
lines changed

src/pkg/cli/client/byoc/aws/byoc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (b *ByocAws) Deploy(ctx context.Context, req *defangv1.DeployRequest) (*def
124124
return nil, err
125125
}
126126

127-
p, err := loader.LoadWithContext(ctx, compose.ConfigDetails{ConfigFiles: []compose.ConfigFile{{Config: req.Compose.AsMap()}}})
127+
p, err := loader.LoadWithContext(ctx, compose.ConfigDetails{ConfigFiles: []compose.ConfigFile{{Content: req.Compose}}})
128128
if err != nil {
129129
return nil, err
130130
}

src/pkg/cli/composeUp.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"github.com/DefangLabs/defang/src/pkg/term"
1010
defangv1 "github.com/DefangLabs/defang/src/protos/io/defang/v1"
1111
"github.com/compose-spec/compose-go/v2/types"
12-
"google.golang.org/protobuf/types/known/structpb"
13-
"gopkg.in/yaml.v3"
1412
)
1513

1614
type ComposeError struct {
@@ -56,25 +54,14 @@ func ComposeUp(ctx context.Context, c client.Client, force bool, mode defangv1.D
5654
return nil, project, ErrDryRun
5755
}
5856

59-
// Unmarshal the project into a map so we can convert it to a structpb.Struct
60-
var asMap map[string]any
61-
if err := yaml.Unmarshal(bytes, &asMap); err != nil {
62-
return nil, project, err
63-
}
64-
65-
strpb, err := structpb.NewStruct(asMap)
66-
if err != nil {
67-
return nil, project, err
68-
}
69-
7057
for _, service := range project.Services {
7158
term.Info("Deploying service", service.Name)
7259
}
7360

7461
resp, err := c.Deploy(ctx, &defangv1.DeployRequest{
7562
Mode: mode,
7663
Project: project.Name,
77-
Compose: strpb,
64+
Compose: bytes,
7865
})
7966
if err != nil {
8067
return nil, project, err

src/pkg/cli/composeUp_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ func (d deployMock) Deploy(ctx context.Context, req *defangv1.DeployRequest) (*d
2424
return nil, errors.New("DeployRequest needs Compose or Services")
2525
}
2626

27-
asMap := req.Compose.AsMap()
28-
p, err := loader.LoadWithContext(ctx, types.ConfigDetails{ConfigFiles: []types.ConfigFile{{Config: asMap}}}, func(o *loader.Options) {
29-
o.SetProjectName(asMap["name"].(string), true) // HACK: workaround for bug in compose-go where it insists on loading the project name from the file
27+
p, err := loader.LoadWithContext(ctx, types.ConfigDetails{ConfigFiles: []types.ConfigFile{{Content: req.Compose}}}, func(o *loader.Options) {
28+
o.SetProjectName(req.Project, true) // HACK: workaround for bug in compose-go where it insists on loading the project name from the file
3029
})
3130
if err != nil {
3231
return nil, err

0 commit comments

Comments
 (0)