2
0

gitrepo.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 path to the dockerfile in the git repo
  34. DockerfilePath string `json:"dockerfile_path"`
  35. // The build context
  36. FolderPath string `json:"folder_path"`
  37. // Determines on how authentication is performed on this action
  38. IsInstallation bool `json:"is_installation"`
  39. Version string `json:"version" gorm:"default:v0.0.1"`
  40. }
  41. // ToGitActionConfigType generates an external GitActionConfig to be shared over REST
  42. func (r *GitActionConfig) ToGitActionConfigType() *types.GitActionConfig {
  43. return &types.GitActionConfig{
  44. GitRepo: r.GitRepo,
  45. GitBranch: r.GitBranch,
  46. ImageRepoURI: r.ImageRepoURI,
  47. GitRepoID: r.GithubInstallationID,
  48. DockerfilePath: r.DockerfilePath,
  49. FolderPath: r.FolderPath,
  50. }
  51. }