diff --git a/internal/types/resource/resource.go b/internal/types/resource/resource.go index a21d1cdcce..14106c3bcb 100644 --- a/internal/types/resource/resource.go +++ b/internal/types/resource/resource.go @@ -3,7 +3,10 @@ package resource -import "encoding/json" +import ( + "encoding/json" + "strings" +) // Type defines the types of resources in the system type Type uint @@ -81,6 +84,16 @@ func (r Type) PluralString() string { } } +func FromPlural(s string) (Type, bool) { + switch s { + case "credential-libraries": + return CredentialLibrary, true + default: + t, ok := Map[strings.TrimSuffix(s, "s")] + return t, ok + } +} + var Map = map[string]Type{ Unknown.String(): Unknown, All.String(): All,