Files
zeekay b36a8788a5 feat: rebrand SigNoz → Hanzo O11y
Full rebrand of the SigNoz observability platform:
- Go module: github.com/SigNoz/signoz → github.com/hanzoai/o11y
- Frontend: @signozhq/* → @hanzo/o11y-*, posthog-js → @hanzo/insights
- Docker: signoz/* → ghcr.io/hanzoai/o11y*
- ClickHouse → Hanzo Datastore (hanzoai/datastore)
- Env vars: SIGNOZ_* → HANZO_*
- DB tables: signoz_* → o11y_*
- All branding, URLs, docs updated
- 2172 files changed
2026-03-12 02:10:29 -07:00

53 lines
940 B
Go

package types
import (
"encoding/json"
"github.com/hanzoai/o11y/pkg/errors"
)
// Do not take inspiration from this. This is a hack to avoid using valuer.String and use upper case strings.
type Role string
const (
RoleAdmin Role = "ADMIN"
RoleEditor Role = "EDITOR"
RoleViewer Role = "VIEWER"
)
func NewRole(role string) (Role, error) {
switch role {
case "ADMIN":
return RoleAdmin, nil
case "EDITOR":
return RoleEditor, nil
case "VIEWER":
return RoleViewer, nil
}
return "", errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput, "invalid role: %s", role)
}
func (r Role) String() string {
return string(r)
}
func (r *Role) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return err
}
role, err := NewRole(s)
if err != nil {
return err
}
*r = role
return nil
}
func (r Role) MarshalJSON() ([]byte, error) {
return json.Marshal(r.String())
}