crossplane / terrajet

Generate Crossplane Providers from any Terraform Provider
https://crossplane.io
Apache License 2.0
290 stars 38 forks source link

Add validation on the r.Kind field #221

Open remyleone opened 2 years ago

remyleone commented 2 years ago

What happened?

I've used a configurator like this:

    p.AddResourceConfigurator("scaleway_instance_ip", func(r *config.Resource) {
        // Identifier for this resource is assigned by the provider. In other
        // words it is not simply the name of the resource.
        r.ExternalName = config.IdentifierFromProvider
        r.ShortGroup = "instance"
        r.Kind = "ip"
    })

The problem is that it created issue in angryjet like this:

angryjet: error: error loading packages using pattern ./...: /Users/sieben/workspace/crossplane-scaleway-provider/apis/instance/v1alpha1/zz_ip_types.go:97:25: cannot use &(ip literal) (value of type *ip) as "k8s.io/apimachinery/pkg/runtime".Object value in argument to SchemeBuilder.Register: missing method DeepCopyObject
exit status 1
apis/generate.go:38: running "go": exit status 1
11:00:24 [FAIL]
make[1]: *** [go.generate] Error 1
make: *** [generate] Error 2

I've fixed it using IP instead of ip. Maybe it could be a good idea to add validation on the r.Kind field about the convention for kind (uppercased, lowercase, camelcase, ...)

How can we reproduce it?

muvaf commented 2 years ago

@remyleone The reason it fails is because the type has to be exported, hence start with uppercase in Go. But it's a great idea to have a validation since it's not clear that this is the problem. Maybe here after all configurators are run?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.