mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-09 09:26:54 +00:00
* Format error messages correctly Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de> * No punctuation at the end or errors Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de> * Replace loop with simple if Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de> * Fix more errors Signed-off-by: Marcel Mueller <marcel.mueller1@rwth-aachen.de>
30 lines
790 B
Go
30 lines
790 B
Go
package admissionreviewduration
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/kyverno/kyverno/pkg/metrics"
|
|
)
|
|
|
|
func ParsePromMetrics(pm metrics.PromMetrics) PromMetrics {
|
|
return PromMetrics(pm)
|
|
}
|
|
|
|
func ParsePromConfig(pc metrics.PromConfig) PromConfig {
|
|
return PromConfig(pc)
|
|
}
|
|
|
|
func ParseResourceRequestOperation(requestOperationStr string) (metrics.ResourceRequestOperation, error) {
|
|
switch requestOperationStr {
|
|
case "CREATE":
|
|
return metrics.ResourceCreated, nil
|
|
case "UPDATE":
|
|
return metrics.ResourceUpdated, nil
|
|
case "DELETE":
|
|
return metrics.ResourceDeleted, nil
|
|
case "CONNECT":
|
|
return metrics.ResourceConnected, nil
|
|
default:
|
|
return "", fmt.Errorf("unknown request operation made by resource: %s. Allowed requests: 'CREATE', 'UPDATE', 'DELETE', 'CONNECT'", requestOperationStr)
|
|
}
|
|
}
|