Skip to content

Commit

Permalink
Merge pull request #20 from mulesoft-anypoint/dev
Browse files Browse the repository at this point in the history
BG Specific Fixes and Enhancements
  • Loading branch information
soufi authored Oct 16, 2023
2 parents ea2765d + ce0beab commit 7e7ba91
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTNAME=anypoint.mulesoft.com
NAMESPACE=automation
NAME=anypoint
BINARY=terraform-provider-${NAME}
VERSION=1.5.4-SNAPSHOT
VERSION=1.5.6-SNAPSHOT
OS_ARCH=darwin_amd64

default: install
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ In this repository, you'll discover:

* **Issues and Contributions:** A space to report issues, suggest improvements, and contribute to the development of the provider. We welcome your contributions and feedback!



## How it works

This provider uses the anypoint platform APIs to perform actions for each one of the implemented resources.
Expand Down Expand Up @@ -129,6 +127,8 @@ Now you can run terraform using the debugger, here's an example:
TF_REATTACH_PROVIDERS='{"anypoint.mulesoft.com/automation/anypoint":{"Protocol":"grpc","Pid":69612,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/yc/k0_j_x0945jdthsw7fzw5ysh0000gp/T/plugin598168131"}}}' terraform apply --auto-approve -var-file="params.tfvars.json"
```

> **N.B:** Make sure that your script uses the source `anypoint.mulesoft.com/automation/anypoint`. Otherwise, it won't work.
#### How to log

Use `log` package to log. Here's an exampe:
Expand Down
43 changes: 29 additions & 14 deletions anypoint/resource_bg.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@ func resourceBG() *schema.Resource {
"entitlements_mqmessages_base": {
Type: schema.TypeInt,
Optional: true,
Default: 100000,
Description: "The number of basic MQ messages assigned to this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "0") // default value of integers if not set is 0
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "100000") // default value of integers if not set is 0
},
},
"entitlements_mqmessages_addon": {
Expand All @@ -332,9 +333,10 @@ func resourceBG() *schema.Resource {
"entitlements_mqrequests_base": {
Type: schema.TypeInt,
Optional: true,
Default: 1000000,
Description: "The number of MQ requests base assigned to this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "0") // default value of integers if not set is 0
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "1000000") // default value of integers if not set is 0
},
},
"entitlements_mqrequests_addon": {
Expand Down Expand Up @@ -380,14 +382,16 @@ func resourceBG() *schema.Resource {
"entitlements_mqadvancedfeatures_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Whether the Anypoint MQ advanced features are enabled for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "false") // default value of bool if not set is false
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "true") // default value of bool if not set is false
},
},
"entitlements_gateways_assigned": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
Description: "The number of gateways assigned to this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "0") // default value of integers if not set is 0
Expand All @@ -396,17 +400,19 @@ func resourceBG() *schema.Resource {
"entitlements_designcenter_api": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Whether te design center api is enabled for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "false") // default value of bool if not set is false
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "true") // default value of bool if not set is false
},
},
"entitlements_designcenter_mozart": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Whether the design center mozart is enabled for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "false") // default value of bool if not set is false
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "true") // default value of bool if not set is false
},
},
"entitlements_partnersproduction_assigned": {
Expand Down Expand Up @@ -490,9 +496,10 @@ func resourceBG() *schema.Resource {
"entitlements_apimonitoring_schedules": {
Type: schema.TypeInt,
Optional: true,
Default: 5,
Description: "The number of api monitoring schedules for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "0") // default value of integers if not set is 0
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "5") // default value of integers if not set is 0
},
},
"entitlements_apicommunitymanager_enabled": {
Expand All @@ -506,25 +513,28 @@ func resourceBG() *schema.Resource {
"entitlements_monitoringcenter_productsku": {
Type: schema.TypeInt,
Optional: true,
Default: 3,
Description: "The number of monitoring center products sku for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "0") // default value of integers if not set is 0
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "3") // default value of integers if not set is 0
},
},
"entitlements_apiquery_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Whether api queries are enabled for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "false") // default value of bool if not set is false
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "true") // default value of bool if not set is false
},
},
"entitlements_apiquery_productsku": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
Description: "The number of api query product sku for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "0") // default value of integers if not set is 0
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "1") // default value of integers if not set is 0
},
},
"entitlements_apiqueryc360_enabled": {
Expand Down Expand Up @@ -623,25 +633,28 @@ func resourceBG() *schema.Resource {
"entitlements_anypointsecuritytokenization_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "whether Anypoint securirty tokenization is enabled for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "false") // default value of bool if not set is false
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "true") // default value of bool if not set is false
},
},
"entitlements_anypointsecurityedgepolicies_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Whether Anypoint security edge policies is enabled for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "false") // default value of bool if not set is false
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "true") // default value of bool if not set is false
},
},
"entitlements_runtimefabriccloud_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Whether Runtime Fabrics (RTF) is enabled for this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "false") // default value of bool if not set is false
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "true") // default value of bool if not set is false
},
},
"entitlements_servicemesh_enabled": {
Expand All @@ -655,17 +668,19 @@ func resourceBG() *schema.Resource {
"entitlements_messaging_assigned": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
Description: "The number of messaging assigned to this organization.",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "0") // default value of integers if not set is 0
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "1") // default value of integers if not set is 0
},
},
"entitlements_workerclouds_assigned": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
Description: "The number of worker clouds assigned to this organization",
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "0") // default value of integers if not set is 0
return DiffSuppressFunc4OptionalPrimitives(k, old, new, d, "1") // default value of integers if not set is 0
},
},
"entitlements_workerclouds_reassigned": {
Expand Down
2 changes: 1 addition & 1 deletion anypoint/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func FilterMapList(list []interface{}, filter func(map[string]interface{}) bool)
// compares diffing for optional values, if the new value is equal to the initial value (that is the default value)
// returns true if the attribute has the same value as the initial or if the new and old value are the same which needs no updaten false otherwise.
func DiffSuppressFunc4OptionalPrimitives(k, old, new string, d *schema.ResourceData, initial string) bool {
if new == initial {
if len(old) == 0 && new == initial {
return true
} else {
return old == new
Expand Down

0 comments on commit 7e7ba91

Please sign in to comment.