Skip to content

Commit

Permalink
Flow variable import and data type fixes (#361)
Browse files Browse the repository at this point in the history
* Draft fix

* changelog

* add better flow validation debug

* add variable values validation

* update documentation

* switch flow read to export variable values

* changelog

* changelog

* update tests

* bump dv sdk

* update for lint
  • Loading branch information
patrickcping authored Aug 20, 2024
1 parent 09dd805 commit 0b7885f
Show file tree
Hide file tree
Showing 14 changed files with 339 additions and 114 deletions.
23 changes: 23 additions & 0 deletions .changelog/361.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```release-note:bug
`resource/davinci_variable`: Fixed panic crash when attempting to create a new flow variable that does not already exist.
```

```release-note:bug
`resource/davinci_variable`: Fixed "Error reading variable: json: cannot unmarshal object into Go struct field" error on all variables when a flow sets a flow variable value to an object type.
```

```release-note:breaking-change
`resource/davinci_flow`: Reverted the ability to use flow exports with variable values removed. Variable values are required when importing flows using this provider.
```

```release-note:bug
`resource/davinci_flow`: Resolve warnings that state that DaVinci JSON files contain unknown properties when using flow variable nodes.
```

```release-note:note
`resource/davinci_flow`: Enhanced error messages that result from invalid flow formats.
```

```release-note:note
Bump `github.com/samir-gandhi/davinci-client-go` from 0.4.0 => 0.5.0
```
2 changes: 2 additions & 0 deletions docs/resources/flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description: |-

Resource to import and manage a DaVinci flow in an environment. Connection and Subflow references in the JSON export can be overridden with ones managed by Terraform, see the examples and schema below for details.

!> Only flows that include variable values are supported. Flows that have been exported from a source system with the "Include Variable Values" admin console tickbox unchecked will not be imported correctly.

!> When flow, flow instance or company variables are embedded in the `flow_json`, only the `context`, `type` and `name` of the variables are managed by this resource. To manage the mutability, value, description, minimum and maximum values of an imported variable, the `davinci_variable` resource must be used.

~> When using "company" or "flow instance" variables, it is recommended to define these variables using the `davinci_variable` resource before the flows that depend on them. This is shown in the example using the `depends_on` meta argument.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/patrickcping/pingone-go-sdk-v2 v0.12.3
github.com/patrickcping/pingone-go-sdk-v2/management v0.43.0
github.com/pavius/impi v0.0.3
github.com/samir-gandhi/davinci-client-go v0.4.0
github.com/samir-gandhi/davinci-client-go v0.5.0
github.com/samir-gandhi/dvgenerate v0.0.11
github.com/terraform-linters/tflint v0.53.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,8 @@ github.com/ryancurrah/gomodguard v1.3.3 h1:eiSQdJVNr9KTNxY2Niij8UReSwR8Xrte3exBr
github.com/ryancurrah/gomodguard v1.3.3/go.mod h1:rsKQjj4l3LXe8N344Ow7agAy5p9yjsWOtRzUMYmA0QY=
github.com/ryanrolds/sqlclosecheck v0.5.1 h1:dibWW826u0P8jNLsLN+En7+RqWWTYrjCB9fJfSfdyCU=
github.com/ryanrolds/sqlclosecheck v0.5.1/go.mod h1:2g3dUjoS6AL4huFdv6wn55WpLIDjY7ZgUR4J8HOO/XQ=
github.com/samir-gandhi/davinci-client-go v0.4.0 h1:XsjCOxZhm9AvhVREUuqFP09dMjHwnsk4pDAx6uPzaUk=
github.com/samir-gandhi/davinci-client-go v0.4.0/go.mod h1:DmOPy/WsIc4e7RYOIeSGM6Qrlb1JsYuN45UaGnlDt9U=
github.com/samir-gandhi/davinci-client-go v0.5.0 h1:8aYXLsfdepnR5seT7suqI2WTQkhueX/8KzvevHy5LBA=
github.com/samir-gandhi/davinci-client-go v0.5.0/go.mod h1:DmOPy/WsIc4e7RYOIeSGM6Qrlb1JsYuN45UaGnlDt9U=
github.com/samir-gandhi/dvgenerate v0.0.11 h1:VMvkeCdI7DyzrPuE3clPFPvR1gO9s6Z24O8Gyh0d5h8=
github.com/samir-gandhi/dvgenerate v0.0.11/go.mod h1:PvrK6c+8SdRSWKmyXsagKeVqSGoo9P8oBbWaIzFD1mQ=
github.com/sanposhiho/wastedassign/v2 v2.0.7 h1:J+6nrY4VW+gC9xFzUc+XjPD3g3wF3je/NsJFwFK7Uxc=
Expand Down
70 changes: 35 additions & 35 deletions internal/acctest/flows/full-basic-novariablevalues.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"companyId": "942b4724-d83d-418c-966c-ed7d352a985c",
"companyId": "2c6123ae-108f-4d11-bcc2-6c8f4dfa9fdb",
"authTokenExpireIds": [],
"connectorIds": [
"httpConnector",
Expand All @@ -8,29 +8,29 @@
"flowConnector",
"variablesConnector"
],
"createdDate": 1723638023970,
"currentVersion": 1,
"createdDate": 1706708769850,
"currentVersion": 8,
"customerId": "db5f4450b2bd8a56ce076dec0c358a9a",
"deployedDate": 1723638024066,
"description": "Imported on Wed Aug 14 2024 12:20:23 GMT+0000 (Coordinated Universal Time)",
"deployedDate": 1706709739837,
"description": "",
"flowStatus": "enabled",
"isOutputSchemaSaved": false,
"name": "full-basic",
"publishedVersion": 1,
"publishedVersion": 8,
"timeouts": "null",
"updatedDate": 1723638024104,
"flowId": "8236d08b476a5cf7b981fa53f6971019",
"versionId": 1,
"updatedDate": 1706709739837,
"flowId": "c7062a8857740ee2185694bb855f8f21",
"versionId": 8,
"graphData": {
"elements": {
"nodes": [
{
"data": {
"id": "1u2m5vzr49",
"nodeType": "CONNECTION",
"connectionId": "481e952e6b11db8360587b8711620786",
"connectionId": "867ed4363b2bc21c860085ad2baa817d",
"connectorId": "httpConnector",
"name": "HTTP",
"name": "Http",
"label": "Http",
"status": "configured",
"capabilityName": "customHtmlMessage",
Expand Down Expand Up @@ -77,9 +77,9 @@
"data": {
"id": "nx0o1b2cmw",
"nodeType": "CONNECTION",
"connectionId": "548ea933f35b9787ae12ad130f78045b",
"connectionId": "de650ca45593b82c49064ead10b9fe17",
"connectorId": "functionsConnector",
"name": "abcd123-functions",
"name": "Functions",
"label": "Functions",
"status": "configured",
"capabilityName": "AEqualsB",
Expand Down Expand Up @@ -137,9 +137,9 @@
"data": {
"id": "ikt13crnhy",
"nodeType": "CONNECTION",
"connectionId": "481e952e6b11db8360587b8711620786",
"connectionId": "867ed4363b2bc21c860085ad2baa817d",
"connectorId": "httpConnector",
"name": "HTTP",
"name": "Http",
"label": "Http",
"status": "configured",
"capabilityName": "createSuccessResponse",
Expand All @@ -163,9 +163,9 @@
"data": {
"id": "vsp1ewtr9m",
"nodeType": "CONNECTION",
"connectionId": "fa497c1ceaea43c0886d8d360874a53d",
"connectionId": "53ab83a4a4ab919d9f2cb02d9e111ac8",
"connectorId": "errorConnector",
"name": "abcd123-error",
"name": "Error Message",
"label": "Error Message",
"status": "configured",
"capabilityName": "customErrorMessage",
Expand Down Expand Up @@ -193,9 +193,9 @@
"data": {
"id": "xb74p6rkd8",
"nodeType": "CONNECTION",
"connectionId": "84e29d2409ba66c0caf53f9cad0a2049",
"connectionId": "2581eb287bb1d9bd29ae9886d675f89f",
"connectorId": "flowConnector",
"name": "abcd123-flow",
"name": "Flow Connector",
"label": "Flow Conductor",
"status": "configured",
"capabilityName": "startUiSubFlow",
Expand Down Expand Up @@ -229,9 +229,9 @@
"data": {
"id": "kq5ybvwvro",
"nodeType": "CONNECTION",
"connectionId": "84e29d2409ba66c0caf53f9cad0a2049",
"connectionId": "2581eb287bb1d9bd29ae9886d675f89f",
"connectorId": "flowConnector",
"name": "abcd123-flow",
"name": "Flow Connector",
"label": "Flow Conductor",
"status": "configured",
"capabilityName": "startUiSubFlow",
Expand Down Expand Up @@ -301,9 +301,9 @@
"data": {
"id": "3zvjdgdljx",
"nodeType": "CONNECTION",
"connectionId": "9f8f97e94ad87e184960633b424d80b6",
"connectionId": "06922a684039827499bdbdd97f49827b",
"connectorId": "variablesConnector",
"name": "abcd123-variables",
"name": "Variables",
"label": "Variables",
"status": "configured",
"capabilityName": "saveFlowValue",
Expand Down Expand Up @@ -589,42 +589,42 @@
}
},
"flowColor": "#E3F0FF",
"savedDate": 1723638023903,
"savedDate": 1706708769645,
"variables": [
{
"context": "flow",
"createdDate": 1723638023769,
"createdDate": 1706708735989,
"customerId": "db5f4450b2bd8a56ce076dec0c358a9a",
"fields": {
"type": "string",
"displayName": "",
"mutable": true,
"min": 0,
"max": 2000
},
"flowId": "8236d08b476a5cf7b981fa53f6971019",
"id": "bfaf14e8-0756-4e78-800e-90f558391368",
"flowId": "c7062a8857740ee2185694bb855f8f21",
"type": "property",
"visibility": "private",
"name": "fdgdfgfdg##SK##flow##SK##8236d08b476a5cf7b981fa53f6971019",
"companyId": "942b4724-d83d-418c-966c-ed7d352a985c"
"name": "fdgdfgfdg##SK##flow##SK##c7062a8857740ee2185694bb855f8f21",
"companyId": "2c6123ae-108f-4d11-bcc2-6c8f4dfa9fdb"
},
{
"context": "flow",
"createdDate": 1723638023768,
"createdDate": 1706708761083,
"customerId": "db5f4450b2bd8a56ce076dec0c358a9a",
"fields": {
"type": "number",
"displayName": "test123",
"mutable": true,
"min": 4,
"max": 20
},
"flowId": "8236d08b476a5cf7b981fa53f6971019",
"id": "0389e818-4dd2-4203-b82f-ee5948f93287",
"flowId": "c7062a8857740ee2185694bb855f8f21",
"type": "property",
"visibility": "private",
"name": "test123##SK##flow##SK##8236d08b476a5cf7b981fa53f6971019",
"companyId": "942b4724-d83d-418c-966c-ed7d352a985c"
"name": "test123##SK##flow##SK##c7062a8857740ee2185694bb855f8f21",
"companyId": "2c6123ae-108f-4d11-bcc2-6c8f4dfa9fdb"
}
],
"connections": []
}
}
15 changes: 10 additions & 5 deletions internal/acctest/flows/full-basic-vars-add-variable.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,19 +315,22 @@
"name": "fdgdfgfdg",
"key": 0.8936786494474329,
"label": "fdgdfgfdg (string - flow)",
"type": "string"
"type": "string",
"value": "fdgdfgfdgValue"
},
{
"name": "fdgdfgfdgNEW",
"key": 0.8936786494474330,
"label": "fdgdfgfdgNEW (string - flow)",
"type": "string"
"type": "string",
"value": "fdgdfgfdgNEWValue"
},
{
"name": "test123",
"key": 0.379286774724122,
"label": "test123 (number - flow)",
"type": "number"
"type": "number",
"value": 5
}
]
}
Expand Down Expand Up @@ -382,7 +385,8 @@
"name": "flowInstanceVariable1",
"key": 0.09068454768967449,
"label": "flowInstanceVariable1 (string - flowInstance)",
"type": "string"
"type": "string",
"value": "flowInstanceVariable1Value"
}
]
}
Expand Down Expand Up @@ -437,7 +441,8 @@
"name": "testuser",
"key": 0.9814043007447408,
"label": "testuser (string - flowInstance)",
"type": "string"
"type": "string",
"value": "testuserValue"
}
]
}
Expand Down
12 changes: 8 additions & 4 deletions internal/acctest/flows/full-basic-vars-modify-variable.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,15 @@
"name": "fdgdfgfdg",
"key": 0.8936786494474329,
"label": "fdgdfgfdg (number - flow)",
"type": "number"
"type": "number",
"value": 10
},
{
"name": "test123",
"key": 0.379286774724122,
"label": "test123 (number - flow)",
"type": "number"
"type": "number",
"value": 5
}
]
}
Expand Down Expand Up @@ -376,7 +378,8 @@
"name": "flowInstanceVariable1",
"key": 0.09068454768967449,
"label": "flowInstanceVariable1 (string - flowInstance)",
"type": "string"
"type": "string",
"value": "flowInstanceVariable1Value"
}
]
}
Expand Down Expand Up @@ -431,7 +434,8 @@
"name": "testuser",
"key": 0.9814043007447408,
"label": "testuser (string - flowInstance)",
"type": "string"
"type": "string",
"value": "testuserValue"
}
]
}
Expand Down
9 changes: 6 additions & 3 deletions internal/acctest/flows/full-basic-vars-remove-variable.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@
"name": "test123",
"key": 0.379286774724122,
"label": "test123 (number - flow)",
"type": "number"
"type": "number",
"value": 5
}
]
}
Expand Down Expand Up @@ -370,7 +371,8 @@
"name": "flowInstanceVariable1",
"key": 0.09068454768967449,
"label": "flowInstanceVariable1 (string - flowInstance)",
"type": "string"
"type": "string",
"value": "flowInstanceVariable1Value"
}
]
}
Expand Down Expand Up @@ -425,7 +427,8 @@
"name": "testuser",
"key": 0.9814043007447408,
"label": "testuser (string - flowInstance)",
"type": "string"
"type": "string",
"value": "testuserValue"
}
]
}
Expand Down
12 changes: 8 additions & 4 deletions internal/acctest/flows/full-basic-vars.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,15 @@
"name": "fdgdfgfdg",
"key": 0.8936786494474329,
"label": "fdgdfgfdg (string - flow)",
"type": "string"
"type": "string",
"value": "fdgdfgfdgValue"
},
{
"name": "test123",
"key": 0.379286774724122,
"label": "test123 (number - flow)",
"type": "number"
"type": "number",
"value": "5"
}
]
}
Expand Down Expand Up @@ -376,7 +378,8 @@
"name": "flowInstanceVariable1",
"key": 0.09068454768967449,
"label": "flowInstanceVariable1 (string - flowInstance)",
"type": "string"
"type": "string",
"value": "flowInstanceVariable1Value"
}
]
}
Expand Down Expand Up @@ -431,7 +434,8 @@
"name": "testuser",
"key": 0.9814043007447408,
"label": "testuser (string - flowInstance)",
"type": "string"
"type": "string",
"value": "testuserValue"
}
]
}
Expand Down
Loading

0 comments on commit 0b7885f

Please sign in to comment.