parseRolesArray parses a comma-separated string of quoted role names.
(rolesStr string)
| 53 | |
| 54 | // parseRolesArray parses a comma-separated string of quoted role names. |
| 55 | func parseRolesArray(rolesStr string) ([]string, error) { |
| 56 | var roles []string |
| 57 | for _, role := range strings.Split(rolesStr, ",") { |
| 58 | role = strings.TrimSpace(role) |
| 59 | role = strings.Trim(role, `"`) |
| 60 | if role != "" { |
| 61 | roles = append(roles, role) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | if len(roles) == 0 { |
| 66 | return nil, fmt.Errorf("no roles found in role array") |
| 67 | } |
| 68 | |
| 69 | return roles, nil |
| 70 | } |
| 71 | |
| 72 | // parseConstraint parses a constraint definition string. |
| 73 | func parseConstraint(key, value string) (*Constraint, error) { |
no outgoing calls
no test coverage detected
searching dependent graphs…