@@ -19,11 +19,6 @@ import (
1919 "github.com/grafana/terraform-provider-grafana/v4/internal/common"
2020)
2121
22- const (
23- pdcEnableSecureSocksProxy = "enableSecureSocksProxy"
24- pdcSecureSocksProxyUsername = "secureSocksProxyUsername"
25- )
26-
2722func resourceDataSource () * common.Resource {
2823 schema := & schema.Resource {
2924
@@ -172,17 +167,6 @@ func datasourceJSONDataAttribute() *schema.Schema {
172167 errors .New ("teamHttpHeaders is a reserved key and cannot be used in JSON data. Use the data_source_config_lbac_rules resource instead" ),
173168 }
174169 }
175-
176- if strings .Contains (i .(string ), pdcEnableSecureSocksProxy ) {
177- return nil , []error {
178- errors .New (pdcEnableSecureSocksProxy + " is a reserved key and cannot be used in JSON data" ),
179- }
180- }
181- if strings .Contains (i .(string ), pdcSecureSocksProxyUsername ) {
182- return nil , []error {
183- errors .New (pdcSecureSocksProxyUsername + " is a reserved key and cannot be used in JSON data" ),
184- }
185- }
186170 return validation .StringIsJSON (i , s )
187171 },
188172 StateFunc : func (v any ) string {
@@ -198,8 +182,8 @@ func datasourceJSONDataAttribute() *schema.Schema {
198182 json .Unmarshal ([]byte (newValue ), & newValueUnmarshalled )
199183 pdcNetworkID := d .Get ("private_data_source_connect_network_id" )
200184 if pdcNetworkID != "" {
201- newValueUnmarshalled [pdcEnableSecureSocksProxy ] = true
202- newValueUnmarshalled [pdcSecureSocksProxyUsername ] = pdcNetworkID
185+ newValueUnmarshalled ["enableSecureSocksProxy" ] = true
186+ newValueUnmarshalled ["secureSocksProxyUsername" ] = pdcNetworkID
203187 }
204188 newValue , _ = structure .FlattenJsonToString (newValueUnmarshalled )
205189
@@ -349,14 +333,6 @@ func datasourceToState(d *schema.ResourceData, dataSource *models.DataSource) di
349333
350334func datasourceConfigToState (d * schema.ResourceData , dataSource * models.DataSource ) diag.Diagnostics {
351335 gottenJSONData , gottenHeaders := removeHeadersFromJSONData (dataSource .JSONData .(map [string ]any ))
352-
353- // These PDC fields are added by the provider, so we should remove them from
354- // the state so that the state matches the user config. The consequence of
355- // having a diff here is suppressed in the DiffSuppressFunc, but there is
356- // a risk that the encoding of the map provides an inconsistent result.
357- delete (gottenJSONData , pdcEnableSecureSocksProxy )
358- delete (gottenJSONData , pdcSecureSocksProxyUsername )
359-
360336 encodedJSONData , err := json .Marshal (gottenJSONData )
361337 if err != nil {
362338 return diag .Errorf ("Failed to marshal JSON data: %s" , err )
@@ -414,8 +390,8 @@ func stateToDatasourceConfig(d *schema.ResourceData) (map[string]any, map[string
414390 pdcNetworkID := d .Get ("private_data_source_connect_network_id" )
415391 if pdcNetworkID != nil {
416392 if id := pdcNetworkID .(string ); id != "" {
417- jd [pdcEnableSecureSocksProxy ] = true
418- jd [pdcSecureSocksProxyUsername ] = pdcNetworkID
393+ jd ["enableSecureSocksProxy" ] = true
394+ jd ["secureSocksProxyUsername" ] = pdcNetworkID
419395 }
420396 }
421397
0 commit comments