Closed thibaultbustarret-ovhcloud closed 4 months ago
Can you include enforce_unique
in a test?
Given that it is a bool, it is very much possible that it can be set to true
while setting it to false
does not work, so test for that as well please.
Allowing it to be unset would need a tiny change in fbreckle/go-netbox, which I can do if needed.
Oops i forgot to test it and it was indeed worth adding a test, as it revealed a bug.
Whenever I try to create a Vrf with enforce_unique
set to false, the Vrf create in Netbox have a enforce_unique value of true, so I tried to create a simple Vrf with go-netbox, not depending on anything else :
func main() {
token := "example-token"
netboxHost := "localhost:8000"
transport := httptransport.New(netboxHost, client.DefaultBasePath, []string{"http"})
transport.DefaultAuthentication = httptransport.APIKeyAuth("Authorization", "header", "Token "+token)
c := client.New(transport, nil)
name := "test-vrf"
req := ipam.NewIpamVrfsCreateParams().WithData(&models.WritableVRF{
Name: &name,
EnforceUnique: false, // <- set to false here
ExportTargets: []int64{},
ImportTargets: []int64{},
Tags: []*models.NestedTag{},
})
res, err := c.Ipam.IpamVrfsCreate(req, nil)
if err != nil {
log.Fatalf("Cannot create site: %v", err)
}
log.Infof("res2: %v", res)
}
And the Vrf created gets a enforce_unique
value of true in Netbox, so the problem must be coming from go-netbox.
Any ideas on how to solve that?
As i don't need enforce_unique to be set to something else than true, I just removed it from this PR
Nah, you can leave it in, I will do the required change later this week, I'm just really busy atm.
Actually, I might just push the required changes to this branch.
Perfect then, i added them back
Add 'rd' and 'enforce_unique' fields to the vrf resource.