gitrepo.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. }
  36. // GitActionConfig is a configuration for release's CI integration via
  37. // Github Actions
  38. type GitActionConfig struct {
  39. gorm.Model
  40. // The ID of the release that this is linked to
  41. ReleaseID uint `json:"release_id"`
  42. // The git repo in ${owner}/${repo} form
  43. GitRepo string `json:"git_repo"`
  44. // The complete image repository uri to pull from
  45. ImageRepoURI string `json:"image_repo_uri"`
  46. // The git integration id
  47. GitRepoID uint `json:"git_repo_id"`
  48. // The path to the dockerfile in the git repo
  49. DockerfilePath string `json:"dockerfile_path"`
  50. // The build context
  51. FolderPath string `json:"folder_path"`
  52. }
  53. // GitActionConfigExternal is an external GitActionConfig to be shared over REST
  54. type GitActionConfigExternal struct {
  55. // The git repo in ${owner}/${repo} form
  56. GitRepo string `json:"git_repo"`
  57. // The complete image repository uri to pull from
  58. ImageRepoURI string `json:"image_repo_uri"`
  59. // The git integration id
  60. GitRepoID uint `json:"git_repo_id"`
  61. // The path to the dockerfile in the git repo
  62. DockerfilePath string `json:"dockerfile_path" form:"required"`
  63. // The build context
  64. FolderPath string `json:"folder_path"`
  65. }
  66. // Externalize generates an external GitActionConfig to be shared over REST
  67. func (r *GitActionConfig) Externalize() *GitActionConfigExternal {
  68. return &GitActionConfigExternal{
  69. GitRepo: r.GitRepo,
  70. ImageRepoURI: r.ImageRepoURI,
  71. GitRepoID: r.GitRepoID,
  72. DockerfilePath: r.DockerfilePath,
  73. FolderPath: r.FolderPath,
  74. }
  75. }