gitrepo.go 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package models
  2. import (
  3. "gorm.io/gorm"
  4. )
  5. // GitRepo is an integration that can connect to a remote git repo via an auth
  6. // mechanism (currently only oauth)
  7. type GitRepo struct {
  8. gorm.Model
  9. // The project that this integration belongs to
  10. ProjectID uint `json:"project_id"`
  11. // The username/organization that this repo integration is linked to
  12. RepoEntity string `json:"repo_entity"`
  13. // The various auth mechanisms available to the integration
  14. OAuthIntegrationID uint
  15. }
  16. // GitRepoExternal is a repository to be shared over REST
  17. type GitRepoExternal struct {
  18. ID uint `json:"id"`
  19. // The project that this integration belongs to
  20. ProjectID uint `json:"project_id"`
  21. // The username/organization that this repo integration is linked to
  22. RepoEntity string `json:"repo_entity"`
  23. }
  24. // Externalize generates an external Repo to be shared over REST
  25. func (r *GitRepo) Externalize() *GitRepoExternal {
  26. return &GitRepoExternal{
  27. ID: r.Model.ID,
  28. ProjectID: r.ProjectID,
  29. RepoEntity: r.RepoEntity,
  30. }
  31. }