mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 14:32:22 +08:00
30 lines
1014 B
Go
30 lines
1014 B
Go
package validation
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/apimachinery/errutil"
|
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
|
)
|
|
|
|
var (
|
|
ErrProvenanceChangeNotAllowed = errutil.Forbidden("alerting.notifications.invalidProvenance").MustTemplate(
|
|
"Resource with provenance status '{{ .Public.SourceProvenance }}' cannot be managed via API that handles resources with provenance status '{{ .Public.TargetProvenance }}'",
|
|
errutil.WithPublic("Resource with provenance status '{{ .Public.SourceProvenance }}' cannot be managed via API that handles resources with provenance status '{{ .Public.TargetProvenance }}'. You must use appropriate API to manage this resource"),
|
|
)
|
|
)
|
|
|
|
func MakeErrProvenanceChangeNotAllowed(from, to models.Provenance) error {
|
|
if to == "" {
|
|
to = "none"
|
|
}
|
|
if from == "" {
|
|
from = "none"
|
|
}
|
|
data := errutil.TemplateData{
|
|
Public: map[string]interface{}{
|
|
"TargetProvenance": to,
|
|
"SourceProvenance": from,
|
|
},
|
|
}
|
|
return ErrProvenanceChangeNotAllowed.Build(data)
|
|
}
|