NewObjState parses string into an ObjState.
(in string)
| 452 | |
| 453 | // NewObjState parses string into an ObjState. |
| 454 | func NewObjState(in string) (ObjState, error) { |
| 455 | in = strings.ToLower(in) |
| 456 | switch in { |
| 457 | case "", "ok": |
| 458 | return StateOK, nil |
| 459 | case "susp": |
| 460 | return StateSuspended, nil |
| 461 | case "del": |
| 462 | return StateDeleted, nil |
| 463 | case "undef": |
| 464 | return StateUndefined, nil |
| 465 | } |
| 466 | // This is the default. |
| 467 | return StateOK, errors.New("failed to parse object state") |
| 468 | } |
| 469 | |
| 470 | // MarshalJSON converts ObjState to a quoted string. |
| 471 | func (os ObjState) MarshalJSON() ([]byte, error) { |
no outgoing calls
no test coverage detected
searching dependent graphs…