mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-04 11:25:52 +08:00

* fix: support multitenancy in dashboards * fix: support multitenancy in saved views * fix: move migrations to provider file * fix: remove getUserFromClaims and use new errors * fix: remove getUserFromClaims and use new errors * fix: use new errors in dashboards.go * Update ee/query-service/app/api/dashboard.go Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: minor changes --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
45 lines
847 B
Go
45 lines
847 B
Go
package errors
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
)
|
|
|
|
var (
|
|
CodeInvalidInput code = code{"invalid_input"}
|
|
CodeInternal = code{"internal"}
|
|
CodeUnsupported = code{"unsupported"}
|
|
CodeNotFound = code{"not_found"}
|
|
CodeMethodNotAllowed = code{"method_not_allowed"}
|
|
CodeAlreadyExists = code{"already_exists"}
|
|
CodeUnauthenticated = code{"unauthenticated"}
|
|
CodeForbidden = code{"forbidden"}
|
|
)
|
|
|
|
var (
|
|
codeRegex = regexp.MustCompile(`^[a-z_]+$`)
|
|
)
|
|
|
|
type code struct{ s string }
|
|
|
|
func NewCode(s string) (code, error) {
|
|
if !codeRegex.MatchString(s) {
|
|
return code{}, fmt.Errorf("invalid code: %v", s)
|
|
}
|
|
|
|
return code{s: s}, nil
|
|
}
|
|
|
|
func MustNewCode(s string) code {
|
|
code, err := NewCode(s)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return code
|
|
}
|
|
|
|
func (c code) String() string {
|
|
return c.s
|
|
}
|