Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

no warning or error is produced when creating a referencer for a missing field #141

Open
displague opened this issue Nov 13, 2021 · 2 comments
Assignees
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@displague
Copy link
Member

displague commented Nov 13, 2021

What happened?

While working on an Equinix Metal Terrajet provider, I created a metal_device project field reference, associated with the metal_project identifier.

// config/device/config.go
package device

import "github.com/crossplane-contrib/terrajet/pkg/config"

func Customize(p *config.Provider) {
        p.AddResourceConfigurator("metal_device", func(r *config.Resource) {
                r.Group = "device"
                r.ExternalName = config.IdentifierFromProvider
                r.References["project"] = config.Reference{
                        Type: "github.com/crossplane-contrib/provider-tf-equinixmetal/apis/project/v1alpha1.Project",
                }
        })
}

The problem is that project is not a valid field for metal_device. The field is project_id.

I received no error messages about this typo.
make generate succeeded.

When I eventually discovered the typo and set the field name in the map to project_id, an additional file (apis/device/v1alpha1/zz_generated.resolvers.go) was generated.

How can we reproduce it?

crossplane-contrib/provider-tf-equinix-metal@81a6d89

@displague displague added the bug Something isn't working label Nov 13, 2021
@muvaf
Copy link
Member

muvaf commented Jan 4, 2022

That's due to the look-up mechanism we have for this feature where for each field we check whether there is a referencer field, hence no error if nothing hits the given reference entry. One option could be to validate the whole configuration object before starting any operation.

@sergenyalcin sergenyalcin self-assigned this Apr 8, 2022
@stale
Copy link

stale bot commented Aug 13, 2022

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.

@stale stale bot added the wontfix This will not be worked on label Aug 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants