(appId string)
| 58 | } |
| 59 | |
| 60 | func ValidateAppId(appId string) error { |
| 61 | appNS, appName, err := ParseAppId(appId) |
| 62 | if err != nil { |
| 63 | return err |
| 64 | } |
| 65 | if len(appNS) > MaxNamespaceLen { |
| 66 | return fmt.Errorf("namespace too long: max %d characters", MaxNamespaceLen) |
| 67 | } |
| 68 | if len(appName) > MaxAppNameLen { |
| 69 | return fmt.Errorf("app name too long: max %d characters", MaxAppNameLen) |
| 70 | } |
| 71 | if !namespaceRegex.MatchString(appNS) { |
| 72 | return fmt.Errorf("invalid namespace: must match pattern @?[a-z0-9-]+") |
| 73 | } |
| 74 | if !appNameRegex.MatchString(appName) { |
| 75 | return fmt.Errorf("invalid app name: must match pattern [a-zA-Z0-9_-]+") |
| 76 | } |
| 77 | return nil |
| 78 | } |
| 79 | |
| 80 | func GetAppDir(appId string) (string, error) { |
| 81 | if err := ValidateAppId(appId); err != nil { |
no test coverage detected