Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions internal/method/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewResolveReferences(traverser *xptypes.Traverser, receiver, clientPath, re
resolverCalls[i] = encapsulate(0, multiResolutionCall(ref, referencePkgPath, convertPkgPath), ref.GoValueFieldPath...).Line()
} else {
hasSingleResolution = true
resolverCalls[i] = encapsulate(0, singleResolutionCall(ref, referencePkgPath, ptrPkgPath), ref.GoValueFieldPath...).Line()
resolverCalls[i] = encapsulate(0, singleResolutionCall(ref, referencePkgPath, ptrPkgPath, convertPkgPath), ref.GoValueFieldPath...).Line()
}
}
var initStatements jen.Statement
Expand Down Expand Up @@ -113,7 +113,7 @@ func encapsulate(index int, callFn resolutionCallFn, fields ...string) *jen.Stat
}
}

func singleResolutionCall(ref Reference, referencePkgPath string, ptrPkgPath string) resolutionCallFn {
func singleResolutionCall(ref Reference, referencePkgPath string, ptrPkgPath string, convertPkgPath string) resolutionCallFn {
return func(fields ...string) *jen.Statement {
prefixPath := jen.Id(fields[0])
for i := 1; i < len(fields)-1; i++ {
Expand All @@ -129,8 +129,9 @@ func singleResolutionCall(ref Reference, referencePkgPath string, ptrPkgPath str
if ref.IsFloatPointer {
toPointerFunction = "ToFloatPtrValue"
fromPointerFunction = "FromFloatPtrValue"
}
if ref.IsPointer {
setResolvedValue = currentValuePath.Clone().Op("=").Qual(convertPkgPath, toPointerFunction).Call(jen.Id("rsp").Dot("ResolvedValue"))
currentValuePath = jen.Qual(convertPkgPath, fromPointerFunction).Call(currentValuePath)
} else if ref.IsPointer {
setResolvedValue = currentValuePath.Clone().Op("=").Qual(ptrPkgPath, toPointerFunction).Call(jen.Id("rsp").Dot("ResolvedValue"))
currentValuePath = jen.Qual(ptrPkgPath, fromPointerFunction).Call(currentValuePath, jen.Op(`""`))
}
Expand Down
4 changes: 2 additions & 2 deletions internal/method/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (mg *Model) ResolveReferences(ctx context.Context, c client.Reader) error {
mg.Spec.ForProvider.RouteTableIDsRefs = mrsp.ResolvedReferences

rsp, err = r.Resolve(ctx, reference.ResolutionRequest{
CurrentValue: ptr.Deref(mg.Spec.ForProvider.CustomConfiguration, ""),
CurrentValue: mg.Spec.ForProvider.CustomConfiguration,
Extract: Configuration(),
Reference: mg.Spec.ForProvider.CustomConfigurationRef,
Selector: mg.Spec.ForProvider.CustomConfigurationSelector,
Expand All @@ -298,7 +298,7 @@ func (mg *Model) ResolveReferences(ctx context.Context, c client.Reader) error {
if err != nil {
return errors.Wrap(err, "mg.Spec.ForProvider.CustomConfiguration")
}
mg.Spec.ForProvider.CustomConfiguration = ptr.To(rsp.ResolvedValue)
mg.Spec.ForProvider.CustomConfiguration = rsp.ResolvedValue
mg.Spec.ForProvider.CustomConfigurationRef = rsp.ResolvedReference

return nil
Expand Down