-
Notifications
You must be signed in to change notification settings - Fork 209
Create custom list and map fields #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,25 +137,45 @@ func (m *Model) GetCRDs() ([]*CRD, error) { | |
// It's a Status field... | ||
continue | ||
} | ||
if fieldConfig.From == nil { | ||
// Isn't an additional Spec field... | ||
continue | ||
} | ||
from := fieldConfig.From | ||
memberShapeRef, found := m.SDKAPI.GetInputShapeRef( | ||
from.Operation, from.Path, | ||
) | ||
if found { | ||
memberNames := names.New(targetFieldName) | ||
crd.AddSpecField(memberNames, memberShapeRef) | ||
} else { | ||
// This is a compile-time failure, just bomb out... | ||
msg := fmt.Sprintf( | ||
"unknown additional Spec field with Op: %s and Path: %s", | ||
|
||
var found bool | ||
var memberShapeRef *awssdkmodel.ShapeRef | ||
|
||
if fieldConfig.From != nil { | ||
from := fieldConfig.From | ||
memberShapeRef, found = m.SDKAPI.GetInputShapeRef( | ||
from.Operation, from.Path, | ||
) | ||
panic(msg) | ||
if !found { | ||
// This is a compile-time failure, just bomb out... | ||
msg := fmt.Sprintf( | ||
"unknown additional Spec field with Op: %s and Path: %s", | ||
from.Operation, from.Path, | ||
) | ||
panic(msg) | ||
} | ||
} else if fieldConfig.CustomField != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like the custom field is being added to both Spec and Status-- is that intended? Am I misreading? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The field can be added to either the Spec or the Status, depending on the value of |
||
customField := fieldConfig.CustomField | ||
if customField.ListOf != "" { | ||
memberShapeRef = m.SDKAPI.GetCustomShapeRef(customField.ListOf) | ||
} else { | ||
memberShapeRef = m.SDKAPI.GetCustomShapeRef(customField.MapOf) | ||
} | ||
if memberShapeRef == nil { | ||
// This is a compile-time failure, just bomb out... | ||
msg := fmt.Sprintf( | ||
"unknown additional Spec field with custom field %+v", | ||
customField, | ||
) | ||
panic(msg) | ||
} | ||
} else { | ||
// Spec field is not well defined | ||
continue | ||
} | ||
|
||
memberNames := names.New(targetFieldName) | ||
crd.AddSpecField(memberNames, memberShapeRef) | ||
} | ||
|
||
// Now process the fields that will go into the Status struct. We want | ||
|
@@ -209,25 +229,45 @@ func (m *Model) GetCRDs() ([]*CRD, error) { | |
// It's a Spec field... | ||
continue | ||
} | ||
if fieldConfig.From == nil { | ||
// Isn't an additional Status field... | ||
continue | ||
} | ||
from := fieldConfig.From | ||
memberShapeRef, found := m.SDKAPI.GetOutputShapeRef( | ||
from.Operation, from.Path, | ||
) | ||
if found { | ||
memberNames := names.New(targetFieldName) | ||
crd.AddStatusField(memberNames, memberShapeRef) | ||
} else { | ||
// This is a compile-time failure, just bomb out... | ||
msg := fmt.Sprintf( | ||
"unknown additional Status field with Op: %s and Path: %s", | ||
|
||
var found bool | ||
var memberShapeRef *awssdkmodel.ShapeRef | ||
|
||
if fieldConfig.From != nil { | ||
from := fieldConfig.From | ||
memberShapeRef, found = m.SDKAPI.GetOutputShapeRef( | ||
from.Operation, from.Path, | ||
) | ||
panic(msg) | ||
if !found { | ||
// This is a compile-time failure, just bomb out... | ||
msg := fmt.Sprintf( | ||
"unknown additional Status field with Op: %s and Path: %s", | ||
from.Operation, from.Path, | ||
) | ||
panic(msg) | ||
} | ||
} else if fieldConfig.CustomField != nil { | ||
customField := fieldConfig.CustomField | ||
if customField.ListOf != "" { | ||
memberShapeRef = m.SDKAPI.GetCustomShapeRef(customField.ListOf) | ||
} else { | ||
memberShapeRef = m.SDKAPI.GetCustomShapeRef(customField.MapOf) | ||
} | ||
if memberShapeRef == nil { | ||
// This is a compile-time failure, just bomb out... | ||
msg := fmt.Sprintf( | ||
"unknown additional Status field with custom field %+v", | ||
customField, | ||
) | ||
panic(msg) | ||
} | ||
} else { | ||
// Status field is not well defined | ||
continue | ||
} | ||
|
||
memberNames := names.New(targetFieldName) | ||
crd.AddStatusField(memberNames, memberShapeRef) | ||
} | ||
|
||
crds = append(crds, crd) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,8 @@ package model_test | |
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/aws-controllers-k8s/code-generator/pkg/model" | ||
"github.com/stretchr/testify/assert" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: import order There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh damn linter, again. |
||
) | ||
|
||
func TestReplacePkgName(t *testing.T) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.