Skip to content

fix: generate *float64 with convert import path #102

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cristiGuranIonos
Copy link

@cristiGuranIonos cristiGuranIonos commented Apr 28, 2025

Description of your changes

Float64 pointer fields are not generated correctly using the latest version of corssplane-tools:
Example:

 mg.Spec.ForProvider.Lan = ptr.ToFloatPtrValue(rsp.ResolvedValue)

Where the import is :

ptr "k8s.io/utils/ptr"

Fixes #

I have:

  • Read and followed Crossplane's [contribution process].
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Replace in go.mod for provider-upjet-ionoscloud with the local copy with the changes. Test that the code is generated correctly.

go mod vendor
make generate
make run

Ran tests in resolvers_test.go . These tests were failing before I made any changes:

		          		rsp, err = r.Resolve(ctx, reference.ResolutionRequest{
        - 			CurrentValue: convert.FromPtrValue(mg.Spec.ForProvider.CustomConfiguration),
        + 			CurrentValue: mg.Spec.ForProvider.CustomConfiguration,
          			Extract:      Configuration(),
          			Reference:    mg.Spec.ForProvider.CustomConfigurationRef,
          	... // 7 identical lines
          			return errors.Wrap(err, "mg.Spec.ForProvider.CustomConfiguration")
          		}
        - 		mg.Spec.ForProvider.CustomConfiguration = convert.ToPtrValue(rsp.ResolvedValue)
        + 		mg.Spec.ForProvider.CustomConfiguration = rsp.ResolvedValue
          		mg.Spec.ForProvider.CustomConfigurationRef = rsp.ResolvedReference

I fixed those errors, but maybe someone can take a closer look at that field.

Note: There is another solution to use convert path for both IsPointer and IsFloatPointer, but I saw that convert.FromPtrValue in convert.go is deprecated in favor of ptr.Deref.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant