Skip to content

Commit

Permalink
fixing marshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
sankur-codes committed Apr 12, 2024
1 parent e18058a commit 1be3f99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/deploy/generator/resources_rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ func (g *generator) database(databaseName string, addDependsOn bool) []*arm.Reso
}

if !g.production {
database.Resource.(*sdkcosmos.SQLContainerCreateUpdateParameters).Properties.Options = &sdkcosmos.CreateUpdateOptions{
database.Resource.(*sdkcosmos.SQLDatabaseCreateUpdateParameters).Properties.Options = &sdkcosmos.CreateUpdateOptions{
AutoscaleSettings: &sdkcosmos.AutoscaleSettings{
MaxThroughput: to.Int32Ptr(1000),
},
Expand Down
6 changes: 5 additions & 1 deletion pkg/util/arm/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ func (r *Resource) MarshalJSON() ([]byte, error) {

// hack to handle newer track2 sdk which doesn't have json tags
if strings.HasPrefix(r.Type, "Microsoft.DocumentDB/databaseAccounts/sqlDatabases") {
b, err = r.Resource.(*sdkcosmos.SQLContainerCreateUpdateParameters).MarshalJSON()
if reflect.TypeOf(r.Resource) == reflect.TypeOf(&sdkcosmos.SQLDatabaseCreateUpdateParameters{}) {
b, err = r.Resource.(*sdkcosmos.SQLDatabaseCreateUpdateParameters).MarshalJSON()
} else if reflect.TypeOf(r.Resource) == reflect.TypeOf(&sdkcosmos.SQLContainerCreateUpdateParameters{}) {
b, err = r.Resource.(*sdkcosmos.SQLContainerCreateUpdateParameters).MarshalJSON()
}
} else if strings.HasPrefix(r.Type, "Microsoft.DocumentDB/databaseAccounts") {
b, err = r.Resource.(*sdkcosmos.DatabaseAccountCreateUpdateParameters).MarshalJSON()
}
Expand Down

0 comments on commit 1be3f99

Please sign in to comment.