crossplane / crossplane-tools

Experimental code generators for Crossplane controllers.
https://crossplane.io
Apache License 2.0
34 stars 26 forks source link

Cannot generate referencers when a function call expression involves an argument with dots #42

Closed ulucinar closed 2 years ago

ulucinar commented 2 years ago

What happened?

Referencer configuration involving a function call expression with an argument with dots fails with the following message:

angryjet: error: cannot write reference resolvers for package github.com/upbound/official-providers/provider-azure/apis/cache/v1beta1: cannot write reference resolver methods: cannot render Go file: Error 15:41: invalid import path: "github.com/upbound/upjet/pkg/resource.ExtractParamPath(\"spec.forProvider" (and 10 more errors) while formatting source:
...

How can we reproduce it?

Configure a referencer as follows:

    // +crossplane:generate:reference:type=github.com/upbound/official-providers/provider-azure/apis/cache/v1beta1.RedisCache
    // +crossplane:generate:reference:extractor=github.com/upbound/upjet/pkg/resource.ExtractParamPath("spec.forProvider.alias")
    // +kubebuilder:validation:Optional
    ResourceGroupName *string `json:"resourceGroupName,omitempty" tf:"resource_group_name,omitempty"`

, and run:

go run -tags generate github.com/crossplane/crossplane-tools/cmd/angryjet generate-methodsets --header-file=../hack/boilerplate.go.txt ./...

What environment did it happen in?

crossplane-tools commit: 1f43fc12793e