hashicorp / hashicorp/go-bexpr

Selector comparison not working

Open
#72 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
123
Forks
17
Avg merge
7h 36m
Merged PRs (30d)
3

Description

Hi,

Using two selectors in comparison expression doesn't seem to work.

This works:

```
"value.nomad == test and value.consul == test",
```

This doesn't:

```
"value.nomad == value.consul",
```

The following code shows the problem:

```
package main

import (
"fmt"
"os"

"github.com/hashicorp/go-bexpr"
"github.com/hashicorp/go-bexpr/grammar"
)

type Example struct {
Nomad string `bexpr:"nomad"`
Consul string `bexpr:"consul"`
}

func main() {
value := map[string]Example{
"value": {Nomad: "prueba", Consul: "prueba"},
}

expressions := []string{
"value.nomad == prueba and value.consul == prueba",
"value.nomad == value.consul",
}

for _, expression := range expressions {
eval, err := bexpr.CreateEvaluator(expression)

if err != nil {
fmt.Printf("Failed to create evaluator for expression %q: %v\n", expression, err)
continue
}

result, err := eval.Evaluate(value)
if err != nil {
fmt.Printf("Failed to run evaluation of expression %q: %v\n", expression, err)
continue
}

fmt.Printf("Result of expression %q evaluation: %t\n", expression, result)
}
}
```

I guess this is not implemented. Is there any way I can get this working? Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.