Skip to content

Commit 93a16e4

Browse files
committed
Allow from operation to take output shapes
So currenly, when you define a `from` `operation` `path` in generator.yaml fieldConfig, the code-generator checks for the read_only configuration to decide whether to get the field from the input shape or the output shape. The change introduced here tries to retrieve spec fields from input shapes first, if not found it checks output shape. If read_only is configured to true, it does so in reverse order (checks output shape first, if not found, checks input shape)
1 parent a326346 commit 93a16e4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/model/model.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ func (m *Model) GetCRDs() ([]*CRD, error) {
176176
memberShapeRef, found = m.SDKAPI.GetInputShapeRef(
177177
from.Operation, from.Path,
178178
)
179+
// allowing getting spec fields from output shape
180+
if !found {
181+
memberShapeRef, found = m.SDKAPI.GetOutputShapeRef(
182+
from.Operation, from.Path,
183+
)
184+
}
179185
if !found {
180186
// This is a compile-time failure, just bomb out...
181187
msg := fmt.Sprintf(
@@ -289,6 +295,12 @@ func (m *Model) GetCRDs() ([]*CRD, error) {
289295
memberShapeRef, found = m.SDKAPI.GetOutputShapeRef(
290296
from.Operation, from.Path,
291297
)
298+
// allowing to get status fields from output shapes
299+
if !found {
300+
memberShapeRef, found = m.SDKAPI.GetInputShapeRef(
301+
from.Operation, from.Path,
302+
)
303+
}
292304
if !found {
293305
// This is a compile-time failure, just bomb out...
294306
msg := fmt.Sprintf(

0 commit comments

Comments
 (0)