From cf8a30efac4e90b521d73debc6ada6018e5a99ac Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Tue, 26 Mar 2024 07:58:04 +0100 Subject: [PATCH] mob-next: how to store port & schema --- models/repo/federated_repo.go | 2 ++ modules/context/repo.go | 9 ++++++--- modules/forgefed/federation_service.go | 8 ++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/models/repo/federated_repo.go b/models/repo/federated_repo.go index d2f25d2a17..fb2952d04b 100644 --- a/models/repo/federated_repo.go +++ b/models/repo/federated_repo.go @@ -13,6 +13,8 @@ type FederatedRepo struct { RepoID int64 `xorm:"NOT NULL"` ExternalID string `xorm:"TEXT UNIQUE(federation_repo_mapping) NOT NULL"` FederationHostID int64 `xorm:"UNIQUE(federation_repo_mapping) NOT NULL"` + Schema string + Port string } func NewFederatedRepo(repoID int64, externalID string, federationHostID int64) (FederatedRepo, error) { diff --git a/modules/context/repo.go b/modules/context/repo.go index ea612cc1af..deb7f3d92e 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -380,10 +380,13 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) { ctx.Data["HasAccess"] = true ctx.Data["Permission"] = &ctx.Repo.Permission - federatedRepo, err := repo_model.FindFederatedReposByRepoID(ctx, repo.ID) + federatedRepoList, err := repo_model.FindFederatedReposByRepoID(ctx, repo.ID) if err == nil { - // TODO: concat string to semicolon sperated list here - ctx.Data["FederatedRepos"] = federatedRepo + federatedRepoString := "" + for _, federatedRepo := range federatedRepoList { + + } + ctx.Data["FederatedRepos"] = federatedRepoString } else if err != repo_model.ErrMirrorNotExist { ctx.ServerError("FindFederatedRepoByRepoID", err) return diff --git a/modules/forgefed/federation_service.go b/modules/forgefed/federation_service.go index 99d48673d7..5e443a768e 100644 --- a/modules/forgefed/federation_service.go +++ b/modules/forgefed/federation_service.go @@ -234,3 +234,11 @@ func StoreFederatedRepoList(ctx context.Context, localRepoId int64, federatedRep return 0, "", nil } + +func FederatedRepoUrl(ctx context.Context, federatedRepo repo.FederatedRepo) (string, error) { + federationHost, err := forgefed.GetFederationHost(ctx, federatedRepo.FederationHostID) + if err != nil { + return "", err + } + return federationHost.HostFqdn +}