@@ -547,82 +547,83 @@ func runDeploymentUpdateAction(d *schema.ResourceData, apiClient *client.Multicl
547
547
548
548
name := d .Get ("name" )
549
549
if ! updateAvailable {
550
- log .Printf ("Update action is not available on the vra_deployment %s, hence new inputs are not applied" , name )
551
- } else {
552
- var inputs = make (map [string ]interface {})
553
- blueprintID , catalogItemID := "" , ""
554
- if v , ok := d .GetOk ("catalog_item_id" ); ok {
555
- catalogItemID = v .(string )
556
- }
550
+ return fmt .Errorf ("noticed changes to inputs, but 'Update' action is not supported based on the current state of the deployment %s" , name )
551
+ }
552
+
553
+ // Continue if update action is available.
554
+ var inputs = make (map [string ]interface {})
555
+ blueprintID , catalogItemID := "" , ""
556
+ if v , ok := d .GetOk ("catalog_item_id" ); ok {
557
+ catalogItemID = v .(string )
558
+ }
557
559
558
- if v , ok := d .GetOk ("blueprint_id" ); ok {
559
- blueprintID = v .(string )
560
+ if v , ok := d .GetOk ("blueprint_id" ); ok {
561
+ blueprintID = v .(string )
562
+ }
563
+
564
+ // If catalog_item_id is provided, get the catalog item schema deployment with the catalog item
565
+ if catalogItemID != "" {
566
+ catalogItemVersion := ""
567
+ if v , ok := d .GetOk ("catalog_item_version" ); ok {
568
+ catalogItemVersion = v .(string )
560
569
}
561
570
562
- // If catalog_item_id is provided, get the catalog item schema deployment with the catalog item
563
- if catalogItemID != "" {
564
- catalogItemVersion := ""
565
- if v , ok := d .GetOk ("catalog_item_version" ); ok {
566
- catalogItemVersion = v .(string )
571
+ if v , ok := d .GetOk ("inputs" ); ok {
572
+ // If the inputs are provided, get the schema from catalog item to convert the provided input values
573
+ // to the type defined in the schema.
574
+ inputsSchemaMap , err := getCatalogItemSchema (apiClient , catalogItemID , catalogItemVersion )
575
+ if err != nil {
576
+ return err
567
577
}
568
578
569
- if v , ok := d .GetOk ("inputs" ); ok {
570
- // If the inputs are provided, get the schema from catalog item to convert the provided input values
571
- // to the type defined in the schema.
572
- inputsSchemaMap , err := getCatalogItemSchema (apiClient , catalogItemID , catalogItemVersion )
573
- if err != nil {
574
- return err
575
- }
576
-
577
- log .Printf ("Inputs Schema: %v" , inputsSchemaMap )
578
- inputTypesMap , err := getInputTypesMapFromCatalogItemSchema (inputsSchemaMap )
579
- if err != nil {
580
- return err
581
- }
582
-
583
- log .Printf ("InputTypesMap: %v" , inputTypesMap )
584
- inputs , err = getInputsByType (v .(map [string ]interface {}), inputTypesMap )
585
- if err != nil {
586
- return err
587
- }
588
- }
589
- } else if blueprintID != "" {
590
- blueprintVersion := ""
591
- if v , ok := d .GetOk ("blueprint_version" ); ok {
592
- blueprintVersion = v .(string )
579
+ log .Printf ("Inputs Schema: %v" , inputsSchemaMap )
580
+ inputTypesMap , err := getInputTypesMapFromCatalogItemSchema (inputsSchemaMap )
581
+ if err != nil {
582
+ return err
593
583
}
594
584
595
- if v , ok := d .GetOk ("inputs" ); ok {
596
- // If the inputs are provided, get the schema from blueprint to convert the provided input values
597
- // to the type defined in the schema.
598
- inputsSchemaMap , err := getBlueprintSchema (apiClient , blueprintID , blueprintVersion )
599
- if err != nil {
600
- return err
601
- }
602
-
603
- log .Printf ("Inputs Schema: %v" , inputsSchemaMap )
604
- inputTypesMap , err := getInputTypesMapFromBlueprintInputsSchema (inputsSchemaMap )
605
- if err != nil {
606
- return err
607
- }
608
-
609
- log .Printf ("InputTypesMap: %v" , inputTypesMap )
610
- inputs , err = getInputsByType (v .(map [string ]interface {}), inputTypesMap )
611
- if err != nil {
612
- return err
613
- }
585
+ log .Printf ("InputTypesMap: %v" , inputTypesMap )
586
+ inputs , err = getInputsByType (v .(map [string ]interface {}), inputTypesMap )
587
+ if err != nil {
588
+ return err
614
589
}
615
590
}
591
+ } else if blueprintID != "" {
592
+ blueprintVersion := ""
593
+ if v , ok := d .GetOk ("blueprint_version" ); ok {
594
+ blueprintVersion = v .(string )
595
+ }
616
596
617
- reason := "Updated deployment inputs from vRA provider for Terraform."
618
- err := runAction (d , apiClient , deploymentUUID , actionID , inputs , reason )
619
- if err != nil {
620
- return err
597
+ if v , ok := d .GetOk ("inputs" ); ok {
598
+ // If the inputs are provided, get the schema from blueprint to convert the provided input values
599
+ // to the type defined in the schema.
600
+ inputsSchemaMap , err := getBlueprintSchema (apiClient , blueprintID , blueprintVersion )
601
+ if err != nil {
602
+ return err
603
+ }
604
+
605
+ log .Printf ("Inputs Schema: %v" , inputsSchemaMap )
606
+ inputTypesMap , err := getInputTypesMapFromBlueprintInputsSchema (inputsSchemaMap )
607
+ if err != nil {
608
+ return err
609
+ }
610
+
611
+ log .Printf ("InputTypesMap: %v" , inputTypesMap )
612
+ inputs , err = getInputsByType (v .(map [string ]interface {}), inputTypesMap )
613
+ if err != nil {
614
+ return err
615
+ }
621
616
}
617
+ }
622
618
623
- log .Printf ("Finished updating vra_deployment %s with inputs" , name )
619
+ reason := "Updated deployment inputs from vRA provider for Terraform."
620
+ err = runAction (d , apiClient , deploymentUUID , actionID , inputs , reason )
621
+ if err != nil {
622
+ return err
624
623
}
625
624
625
+ log .Printf ("Finished updating vra_deployment %s with inputs" , name )
626
+
626
627
return nil
627
628
}
628
629
0 commit comments