@@ -128,12 +128,15 @@ func fillPlugin(c *client.Plugin, d *schema.ResourceData) {
128128
129129func fillResourceDataFromPlugin (ctx context.Context , c * client.Plugin , d * schema.ResourceData , pluginSchema * client.PluginSchema ) {
130130 // Grab just the schema for config parameter from plugin schema
131- var configSchema []map [string ]client.PluginField
132- configSchema = nil
131+ var fieldSchema []map [string ]client.PluginField
132+ fieldSchema = nil
133+ var shorthandFieldSchema []map [string ]client.PluginField
134+ shorthandFieldSchema = nil
133135 for _ , value := range pluginSchema .Fields {
134136 valueMap , ok := value ["config" ]
135137 if ok {
136- configSchema = valueMap .Fields
138+ fieldSchema = valueMap .Fields
139+ shorthandFieldSchema = valueMap .ShorthandFields
137140 break
138141 }
139142 }
@@ -159,29 +162,33 @@ func fillResourceDataFromPlugin(ctx context.Context, c *client.Plugin, d *schema
159162 d .Set ("consumer_id" , consumerId )
160163 d .Set ("plugin_id" , c .Id )
161164 // Remove all default values from config based on plugin schema
162- if configSchema != nil {
163- pruneConfigValues (ctx , c .Config , configSchema )
165+ if fieldSchema != nil {
166+ pruneConfigValues (ctx , c .Config , fieldSchema , false )
167+ }
168+ if shorthandFieldSchema != nil {
169+ pruneConfigValues (ctx , c .Config , shorthandFieldSchema , true )
164170 }
165171 bytes , _ := json .Marshal (c .Config )
166172 d .Set ("config_json" , string (bytes [:]))
167173 bytes , _ = json .Marshal (c .ConfigAll )
168174 d .Set ("config_all_json" , string (bytes [:]))
169175}
170176
171- func pruneConfigValues (ctx context.Context , config map [string ]interface {}, configSchema []map [string ]client.PluginField ) {
177+ func pruneConfigValues (ctx context.Context , config map [string ]interface {}, configSchema []map [string ]client.PluginField , isShorthand bool ) {
172178 for _ , fieldConfig := range configSchema {
173179 for fieldKey , field := range fieldConfig {
174180 configValue , ok := config [fieldKey ]
175181 if ok {
176182 // If field type is record, then recurse
177183 if field .Type == "record" {
178184 childConfigValue := configValue .(map [string ]interface {})
179- pruneConfigValues (ctx , childConfigValue , field .Fields )
185+ pruneConfigValues (ctx , childConfigValue , field .Fields , false )
186+ pruneConfigValues (ctx , childConfigValue , field .ShorthandFields , true )
180187 // If all fields of child config are defaults, then remove entire child config from parent
181188 if len (childConfigValue ) == 0 {
182189 delete (config , fieldKey )
183190 }
184- } else if areConfigValuesEqual (ctx , fieldKey , configValue , field .Default ) {
191+ } else if areConfigValuesEqual (ctx , fieldKey , configValue , field .Default ) || isShorthand {
185192 delete (config , fieldKey )
186193 }
187194 }
0 commit comments