( ctx context.Context, registryDao store.RegistryRepository, repoKey string, parentID int64, upstream bool, )
| 145 | } |
| 146 | |
| 147 | func GetOrderedRepos( |
| 148 | ctx context.Context, |
| 149 | registryDao store.RegistryRepository, |
| 150 | repoKey string, |
| 151 | parentID int64, |
| 152 | upstream bool, |
| 153 | ) ([]registrytypes.Registry, error) { |
| 154 | var result []registrytypes.Registry |
| 155 | registry, err := registryDao.GetByParentIDAndName(ctx, parentID, repoKey) |
| 156 | if err != nil { |
| 157 | return result, errors.NotFound("registry %s not found", repoKey) |
| 158 | } |
| 159 | result = append(result, *registry) |
| 160 | if !upstream { |
| 161 | return result, nil |
| 162 | } |
| 163 | proxies := registry.UpstreamProxies |
| 164 | if len(proxies) > 0 { |
| 165 | upstreamRepos, err2 := registryDao.GetByIDIn(ctx, proxies) |
| 166 | if err2 != nil { |
| 167 | log.Ctx(ctx).Error().Msgf("Failed to get upstream proxies for %s: %v", repoKey, err2) |
| 168 | return result, err2 |
| 169 | } |
| 170 | repoMap := make(map[int64]registrytypes.Registry) |
| 171 | for _, repo := range *upstreamRepos { |
| 172 | repoMap[repo.ID] = repo |
| 173 | } |
| 174 | for _, proxyID := range proxies { |
| 175 | if repo, ok := repoMap[proxyID]; ok { |
| 176 | result = append(result, repo) |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | return result, nil |
| 181 | } |
| 182 | |
| 183 | func SearchPackagesProxyWrapper( |
| 184 | ctx context.Context, |
no test coverage detected
searching dependent graphs…