Download this file
| 1 | package provider |
| 2 | |
| 3 | import "slices" |
| 4 | |
| 5 | // ValidateSpecialistTools intersects a specialist's request with independently |
| 6 | // supplied team, project and certified tool sets. Text is never a command. |
| 7 | func ValidateSpecialistTools(requested, team, project, certified []string) error { |
| 8 | catalog := []string{"submit_reproduction", "submit_acceptance", "submit_answer", "submit_candidate", "submit_review", "submit_render", "ask_person"} |
| 9 | seen := []string{} |
| 10 | for _, tool := range requested { |
| 11 | if !slices.Contains(catalog, tool) || slices.Contains(seen, tool) || !slices.Contains(team, tool) || !slices.Contains(project, tool) || !slices.Contains(certified, tool) { |
| 12 | return ErrPolicy |
| 13 | } |
| 14 | seen = append(seen, tool) |
| 15 | } |
| 16 | return nil |
| 17 | } |
| 18 | |