@@ -7,6 +7,10 @@ import (
7
7
"github.com/zededa/terraform-provider/models"
8
8
)
9
9
10
+ // Note, when providing secrets as variable instead of hard-coding them, the fields api_key, ds_err and enterprise_id
11
+ // reports a diff in a subsequent plan command. This seems to be a bug in TF SDKv2 transition of nil values or similar.
12
+ // So these fields are removed (commented) from the schema.
13
+
10
14
func DatastoreModel (d * schema.ResourceData ) * models.Datastore {
11
15
aPIKey , _ := d .Get ("api_key" ).(string )
12
16
var certificateChain * models.CertificateChain // CertificateChain
@@ -32,7 +36,7 @@ func DatastoreModel(d *schema.ResourceData) *models.Datastore {
32
36
dsTypeModel := dsTypeInterface .(string )
33
37
dsType = models .NewDatastoreType (models .DatastoreType (dsTypeModel ))
34
38
}
35
- enterpriseID , _ := d .Get ("enterprise_id" ).(string )
39
+ // enterpriseID, _ := d.Get("enterprise_id").(string)
36
40
id , _ := d .Get ("id" ).(string )
37
41
name , _ := d .Get ("name" ).(string )
38
42
needClearText , _ := d .Get ("need_clear_text" ).(bool )
@@ -62,22 +66,29 @@ func DatastoreModel(d *schema.ResourceData) *models.Datastore {
62
66
}
63
67
}
64
68
title , _ := d .Get ("title" ).(string )
69
+ var revision * models.ObjectRevision // ObjectRevision
70
+ revisionInterface , revisionIsSet := d .GetOk ("revision" )
71
+ if revisionIsSet {
72
+ revisionMap := revisionInterface .([]interface {})[0 ].(map [string ]interface {})
73
+ revision = ObjectRevisionModelFromMap (revisionMap )
74
+ }
65
75
return & models.Datastore {
66
- APIKey : aPIKey ,
67
- CertificateChain : certificateChain ,
68
- Description : description ,
69
- DsFQDN : & dsFQDN , // string true false false
70
- DsPath : & dsPath , // string true false false
71
- DsStatus : dsStatus ,
72
- DsType : dsType ,
73
- EnterpriseID : enterpriseID ,
76
+ APIKey : aPIKey ,
77
+ CertificateChain : certificateChain ,
78
+ Description : description ,
79
+ DsFQDN : & dsFQDN ,
80
+ DsPath : & dsPath ,
81
+ DsStatus : dsStatus ,
82
+ DsType : dsType ,
83
+ // EnterpriseID: enterpriseID,
74
84
ID : id ,
75
- Name : & name , // string true false false
85
+ Name : & name ,
76
86
NeedClearText : needClearText ,
77
87
ProjectAccessList : projectAccessList ,
78
88
Region : region ,
79
89
Secret : secret ,
80
- Title : & title , // string true false false
90
+ Title : & title ,
91
+ Revision : revision ,
81
92
}
82
93
}
83
94
@@ -107,7 +118,7 @@ func DatastoreModelFromMap(m map[string]interface{}) *models.Datastore {
107
118
dsTypeModel := dsTypeInterface .(string )
108
119
dsType = models .NewDatastoreType (models .DatastoreType (dsTypeModel ))
109
120
}
110
- enterpriseID := m ["enterprise_id" ].(string )
121
+ // enterpriseID := m["enterprise_id"].(string)
111
122
id := m ["id" ].(string )
112
123
name := m ["name" ].(string )
113
124
needClearText := m ["need_clear_text" ].(bool )
@@ -138,22 +149,31 @@ func DatastoreModelFromMap(m map[string]interface{}) *models.Datastore {
138
149
}
139
150
//
140
151
title := m ["title" ].(string )
152
+ var revision * models.ObjectRevision // ObjectRevision
153
+ revisionInterface , revisionIsSet := m ["revision" ]
154
+ if revisionIsSet && revisionInterface != nil {
155
+ revisionMap := revisionInterface .([]interface {})
156
+ if len (revisionMap ) > 0 {
157
+ revision = ObjectRevisionModelFromMap (revisionMap [0 ].(map [string ]interface {}))
158
+ }
159
+ }
141
160
return & models.Datastore {
142
- APIKey : aPIKey ,
143
- CertificateChain : certificateChain ,
144
- Description : description ,
145
- DsFQDN : & dsFQDN ,
146
- DsPath : & dsPath ,
147
- DsStatus : dsStatus ,
148
- DsType : dsType ,
149
- EnterpriseID : enterpriseID ,
161
+ APIKey : aPIKey ,
162
+ CertificateChain : certificateChain ,
163
+ Description : description ,
164
+ DsFQDN : & dsFQDN ,
165
+ DsPath : & dsPath ,
166
+ DsStatus : dsStatus ,
167
+ DsType : dsType ,
168
+ // EnterpriseID: enterpriseID,
150
169
ID : id ,
151
170
Name : & name ,
152
171
NeedClearText : needClearText ,
153
172
ProjectAccessList : projectAccessList ,
154
173
Region : region ,
155
174
Secret : secret ,
156
175
Title : & title ,
176
+ Revision : revision ,
157
177
}
158
178
}
159
179
@@ -162,13 +182,13 @@ func SetDatastoreResourceData(d *schema.ResourceData, m *models.Datastore) {
162
182
d .Set ("certificate_chain" , SetCertificateChainSubResourceData ([]* models.CertificateChain {m .CertificateChain }))
163
183
d .Set ("crypto_key" , m .CryptoKey )
164
184
d .Set ("description" , m .Description )
165
- d .Set ("ds_err" , m .DsErr )
185
+ // d.Set("ds_err", m.DsErr)
166
186
d .Set ("ds_fqdn" , m .DsFQDN )
167
187
d .Set ("ds_path" , m .DsPath )
168
188
d .Set ("ds_status" , m .DsStatus )
169
189
d .Set ("ds_type" , m .DsType )
170
190
d .Set ("encrypted_secrets" , m .EncryptedSecrets )
171
- d .Set ("enterprise_id" , m .EnterpriseID )
191
+ // d.Set("enterprise_id", m.EnterpriseID)
172
192
d .Set ("id" , m .ID )
173
193
d .Set ("name" , m .Name )
174
194
d .Set ("need_clear_text" , m .NeedClearText )
@@ -180,7 +200,6 @@ func SetDatastoreResourceData(d *schema.ResourceData, m *models.Datastore) {
180
200
d .Set ("title" , m .Title )
181
201
}
182
202
183
- // Iterate through and update the DatastoreInfo resource data within a pagination response (typically defined in the items array field) retrieved from a READ operation for multiple LM resources
184
203
func SetDatastoreInfoSubResourceData (m []* models.Datastore ) (d []* map [string ]interface {}) {
185
204
for _ , DatastoreInfoModel := range m {
186
205
if DatastoreInfoModel != nil {
@@ -189,13 +208,13 @@ func SetDatastoreInfoSubResourceData(m []*models.Datastore) (d []*map[string]int
189
208
properties ["certificate_chain" ] = SetCertificateChainSubResourceData ([]* models.CertificateChain {DatastoreInfoModel .CertificateChain })
190
209
properties ["crypto_key" ] = DatastoreInfoModel .CryptoKey
191
210
properties ["description" ] = DatastoreInfoModel .Description
192
- properties ["ds_err" ] = DatastoreInfoModel .DsErr
211
+ // properties["ds_err"] = DatastoreInfoModel.DsErr
193
212
properties ["ds_fqdn" ] = DatastoreInfoModel .DsFQDN
194
213
properties ["ds_path" ] = DatastoreInfoModel .DsPath
195
214
properties ["ds_status" ] = DatastoreInfoModel .DsStatus
196
215
properties ["ds_type" ] = DatastoreInfoModel .DsType
197
216
properties ["encrypted_secrets" ] = DatastoreInfoModel .EncryptedSecrets
198
- properties ["enterprise_id" ] = DatastoreInfoModel .EnterpriseID
217
+ // properties["enterprise_id"] = DatastoreInfoModel.EnterpriseID
199
218
properties ["id" ] = DatastoreInfoModel .ID
200
219
properties ["name" ] = DatastoreInfoModel .Name
201
220
properties ["need_clear_text" ] = DatastoreInfoModel .NeedClearText
@@ -211,7 +230,6 @@ func SetDatastoreInfoSubResourceData(m []*models.Datastore) (d []*map[string]int
211
230
return
212
231
}
213
232
214
- // Schema mapping representing the DatastoreInfo resource defined in the Terraform configuration
215
233
func Datastore () map [string ]* schema.Schema {
216
234
return map [string ]* schema.Schema {
217
235
"api_key" : {
@@ -244,11 +262,11 @@ func Datastore() map[string]*schema.Schema {
244
262
Optional : true ,
245
263
},
246
264
247
- "ds_err" : {
248
- Description : `Datastore validation detailed error/status message` ,
249
- Type : schema .TypeString ,
250
- Computed : true ,
251
- },
265
+ // "ds_err": {
266
+ // Description: `Datastore validation detailed error/status message`,
267
+ // Type: schema.TypeString,
268
+ // Computed: true,
269
+ // },
252
270
253
271
"ds_fqdn" : {
254
272
Description : `Datastore Fully Qualified Domain Name` ,
@@ -272,6 +290,7 @@ func Datastore() map[string]*schema.Schema {
272
290
Description : `Datastore status` ,
273
291
Type : schema .TypeString ,
274
292
Optional : true ,
293
+ Computed : true ,
275
294
},
276
295
277
296
"ds_type" : {
@@ -290,11 +309,11 @@ func Datastore() map[string]*schema.Schema {
290
309
Sensitive : true ,
291
310
},
292
311
293
- "enterprise_id" : {
294
- Description : `` ,
295
- Type : schema .TypeString ,
296
- Optional : true ,
297
- },
312
+ // "enterprise_id": {
313
+ // Description: ``,
314
+ // Type: schema.TypeString,
315
+ // Optional: true,
316
+ // },
298
317
299
318
"id" : {
300
319
Description : `System defined universally unique Id of the datastore.` ,
@@ -312,6 +331,9 @@ func Datastore() map[string]*schema.Schema {
312
331
Description : `knob for sending creds in clear text` ,
313
332
Type : schema .TypeBool ,
314
333
Optional : true ,
334
+ DiffSuppressFunc : func (k , oldValue , newValue string , d * schema.ResourceData ) bool {
335
+ return true
336
+ },
315
337
},
316
338
317
339
"origin_type" : {
@@ -336,11 +358,12 @@ func Datastore() map[string]*schema.Schema {
336
358
},
337
359
338
360
"revision" : {
339
- Description : `system defined info ` ,
361
+ Description : `Object revision details ` ,
340
362
Type : schema .TypeList , //GoType: ObjectRevision
341
363
Elem : & schema.Resource {
342
364
Schema : ObjectRevision (),
343
365
},
366
+ Optional : true ,
344
367
Computed : true ,
345
368
},
346
369
@@ -352,7 +375,6 @@ func Datastore() map[string]*schema.Schema {
352
375
},
353
376
Optional : true ,
354
377
Sensitive : true ,
355
- Computed : true ,
356
378
},
357
379
358
380
"title" : {
0 commit comments