From 3b33dc65e7aba31405d387c31ae175bc83a4ae47 Mon Sep 17 00:00:00 2001 From: Rujun Chen Date: Fri, 15 Nov 2024 08:55:57 +0800 Subject: [PATCH] Fix error about marshal yaml (#26) --- cli/azd/pkg/project/resources.go | 30 +++++++++++++++++++++++++++++ cli/azd/pkg/project/scaffold_gen.go | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/cli/azd/pkg/project/resources.go b/cli/azd/pkg/project/resources.go index cd468eec9ce..2ef62e5875e 100644 --- a/cli/azd/pkg/project/resources.go +++ b/cli/azd/pkg/project/resources.go @@ -106,11 +106,41 @@ func (r *ResourceConfig) MarshalYAML() (interface{}, error) { if err != nil { return nil, err } + case ResourceTypeDbPostgres: + err := marshalRawProps(raw.Props.(PostgresProps)) + if err != nil { + return nil, err + } case ResourceTypeDbMySQL: err := marshalRawProps(raw.Props.(MySQLProps)) if err != nil { return nil, err } + case ResourceTypeDbMongo: + err := marshalRawProps(raw.Props.(MongoDBProps)) + if err != nil { + return nil, err + } + case ResourceTypeDbCosmos: + err := marshalRawProps(raw.Props.(CosmosDBProps)) + if err != nil { + return nil, err + } + case ResourceTypeMessagingServiceBus: + err := marshalRawProps(raw.Props.(ServiceBusProps)) + if err != nil { + return nil, err + } + case ResourceTypeMessagingEventHubs: + err := marshalRawProps(raw.Props.(EventHubsProps)) + if err != nil { + return nil, err + } + case ResourceTypeMessagingKafka: + err := marshalRawProps(raw.Props.(KafkaProps)) + if err != nil { + return nil, err + } } return raw, nil diff --git a/cli/azd/pkg/project/scaffold_gen.go b/cli/azd/pkg/project/scaffold_gen.go index a2e1aa99853..e1c5728b379 100644 --- a/cli/azd/pkg/project/scaffold_gen.go +++ b/cli/azd/pkg/project/scaffold_gen.go @@ -141,7 +141,7 @@ func infraSpec(projectConfig *ProjectConfig) (*scaffold.InfraSpec, error) { infraSpec.DbRedis = &scaffold.DatabaseRedis{} case ResourceTypeDbMongo: infraSpec.DbCosmosMongo = &scaffold.DatabaseCosmosMongo{ - DatabaseName: res.Props.(CosmosDBProps).DatabaseName, + DatabaseName: res.Props.(MongoDBProps).DatabaseName, } case ResourceTypeDbPostgres: infraSpec.DbPostgres = &scaffold.DatabasePostgres{