Skip to content
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

feat: add 'rd' and 'enforce_unique' fields to vrf #585

Merged
merged 7 commits into from
May 17, 2024

Conversation

thibaultbustarret-ovhcloud
Copy link
Contributor

Add 'rd' and 'enforce_unique' fields to the vrf resource.

@fbreckle
Copy link
Collaborator

fbreckle commented May 6, 2024

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.

@thibaultbustarret-ovhcloud
Copy link
Contributor Author

thibaultbustarret-ovhcloud commented May 7, 2024

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?

@thibaultbustarret-ovhcloud
Copy link
Contributor Author

thibaultbustarret-ovhcloud commented May 14, 2024

As i don't need enforce_unique to be set to something else than true, I just removed it from this PR

@fbreckle
Copy link
Collaborator

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.

@thibaultbustarret-ovhcloud
Copy link
Contributor Author

Perfect then, i added them back

@fbreckle fbreckle merged commit de4a84d into e-breuninger:master May 17, 2024
14 checks passed
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.

2 participants