in api/groups.go [89:124]
func (f *RemoteGroupFetcher) FetchGroups() ([]string, error) {
resp, err := http.Get(f.GroupsListURL)
if err != nil {
return nil, errors.Wrap(err, "fetching SIG list")
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.New(
fmt.Sprintf(
"invalid status code when fetching SIG list: %d",
resp.StatusCode,
),
)
}
re := regexp.MustCompile(`- dir: (.*)$`)
var result []string
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
match := re.FindStringSubmatch(scanner.Text())
if len(match) > 0 {
result = append(result, match[1])
}
}
if err := scanner.Err(); err != nil {
return nil, errors.Wrap(err, "scanning SIG list")
}
sort.Strings(result)
return result, nil
}