File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package provider
33import (
44 contentfulManagement "github.com/cysp/terraform-provider-contentful/internal/contentful-management-go"
55 "github.com/cysp/terraform-provider-contentful/internal/provider/resource_app_installation"
6+ "github.com/cysp/terraform-provider-contentful/internal/provider/util"
67 "github.com/go-faster/jx"
78 "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes"
89 "github.com/hashicorp/terraform-plugin-framework/diag"
@@ -11,9 +12,9 @@ import (
1112
1213func ReadAppInstallationModel (model * resource_app_installation.AppInstallationModel , appInstallation contentfulManagement.AppInstallation ) {
1314 // SpaceId, EnvironmentId and AppDefinitionId are all already known
14- if appInstallation .Parameters .Set {
15+ if parameters , ok := appInstallation .Parameters .Get (); ok {
1516 encoder := jx.Encoder {}
16- appInstallation . Parameters . Encode (& encoder )
17+ util . EncodeJxRawMapOrdered (& encoder , parameters )
1718 model .Parameters = jsontypes .NewNormalizedValue (encoder .String ())
1819 } else {
1920 model .Parameters = jsontypes .NewNormalizedNull ()
Original file line number Diff line number Diff line change 1+ package util
2+
3+ import (
4+ "sort"
5+
6+ "github.com/go-faster/jx"
7+ )
8+
9+ func EncodeJxRawMapOrdered (encoder * jx.Encoder , object map [string ]jx.Raw ) {
10+ encoder .ObjStart ()
11+
12+ keys := make ([]string , 0 , len (object ))
13+ for k := range object {
14+ keys = append (keys , k )
15+ }
16+
17+ sort .Strings (keys )
18+
19+ for _ , k := range keys {
20+ encoder .FieldStart (k )
21+
22+ elem := object [k ]
23+
24+ if len (elem ) != 0 {
25+ encoder .Raw (elem )
26+ }
27+ }
28+
29+ encoder .ObjEnd ()
30+ }
You can’t perform that action at this time.
0 commit comments