gitrepo.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package models
  2. import (
  3. "github.com/porter-dev/porter/api/types"
  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. // GitActionConfig is a configuration for release's CI integration via
  18. // Github Actions
  19. type GitActionConfig struct {
  20. gorm.Model
  21. // The ID of the release that this is linked to
  22. ReleaseID uint `json:"release_id"`
  23. // The git repo in ${owner}/${repo} form
  24. GitRepo string `json:"git_repo"`
  25. // The git branch to use
  26. GitBranch string `json:"git_branch"`
  27. // The complete image repository uri to pull from
  28. ImageRepoURI string `json:"image_repo_uri"`
  29. // The git installation ID
  30. GithubInstallationID uint `json:"git_installation_id"`
  31. // The git repo ID (legacy field)
  32. GitRepoID uint `json:"git_repo_id"`
  33. // The gitlab integration ID
  34. GitlabIntegrationID uint `json:"gitlab_integration_id"`
  35. // The path to the dockerfile in the git repo
  36. DockerfilePath string `json:"dockerfile_path"`
  37. // The build context
  38. FolderPath string `json:"folder_path"`
  39. // Determines on how authentication is performed on this action
  40. IsInstallation bool `json:"is_installation"`
  41. Version string `json:"version" gorm:"default:v0.0.1"`
  42. }
  43. // ToGitActionConfigType generates an external GitActionConfig to be shared over REST
  44. func (r *GitActionConfig) ToGitActionConfigType() *types.GitActionConfig {
  45. return &types.GitActionConfig{
  46. GitRepo: r.GitRepo,
  47. GitBranch: r.GitBranch,
  48. ImageRepoURI: r.ImageRepoURI,
  49. GitRepoID: r.GitRepoID,
  50. GitlabIntegrationID: r.GitlabIntegrationID,
  51. DockerfilePath: r.DockerfilePath,
  52. FolderPath: r.FolderPath,
  53. }
  54. }