Skip to content

Commit

Permalink
[#4395] Bug/Gerrit Instances
Browse files Browse the repository at this point in the history
- Resolved fetching repo list for https://mockapi.gerrit.dev.itx.linuxfoundation.org instance

Signed-off-by: Harold Wanyama <[email protected]>
  • Loading branch information
nickmango committed Aug 1, 2024
1 parent 9bde61e commit b0133b1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cla-backend-go/gerrits/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,20 @@ func listGerritRepos(ctx context.Context, gerritHost string) (map[string]GerritR
}
client := resty.New()

base := "https://" + gerritHost

gerritAPIPath, gerritAPIPathErr := getGerritAPIPath(ctx, gerritHost)
if gerritAPIPathErr != nil {
return nil, gerritAPIPathErr
}

if gerritAPIPath != "" {
base = fmt.Sprintf("https://%s/%s", gerritHost, gerritAPIPath)
}

resp, err := client.R().
EnableTrace().
Get(fmt.Sprintf("https://%s/%s/projects/?d&pp=0", gerritHost, gerritAPIPath))
Get(fmt.Sprintf("%s/projects/?d&pp=0", base))
if err != nil {
log.WithFields(f).Warnf("problem querying gerrit host: %s, error: %+v", gerritHost, err)
return nil, err
Expand Down Expand Up @@ -302,14 +308,20 @@ func getGerritConfig(ctx context.Context, gerritHost string) (*ServerInfo, error
}
client := resty.New()

base := "https://" + gerritHost

gerritAPIPath, gerritAPIPathErr := getGerritAPIPath(ctx, gerritHost)
if gerritAPIPathErr != nil {
return nil, gerritAPIPathErr
}

if gerritAPIPath != "" {
base = fmt.Sprintf("https://%s/%s", gerritHost, gerritAPIPath)
}

resp, err := client.R().
EnableTrace().
Get(fmt.Sprintf("https://%s/%s/config/server/info", gerritHost, gerritAPIPath))
Get(fmt.Sprintf("%s/config/server/info", base))
if err != nil {
log.WithFields(f).Warnf("problem querying gerrit config, error: %+v", err)
return nil, err
Expand Down Expand Up @@ -343,6 +355,8 @@ func getGerritAPIPath(ctx context.Context, gerritHost string) (string, error) {
switch gerritHost {
case "gerrit.linuxfoundation.org":
return "infra", nil
case "mockapi.gerrit.dev.itx.linuxfoundation.org":
return "", nil
case "gerrit.onap.org":
return "r", nil
case "gerrit.o-ran-sc.org":
Expand Down

0 comments on commit b0133b1

Please sign in to comment.