@@ -55,6 +55,7 @@ const (
5555 deplConfigurationNodeSizeIdFieldName = "node_size_id"
5656 deplConfigurationNodeCountFieldName = "node_count"
5757 deplConfigurationNodeDiskSizeFieldName = "node_disk_size"
58+ deplConfigurationMaximumNodeDiskSizeFieldName = "maximum_node_disk_size"
5859 deplNotificationConfigurationFieldName = "notification_settings"
5960 deplNotificationConfigurationEmailAddressesFieldName = "email_addresses"
6061)
@@ -179,6 +180,13 @@ func resourceDeployment() *schema.Resource {
179180 return new == "0"
180181 },
181182 },
183+ deplConfigurationMaximumNodeDiskSizeFieldName : {
184+ Type : schema .TypeInt ,
185+ Optional : true ,
186+ DiffSuppressFunc : func (k , old , new string , d * schema.ResourceData ) bool {
187+ return new == ""
188+ },
189+ },
182190 },
183191 },
184192 },
@@ -219,11 +227,11 @@ func resourceDeploymentCreate(d *schema.ResourceData, m interface{}) error {
219227 if v , ok := d .GetOk (deplTAndCAcceptedFieldName ); ok {
220228 if ! v .(bool ) {
221229 client .log .Error ().Str ("name" , deplTAndCAcceptedFieldName ).Msg ("Field should be set to accept Terms and Conditions" )
222- return fmt .Errorf ("Field '%s' should be set to accept Terms and Conditions" , deplTAndCAcceptedFieldName )
230+ return fmt .Errorf ("field '%s' should be set to accept Terms and Conditions" , deplTAndCAcceptedFieldName )
223231 }
224232 } else {
225233 client .log .Error ().Str ("name" , deplTAndCAcceptedFieldName ).Msg ("Unable to find field, which is required to accept Terms and Conditions" )
226- return fmt .Errorf ("Unable to find field %s" , deplTAndCAcceptedFieldName )
234+ return fmt .Errorf ("unable to find field %s" , deplTAndCAcceptedFieldName )
227235 }
228236
229237 datac := data .NewDataServiceClient (client .conn )
@@ -265,7 +273,7 @@ func resourceDeploymentCreate(d *schema.ResourceData, m interface{}) error {
265273
266274 if expandedDepl .Certificates .CaCertificateId == "" {
267275 client .log .Error ().Err (err ).Str ("project-id" , expandedDepl .ProjectId ).Msg ("Unable to find default certificate for project. Please select one manually." )
268- return fmt .Errorf ("Unable to find default certificate for project %s. Please select one manually. " , expandedDepl .GetProjectId ())
276+ return fmt .Errorf ("unable to find default certificate for project %s. Please select one manually" , expandedDepl .GetProjectId ())
269277 }
270278 }
271279
@@ -277,11 +285,11 @@ func resourceDeploymentCreate(d *schema.ResourceData, m interface{}) error {
277285 })
278286 if err != nil {
279287 client .log .Fatal ().Err (err ).Msg ("Failed to fetch node size list." )
280- return fmt .Errorf ("Failed to fetch node size list for region %s" , expandedDepl .RegionId )
288+ return fmt .Errorf ("failed to fetch node size list for region %s" , expandedDepl .RegionId )
281289 }
282290 if len (list .Items ) < 1 {
283291 client .log .Fatal ().Msg ("No available node sizes found." )
284- return fmt .Errorf ("No available node sizes found for region %s" , expandedDepl .RegionId )
292+ return fmt .Errorf ("no available node sizes found for region %s" , expandedDepl .RegionId )
285293 }
286294 sort .SliceStable (list .Items , func (i , j int ) bool {
287295 return list .Items [i ].MemorySize < list .Items [j ].MemorySize
@@ -341,10 +349,11 @@ type securityFields struct {
341349
342350// configuration is a convenient wrapper around the configuration schema for easy parsing
343351type configuration struct {
344- model string
345- nodeSizeId string
346- nodeCount int
347- nodeDiskSize int
352+ model string
353+ nodeSizeId string
354+ nodeCount int
355+ nodeDiskSize int
356+ maximumNodeDiskSize int
348357}
349358
350359// expandDeploymentResource creates an oasis deployment structure out of a terraform schema model.
@@ -399,6 +408,12 @@ func expandDeploymentResource(d *schema.ResourceData, defaultProject string) (*d
399408 return nil , err
400409 }
401410 }
411+ var autoSizeSettings * data.Deployment_DiskAutoSizeSettings
412+ if conf .maximumNodeDiskSize > 0 {
413+ autoSizeSettings = & data.Deployment_DiskAutoSizeSettings {
414+ MaximumNodeDiskSize : int32 (conf .maximumNodeDiskSize ),
415+ }
416+ }
402417
403418 return & data.Deployment {
404419 Name : name ,
@@ -416,6 +431,7 @@ func expandDeploymentResource(d *schema.ResourceData, defaultProject string) (*d
416431 NodeSizeId : conf .nodeSizeId ,
417432 },
418433 NotificationSettings : notificationSetting ,
434+ DiskAutoSizeSettings : autoSizeSettings ,
419435 }, nil
420436}
421437
@@ -480,6 +496,9 @@ func expandConfiguration(s []interface{}) (conf configuration, err error) {
480496 if i , ok := item [deplConfigurationNodeDiskSizeFieldName ]; ok && i .(int ) != 0 {
481497 conf .nodeDiskSize = i .(int )
482498 }
499+ if i , ok := item [deplConfigurationMaximumNodeDiskSizeFieldName ]; ok && i .(int ) != 0 {
500+ conf .maximumNodeDiskSize = i .(int )
501+ }
483502 }
484503 return
485504}
@@ -583,13 +602,17 @@ func flattenLocationData(depl *data.Deployment) []interface{} {
583602
584603// flattenConfigurationData takes the configuration part of a deployment and creates a sub map for terraform schema.
585604func flattenConfigurationData (depl * data.Deployment ) []interface {} {
605+ conf := map [string ]interface {}{
606+ deplConfigurationModelFieldName : depl .GetModel ().GetModel (),
607+ deplConfigurationNodeSizeIdFieldName : depl .GetModel ().GetNodeSizeId (),
608+ deplConfigurationNodeDiskSizeFieldName : int (depl .GetModel ().GetNodeDiskSize ()),
609+ deplConfigurationNodeCountFieldName : int (depl .GetModel ().GetNodeCount ()),
610+ }
611+ if autoSizeSettings := depl .GetDiskAutoSizeSettings (); autoSizeSettings != nil {
612+ conf [deplConfigurationMaximumNodeDiskSizeFieldName ] = int (autoSizeSettings .GetMaximumNodeDiskSize ())
613+ }
586614 return []interface {}{
587- map [string ]interface {}{
588- deplConfigurationModelFieldName : depl .GetModel ().GetModel (),
589- deplConfigurationNodeSizeIdFieldName : depl .GetModel ().GetNodeSizeId (),
590- deplConfigurationNodeDiskSizeFieldName : int (depl .GetModel ().GetNodeDiskSize ()),
591- deplConfigurationNodeCountFieldName : int (depl .GetModel ().GetNodeCount ()),
592- },
615+ conf ,
593616 }
594617}
595618
@@ -662,6 +685,12 @@ func resourceDeploymentUpdate(d *schema.ResourceData, m interface{}) error {
662685 if conf .nodeCount != 0 {
663686 depl .Model .NodeCount = int32 (conf .nodeCount )
664687 }
688+ if conf .maximumNodeDiskSize != 0 {
689+ if depl .DiskAutoSizeSettings == nil {
690+ depl .DiskAutoSizeSettings = & data.Deployment_DiskAutoSizeSettings {}
691+ }
692+ depl .DiskAutoSizeSettings .MaximumNodeDiskSize = int32 (conf .maximumNodeDiskSize )
693+ }
665694 }
666695 // if we have change on NotificationSettings apply it
667696 if d .HasChange (deplNotificationConfigurationFieldName ) {
0 commit comments