git_action.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package forms
  2. import (
  3. "github.com/porter-dev/porter/internal/models"
  4. )
  5. // CreateGitAction represents the accepted values for creating a
  6. // github action integration
  7. type CreateGitAction struct {
  8. Release *models.Release
  9. GitRepo string `json:"git_repo" form:"required"`
  10. GitBranch string `json:"git_branch"`
  11. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  12. DockerfilePath string `json:"dockerfile_path"`
  13. FolderPath string `json:"folder_path"`
  14. GitRepoID uint `json:"git_repo_id" form:"required"`
  15. RegistryID uint `json:"registry_id"`
  16. ShouldCreateWorkflow bool `json:"should_create_workflow"`
  17. ShouldGenerateOnly bool
  18. }
  19. // ToGitActionConfig converts the form to a gorm git action config model
  20. func (ca *CreateGitAction) ToGitActionConfig(version string) (*models.GitActionConfig, error) {
  21. return &models.GitActionConfig{
  22. ReleaseID: ca.Release.Model.ID,
  23. GitRepo: ca.GitRepo,
  24. GitBranch: ca.GitBranch,
  25. ImageRepoURI: ca.ImageRepoURI,
  26. DockerfilePath: ca.DockerfilePath,
  27. FolderPath: ca.FolderPath,
  28. GithubInstallationID: ca.GitRepoID,
  29. IsInstallation: true,
  30. Version: version,
  31. }, nil
  32. }
  33. type CreateGitActionOptional struct {
  34. GitRepo string `json:"git_repo"`
  35. GitBranch string `json:"branch"`
  36. ImageRepoURI string `json:"image_repo_uri"`
  37. DockerfilePath string `json:"dockerfile_path"`
  38. FolderPath string `json:"folder_path"`
  39. GitRepoID uint `json:"git_repo_id"`
  40. RegistryID uint `json:"registry_id"`
  41. ShouldCreateWorkflow bool `json:"should_create_workflow"`
  42. }