mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-04 22:13:36 +00:00
push human readable milestone type
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
|
||||
package milestone
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Type int
|
||||
|
||||
const (
|
||||
@@ -24,3 +29,31 @@ func AllTypes() []Type {
|
||||
}
|
||||
return types
|
||||
}
|
||||
|
||||
func (t *Type) MarshalJSON() ([]byte, error) {
|
||||
return []byte(fmt.Sprintf(`"%s"`, t.String())), nil
|
||||
}
|
||||
|
||||
func (t *Type) UnmarshalJSON(data []byte) error {
|
||||
*t = typeFromString(strings.Trim(string(data), `"`))
|
||||
return nil
|
||||
}
|
||||
|
||||
func typeFromString(t string) Type {
|
||||
switch t {
|
||||
case InstanceCreated.String():
|
||||
return InstanceCreated
|
||||
case AuthenticationSucceededOnInstance.String():
|
||||
return AuthenticationSucceededOnInstance
|
||||
case ProjectCreated.String():
|
||||
return ProjectCreated
|
||||
case ApplicationCreated.String():
|
||||
return ApplicationCreated
|
||||
case AuthenticationSucceededOnApplication.String():
|
||||
return AuthenticationSucceededOnApplication
|
||||
case InstanceDeleted.String():
|
||||
return InstanceDeleted
|
||||
default:
|
||||
return unknown
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user