Skip to content

Commit a97b811

Browse files
wip separate input and output types
1 parent c8fb1b6 commit a97b811

File tree

3 files changed

+70
-14
lines changed

3 files changed

+70
-14
lines changed

pkg/pf/tfgen/testdata/TestPFNestedFullyComputed.golden

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@
1919
"config": {},
2020
"types": {
2121
"testprovider:index/ResB1:ResB1": {
22+
"properties": {
23+
"a1": {
24+
"type": "string"
25+
},
26+
"a2": {
27+
"type": "string"
28+
}
29+
},
30+
"type": "object"
31+
},
32+
"testprovider:index/ResB1Output:ResB1Output": {
2233
"properties": {
2334
"a1": {
2435
"type": "string"
@@ -28,11 +39,12 @@
2839
}
2940
},
3041
"type": "object",
42+
"required": [
43+
"a1"
44+
],
3145
"language": {
3246
"nodejs": {
33-
"requiredOutputs": [
34-
"a1"
35-
]
47+
"requiredInputs": []
3648
}
3749
}
3850
}
@@ -47,7 +59,7 @@
4759
"testprovider:index:Res": {
4860
"properties": {
4961
"b1": {
50-
"$ref": "#/types/testprovider:index/ResB1:ResB1"
62+
"$ref": "#/types/testprovider:index/ResB1Output:ResB1OutputOutput"
5163
}
5264
},
5365
"inputProperties": {

pkg/tfgen/generate_schema.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ func (nt *schemaNestedTypes) declareType(typePath paths.TypePath, declarer decla
136136
typeName = typ.nestedType.Name().String()
137137
}
138138

139+
if !isInput {
140+
typeName += "Output"
141+
}
142+
139143
typ.name = typeName
140144

141145
required := codegen.StringSet{}
@@ -1097,6 +1101,9 @@ func (g *schemaGenerator) schemaType(path paths.TypePath, typ *propertyType, out
10971101
case kindObject:
10981102
mod := modulePlacementForType(g.pkg, path)
10991103
ref := fmt.Sprintf("#/types/%s/%s:%s", mod.String(), typ.name, typ.name)
1104+
if out {
1105+
ref += "Output"
1106+
}
11001107
return pschema.TypeSpec{Ref: ref}
11011108
default:
11021109
contract.Failf("Unrecognized type kind: %v", typ.kind)

pkg/tfgen/test_data/nested-fully-computed-schema.json

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,30 @@
4343
],
4444
"language": {
4545
"nodejs": {
46-
"requiredOutputs": [
47-
"a1",
48-
"a3"
49-
]
46+
"requiredOutputs": []
47+
}
48+
}
49+
},
50+
"testprovider:index/ResBlockOutput:ResBlockOutput": {
51+
"properties": {
52+
"a1": {
53+
"type": "string"
54+
},
55+
"a2": {
56+
"type": "string"
57+
},
58+
"a3": {
59+
"type": "string"
60+
}
61+
},
62+
"type": "object",
63+
"required": [
64+
"a1",
65+
"a3"
66+
],
67+
"language": {
68+
"nodejs": {
69+
"requiredInputs": []
5070
}
5171
}
5272
},
@@ -65,10 +85,27 @@
6585
],
6686
"language": {
6787
"nodejs": {
68-
"requiredOutputs": [
69-
"b1",
70-
"b2"
71-
]
88+
"requiredOutputs": []
89+
}
90+
}
91+
},
92+
"testprovider:index/ResOtherBlockOutput:ResOtherBlockOutput": {
93+
"properties": {
94+
"b1": {
95+
"type": "string"
96+
},
97+
"b2": {
98+
"type": "string"
99+
}
100+
},
101+
"type": "object",
102+
"required": [
103+
"b1",
104+
"b2"
105+
],
106+
"language": {
107+
"nodejs": {
108+
"requiredInputs": []
72109
}
73110
}
74111
}
@@ -85,11 +122,11 @@
85122
"blocks": {
86123
"type": "array",
87124
"items": {
88-
"$ref": "#/types/testprovider:index/ResBlock:ResBlock"
125+
"$ref": "#/types/testprovider:index/ResBlockOutput:ResBlockOutputOutput"
89126
}
90127
},
91128
"otherBlock": {
92-
"$ref": "#/types/testprovider:index/ResOtherBlock:ResOtherBlock"
129+
"$ref": "#/types/testprovider:index/ResOtherBlockOutput:ResOtherBlockOutputOutput"
93130
}
94131
},
95132
"required": [

0 commit comments

Comments
 (0)