Use query filter on service list

Hello,

I’m trying to filter the list of service.

I want to only have the list of service I needs.

I think I do something wrong with the query go-bxpr but not sure what.

Here is my code, that don’t filter my list of services:

package main

import (
        "fmt"

        nomad "github.com/hashicorp/nomad/api"
//        "github.com/davecgh/go-spew/spew"
)

func main() {
        config := nomad.Config{
                Address:    "http://192.168.0.137:4646",
                Region:     "global",
        }

        client, _ := nomad.NewClient(&config)

        opts := &nomad.QueryOptions{
                AllowStale: false,
                Filter: "Services.ServiceName contains my-service",
        }

        stubs, _, _ := client.Services().List(opts)

        for _, stub := range stubs {
                for _, service := range stub.Services {
                        fmt.Print(service.ServiceName + "\n")
                }
        }
}

Thank you for your help

Hi @quentin.vallin, I think the /v1/services endpoint doesn’t actually support filtering yet, at least our docs don’t mention any supported parameters.

It does seem like that could be useful though (along with support for pagination) - feel free to open a feature request issue on GitHub.

Hi @seth.hoenig !

Thank you for your reply. I was confused because the nomad go api allow a query in the List call api package - github.com/hashicorp/nomad/api - Go Packages

Can we specify that Filter is not supported on Servoces.List() ?

Quentin.