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

added parent_id to locations #508

Closed
wants to merge 1 commit into from

Conversation

vaneuk
Copy link

@vaneuk vaneuk commented Dec 4, 2023

Hey
I'm working on adding parent_id to locations and looking for an advise.

There is an issue with parent_id=null for data sources. It is treated as "0" and hence "parent_id" is not added to the API query and we are reading multiple locations instead of one. Failed test output:

 data_source_netbox_location_test.go:13: Step 2/2 error: Error running post-apply plan: exit status 1
        
        Error: expected one location, but got 2
        
          with data.netbox_location.by_name_and_parent,
          on terraform_plugin_test.tf line 24, in data "netbox_location" "by_name_and_parent":
          24: data "netbox_location" "by_name_and_parent" {
        
        
        Error: expected one location, but got 2
        
          with data.netbox_location.by_name_and_site_and_parent_id,
          on terraform_plugin_test.tf line 29, in data "netbox_location" "by_name_and_site_and_parent_id":
          29: data "netbox_location" "by_name_and_site_and_parent_id" {
        
        
        Error: expected one location, but got 2
        
          with data.netbox_location.by_slug,
          on terraform_plugin_test.tf line 39, in data "netbox_location" "by_slug":
          39: data "netbox_location" "by_slug" {

location name is unique only per parent. So we can have multiple locations beneath different parents.
parent_id=null means locations without parents (aka root locations).

@fbreckle
Copy link
Collaborator

fbreckle commented Dec 12, 2023

Just making sure I get this right:

You are saying that we need the option to search for parent_id = null, but the api client then drops that part in the actual query because of omitempty? In that case, this has to be changed in https://github.com/fbreckle/go-netbox . This happened a lot in other resources as well.

@fbreckle
Copy link
Collaborator

Superseded by #548

@fbreckle fbreckle closed this Feb 16, 2024
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