github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/pkg/consts/app_type.go (about) 1 package consts 2 3 // AppType is an enum to represent the type of application: webapp clientside 4 // or konnector serverside. 5 type AppType int 6 7 const ( 8 // WebappType is the clientside application type 9 WebappType AppType = iota + 1 10 // KonnectorType is the serverside application type 11 KonnectorType 12 ) 13 14 // String returns the human-readable doctype from the AppType 15 func (at AppType) String() string { 16 switch at { 17 case WebappType: 18 return "io.cozy.apps" 19 case KonnectorType: 20 return "io.cozy.konnectors" 21 default: 22 return "unknown" 23 } 24 } 25 26 // NewAppType creates a new AppType from a string 27 func NewAppType(doctype string) AppType { 28 switch doctype { 29 case "io.cozy.konnectors": 30 return KonnectorType 31 case "io.cozy.apps": 32 return WebappType 33 default: 34 return 0 35 } 36 }