plugin/nomad: Support service filtering (#7724)

Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
This commit is contained in:
Olli Janatuinen
2025-11-25 20:05:14 +01:00
committed by GitHub
parent 3362885b56
commit bdc03ed540
4 changed files with 25 additions and 10 deletions

View File

@@ -10,10 +10,11 @@ import (
func TestSetupNomad(t *testing.T) {
tests := []struct {
name string
config string
shouldErr bool
expectedTTL uint32
name string
config string
shouldErr bool
expectedFilter string
expectedTTL uint32
}{
{
name: "valid_config_default_ttl",
@@ -22,19 +23,22 @@ nomad service.nomad {
address http://127.0.0.1:4646
token test-token
}`,
shouldErr: false,
expectedTTL: uint32(defaultTTL),
shouldErr: false,
expectedFilter: "",
expectedTTL: uint32(defaultTTL),
},
{
name: "valid_config_custom_ttl",
name: "valid_config_custom_filter_and_ttl",
config: `
nomad service.nomad {
address http://127.0.0.1:4646
filter "Tags not contains candidate"
token test-token
ttl 60
}`,
shouldErr: false,
expectedTTL: 60,
shouldErr: false,
expectedFilter: "Tags not contains candidate",
expectedTTL: 60,
},
{
name: "invalid_ttl_negative",
@@ -85,6 +89,7 @@ nomad service.nomad {
ttl: uint32(defaultTTL),
clients: make([]*nomad.Client, 0),
current: -1,
filter: "",
}
err := parse(c, n)