Download this file
| 1 | package forge |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/equipo/internal/runner/provider" |
| 5 | "sort" |
| 6 | ) |
| 7 | |
| 8 | // RepositoryNames reads only the dedicated forge file; no token enters the report. |
| 9 | func (f FileCredentials) RepositoryNames() ([]string, error) { |
| 10 | var file forgeCredentialFile |
| 11 | if err := readCredentialFile(f.Path, &file); err != nil { |
| 12 | return nil, err |
| 13 | } |
| 14 | return repositoryNames(file) |
| 15 | } |
| 16 | |
| 17 | func repositoryNames(file forgeCredentialFile) ([]string, error) { |
| 18 | if len(file.Repositories) > 256 { |
| 19 | return nil, provider.ErrPolicy |
| 20 | } |
| 21 | names := make([]string, 0, len(file.Repositories)) |
| 22 | for repo := range file.Repositories { |
| 23 | if !validRepository(repo) { |
| 24 | return nil, provider.ErrPolicy |
| 25 | } |
| 26 | names = append(names, repo) |
| 27 | } |
| 28 | sort.Strings(names) |
| 29 | return names, nil |
| 30 | } |
| 31 | |