mob-next: how to store port & schema

This commit is contained in:
Michael Jerger 2024-03-26 07:58:04 +01:00
parent 5b8173f660
commit cf8a30efac
3 changed files with 16 additions and 3 deletions

View file

@ -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) {

View file

@ -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

View file

@ -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
}