gitrepo.go 1.2 KB

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