Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit dbc4fc6

Browse files
committed
Add variables for flow JSON paths/contents in generated HCL
1 parent a15267f commit dbc4fc6

7 files changed

Lines changed: 84 additions & 4 deletions

File tree

internal/generate/templates/0.4/hcl_davinci_flow.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ resource "davinci_flow" "{{.ResourceName}}" {
1313
name = var.davinci_flow_{{.ResourceName}}_name
1414
description = var.davinci_flow_{{.ResourceName}}_description
1515

16-
flow_json = file("{{.FlowJSONPath}}")
16+
flow_json = var.davinci_flow_{{.ResourceName}}_json_file_path != null ? file(var.davinci_flow_{{.ResourceName}}_json_file_path) : var.davinci_flow_{{.ResourceName}}_json
1717

1818
{{if .ConnectionLinks}}
1919

internal/generate/templates/0.4/hcl_davinci_flow_vars.tf.tmpl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,24 @@ variable "davinci_flow_{{.ResourceName}}_description" {
2424
default = null
2525
{{- end}}
2626
}
27+
28+
// The location of the flow file path
29+
variable "davinci_flow_{{.ResourceName}}_json_file_path" {
30+
type = string
31+
32+
description = "The filesystem location of the flow JSON with resource name '{{.ResourceName}}'. Cannot be set with the `davinci_flow_{{.ResourceName}}_json` variable."
33+
default = "{{.FlowJSONPath}}"
34+
35+
validation {
36+
condition = (var.davinci_flow_{{.ResourceName}}_json_file_path != null || var.davinci_flow_{{.ResourceName}}_json != null) && (var.davinci_flow_{{.ResourceName}}_json_file_path == null || var.davinci_flow_{{.ResourceName}}_json == null)
37+
error_message = "Must set either 'davinci_flow_{{.ResourceName}}_json_file_path' or 'davinci_flow_{{.ResourceName}}_json', but not both together."
38+
}
39+
}
40+
41+
// The raw JSON of the flow
42+
variable "davinci_flow_{{.ResourceName}}_json" {
43+
type = string
44+
45+
description = "The filesystem location of the flow JSON with resource name '{{.ResourceName}}'. Cannot be set with the `davinci_flow_{{.ResourceName}}_json_file_path` variable."
46+
default = null
47+
}

scripts/generate-multiple.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# Directory containing the files
44
directory="./assets/flows"

scripts/generate-test-all.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
set -e # Exit immediately if a command exits with a non-zero status
4+
5+
script_dir=$(dirname "$(realpath "$0")")
6+
echo $script_dir
7+
8+
ls $script_dir/../testing/test-cases
9+
10+
for dir in "$script_dir/../testing/test-cases"/*/; do
11+
if [ -d "$dir" ]; then
12+
echo "Running generate-test.sh in $dir"
13+
$script_dir/generate-test.sh $dir
14+
fi
15+
done

scripts/generate-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
go build .
44

scripts/validate-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# Directory containing the files
44
directory=$1

testing/test-cases/ciam-passwordless-flow-pack/general.tftest.hcl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,50 @@ run "properties_generated" {
8888
}
8989
}
9090

91+
run "flow_vars_conflicting" {
92+
93+
variables {
94+
pingone_environment_id = run.pingone_setup.pingone_environment_id
95+
96+
davinci_flow_ciam_passwordless_protect_account_recovery_subflow_json_file_path = "assets/flows/ciam_passwordless_protect_account_recovery_subflow.json"
97+
davinci_flow_ciam_passwordless_protect_account_recovery_subflow_json = jsonencode({})
98+
}
99+
100+
command = plan
101+
102+
expect_failures = [
103+
var.davinci_flow_ciam_passwordless_protect_account_recovery_subflow_json_file_path
104+
]
105+
}
106+
107+
run "flow_vars_missing" {
108+
109+
variables {
110+
pingone_environment_id = run.pingone_setup.pingone_environment_id
111+
112+
davinci_flow_ciam_passwordless_protect_account_recovery_subflow_json_file_path = null
113+
davinci_flow_ciam_passwordless_protect_account_recovery_subflow_json = null
114+
}
115+
116+
command = plan
117+
118+
expect_failures = [
119+
var.davinci_flow_ciam_passwordless_protect_account_recovery_subflow_json_file_path
120+
]
121+
}
122+
123+
run "flow_json_override" {
124+
125+
variables {
126+
pingone_environment_id = run.pingone_setup.pingone_environment_id
127+
128+
davinci_flow_ciam_passwordless_protect_account_recovery_subflow_json_file_path = null
129+
davinci_flow_ciam_passwordless_protect_account_recovery_subflow_json = file("assets/flows/ciam_passwordless_protect_account_recovery_subflow.json")
130+
}
131+
132+
command = plan
133+
}
134+
91135
run "apply_success" {
92136

93137
variables {

0 commit comments

Comments
 (0)