mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-05 17:27:51 +00:00
Fixing dependency in custom-provider
This commit is contained in:
parent
ed9eb31b3a
commit
8ef8c8a291
7 changed files with 27 additions and 22 deletions
|
|
@ -3,19 +3,19 @@ package provider
|
|||
import "errors"
|
||||
|
||||
var (
|
||||
// ErrorNewOperatorNotSupportedByPrometheus creates an error that represents the fact that we were requested to service a query that
|
||||
// ErrNewOperatorNotSupportedByPrometheus creates an error that represents the fact that we were requested to service a query that
|
||||
// Prometheus would be unable to support.
|
||||
ErrorNewOperatorNotSupportedByPrometheus = errors.New("operator not supported by prometheus")
|
||||
ErrNewOperatorNotSupportedByPrometheus = errors.New("operator not supported by prometheus")
|
||||
|
||||
// ErrorNewOperatorRequiresValues creates an error that represents the fact that we were requested to service a query
|
||||
// ErrNewOperatorRequiresValues creates an error that represents the fact that we were requested to service a query
|
||||
// that was malformed in its operator/value combination.
|
||||
ErrorNewOperatorRequiresValues = errors.New("operator requires values")
|
||||
ErrNewOperatorRequiresValues = errors.New("operator requires values")
|
||||
|
||||
// ErrorNewOperatorDoesNotSupportValues creates an error that represents the fact that we were requested to service a query
|
||||
// ErrNewOperatorDoesNotSupportValues creates an error that represents the fact that we were requested to service a query
|
||||
// that was malformed in its operator/value combination.
|
||||
ErrorNewOperatorDoesNotSupportValues = errors.New("operator does not support values")
|
||||
ErrNewOperatorDoesNotSupportValues = errors.New("operator does not support values")
|
||||
|
||||
// ErrorNewLabelNotSpecified creates an error that represents the fact that we were requested to service a query
|
||||
// ErrNewLabelNotSpecified creates an error that represents the fact that we were requested to service a query
|
||||
// that was malformed in its label specification.
|
||||
ErrorNewLabelNotSpecified = errors.New("label not specified")
|
||||
ErrNewLabelNotSpecified = errors.New("label not specified")
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ type ExternalSeriesRegistry interface {
|
|||
|
||||
// overridableSeriesRegistry is a basic SeriesRegistry
|
||||
type externalSeriesRegistry struct {
|
||||
// We lock when reading/writing metrics, and rawMetrics to prevent inconsistencies.
|
||||
mu sync.RWMutex
|
||||
|
||||
// metrics is the list of all known metrics, ready to return from the API
|
||||
|
|
|
|||
|
|
@ -92,11 +92,11 @@ func (n *queryBuilder) processQueryParts(queryParts []queryPart) ([]string, map[
|
|||
// We obviously can't generate label filters for these cases.
|
||||
fmt.Println("This is queryPart", qPart.labelName, qPart.operator, qPart.values)
|
||||
if qPart.labelName == "" {
|
||||
return nil, nil, ErrorNewLabelNotSpecified
|
||||
return nil, nil, ErrNewLabelNotSpecified
|
||||
}
|
||||
|
||||
if !n.operatorIsSupported(qPart.operator) {
|
||||
return nil, nil, ErrorNewOperatorNotSupportedByPrometheus
|
||||
return nil, nil, ErrNewOperatorNotSupportedByPrometheus
|
||||
}
|
||||
|
||||
matcher, err := n.selectMatcher(qPart.operator, qPart.values)
|
||||
|
|
@ -128,7 +128,7 @@ func (n *queryBuilder) selectMatcher(operator selection.Operator, values []strin
|
|||
case selection.DoesNotExist:
|
||||
return prom.LabelEq, nil
|
||||
case selection.Equals, selection.DoubleEquals, selection.NotEquals, selection.In, selection.NotIn:
|
||||
return nil, ErrorNewOperatorRequiresValues
|
||||
return nil, ErrNewOperatorRequiresValues
|
||||
}
|
||||
} else if numValues == 1 {
|
||||
switch operator {
|
||||
|
|
@ -168,7 +168,7 @@ func (n *queryBuilder) selectTargetValue(operator selection.Operator, values []s
|
|||
// whose value is NOT "".
|
||||
return "", nil
|
||||
case selection.Equals, selection.DoubleEquals, selection.NotEquals, selection.In, selection.NotIn:
|
||||
return "", ErrorNewOperatorRequiresValues
|
||||
return "", ErrNewOperatorRequiresValues
|
||||
}
|
||||
} else if numValues == 1 {
|
||||
switch operator {
|
||||
|
|
@ -194,7 +194,7 @@ func (n *queryBuilder) selectTargetValue(operator selection.Operator, values []s
|
|||
// for their label selector.
|
||||
return strings.Join(values, "|"), nil
|
||||
case selection.Exists, selection.DoesNotExist:
|
||||
return "", ErrorNewOperatorDoesNotSupportValues
|
||||
return "", ErrNewOperatorDoesNotSupportValues
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue