Skip to content

Commit

Permalink
renamed evaluate and reverted tool.go
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-jokic committed Jun 12, 2023
1 parent 029d2bd commit cbe0554
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions hack/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ limitations under the License.
package tools

import (
// gen-crd-api-reference-docs
_ "github.com/ahmetb/gen-crd-api-reference-docs"
// code-generator
_ "k8s.io/code-generator"

// gen-crd-api-reference-docs
_ "github.com/ahmetb/gen-crd-api-reference-docs"
)


4 changes: 2 additions & 2 deletions pkg/kwok/metrics/cel/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ type Evaluator struct {
program cel.Program
}

// EvaluateMetric evaluates a cel program and returns a metric value
func (e *Evaluator) EvaluateMetric(node *corev1.Node) (float64, error) {
// EvaluateFloat64 evaluates a cel program and returns a metric value and returns float64.
func (e *Evaluator) EvaluateFloat64(node *corev1.Node) (float64, error) {
refVal, _, err := e.program.Eval(map[string]any{
"node": node,
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/kwok/metrics/cel/evaluate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestNodeEvaluation(t *testing.T) {
t.Fatalf("failed to compile expression: %v", err)
}

actual, err := eval.EvaluateMetric(n)
actual, err := eval.EvaluateFloat64(n)
if err != nil {
t.Fatalf("evaluation failed: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/kwok/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (h *UpdateHandler) init() error {
return err
}

result, err := eval.EvaluateMetric(nodeInfo.Node)
result, err := eval.EvaluateFloat64(nodeInfo.Node)
if err != nil {
return fmt.Errorf("failed to evaluate metric %q: %w", m.Name, err)
}
Expand Down Expand Up @@ -195,7 +195,7 @@ func (h *UpdateHandler) init() error {
return err
}

result, err := eval.EvaluateMetric(nodeInfo.Node)
result, err := eval.EvaluateFloat64(nodeInfo.Node)
if err != nil {
return fmt.Errorf("failed to evaluate metric %q: %w", m.Name, err)
}
Expand Down Expand Up @@ -264,7 +264,7 @@ func (h *UpdateHandler) init() error {
if !ok {
return fmt.Errorf("failed to find program for metric %v", b.Le)
}
value, err := prog.EvaluateMetric(nodeInfo.Node)
value, err := prog.EvaluateFloat64(nodeInfo.Node)
if err != nil {
return fmt.Errorf("failed to evaluate metric with Le(%v): %w", b.Le, err)
}
Expand Down

0 comments on commit cbe0554

Please sign in to comment.