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

Multi TAG filtering does not work #222

Open
lgogolin opened this issue Aug 31, 2023 · 1 comment
Open

Multi TAG filtering does not work #222

lgogolin opened this issue Aug 31, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@lgogolin
Copy link

Summary

Filtering by multiple TAGs does not work

Version

Netbox version

3.4.6

Terraform version

1.5.6

Provider version

7.0.1

Issue details

Affected Data(s) / Resource(s)

  • data netbox_json_ipam_prefixes_list

Terraform Configuration Files

locals {
  cluster_name = "eu-pl-1a"
}

data "netbox_json_ipam_prefixes_list" "k8s_pod_cidr" {
  filter {
    name  = "tag"
    value = "kubernetes-pod-cidr"
  }

  filter {
    name  = "tag"
    value = "k8s_${local.cluster_name}"
  }
}

Terraform Output

+ k8s_pod_cidr = {
      + filter = [
          + {
              + name  = "tag"
              + value = "k8s_eu-pl-1a"
            },
          + {
              + name  = "tag"
              + value = "kubernetes-pod-cidr"
            },
        ]
      + id     = "NetboxJSONIpamPrefixesList"
      + json   = jsonencode(
            [
              + {
                  + _depth        = 1
                  + created       = "2022-12-31T00:19:30.358Z"
                  + custom_fields = {}
                  + description   = "lab-1a-k8s-pod"
                  + display       = "172.21.1.0/25"
                  + family        = {
                      + label = "IPv4"
                      + value = 4
                    }
                  + id            = 17
                  + is_pool       = true
                  + last_updated  = "2023-08-31T17:37:22.021Z"
                  + prefix        = "172.21.1.0/25"
                  + site          = {
                      + display = "example"
                      + id      = 1
                      + name    = "example"
                      + slug    = "example"
                      + url     = "https://netbox.inf.example/api/dcim/sites/1/"
                    }
                  + status        = {
                      + label = "Active"
                      + value = "active"
                    }
                  + tags          = [
                      + {
                          + color   = "03a9f4"
                          + display = "k8s_eu-pl-1a"
                          + id      = 8
                          + name    = "k8s_eu-pl-1a"
                          + slug    = "k8s_eu-pl-1a"
                          + url     = "https://netbox.inf.example/api/extras/tags/8/"
                        },
                      + {
                          + color   = "ffeb3b"
                          + display = "kubernetes-pod-cidr"
                          + id      = 10
                          + name    = "kubernetes-pod-cidr"
                          + slug    = "kubernetes-pod-cidr"
                          + url     = "https://netbox.inf.example/api/extras/tags/10/"
                        },
                    ]
                  + url           = "https://netbox.inf.example/api/ipam/prefixes/17/"
                },
              + {
                  + _depth        = 1
                  + created       = "2022-12-31T00:19:54.416Z"
                  + custom_fields = {}
                  + description   = "lab-1a-k8s-svc"
                  + display       = "172.21.1.128/25"
                  + family        = {
                      + label = "IPv4"
                      + value = 4
                    }
                  + id            = 18
                  + is_pool       = true
                  + last_updated  = "2023-08-31T17:37:29.143Z"
                  + prefix        = "172.21.1.128/25"
                  + site          = {
                      + display = "example"
                      + id      = 1
                      + name    = "example"
                      + slug    = "example"
                      + url     = "https://netbox.inf.example/api/dcim/sites/1/"
                    }
                  + status        = {
                      + label = "Active"
                      + value = "active"
                    }
                  + tags          = [
                      + {
                          + color   = "03a9f4"
                          + display = "k8s_eu-pl-1a"
                          + id      = 8
                          + name    = "k8s_eu-pl-1a"
                          + slug    = "k8s_eu-pl-1a"
                          + url     = "https://netbox.inf.example/api/extras/tags/8/"
                        },
                      + {
                          + color   = "4caf50"
                          + display = "kubernetes-svc-cidr"
                          + id      = 11
                          + name    = "kubernetes-svc-cidr"
                          + slug    = "kubernetes-svc-cidr"
                          + url     = "https://netbox.inf.example/api/extras/tags/11/"
                        },
                    ]
                  + url           = "https://netbox.inf.example/api/ipam/prefixes/18/"
                },
            ]
        )
      + limit  = 0
    }

Behaviors

Actual Behavior

Seems like last value for tag filter is picked.
API call to netbox look like this:
GET /api/ipam/prefixes/?limit=0&tag=k8s_eu-pl-1a HTTP/1.1" 200 1901 "-" "Go-http-client/2.0"

Expected Behavior

TAG filters should be combined so that API call would look like this:
GET /api/ipam/prefixes/?limit=0&tag=k8s_eu-pl-1a&tag=kubernetes-pod-cidr HTTP/1.1" 200 1901 "-" "Go-http-client/2.0"

Steps to Reproduce

  1. Define multiple filters with name = tag
@lgogolin lgogolin added the bug Something isn't working label Aug 31, 2023
@smutel
Copy link
Owner

smutel commented Sep 20, 2023

Hello, I dig a little bit and it seems that it's not possible :

.

I will continue to investigate ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants