git_action.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. ReleaseID uint `json:"release_id" form:"required"`
  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. }
  17. // ToGitActionConfig converts the form to a gorm git action config model
  18. func (ca *CreateGitAction) ToGitActionConfig(version string) (*models.GitActionConfig, error) {
  19. return &models.GitActionConfig{
  20. ReleaseID: ca.ReleaseID,
  21. GitRepo: ca.GitRepo,
  22. GitBranch: ca.GitBranch,
  23. ImageRepoURI: ca.ImageRepoURI,
  24. DockerfilePath: ca.DockerfilePath,
  25. FolderPath: ca.FolderPath,
  26. GithubInstallationID: ca.GitRepoID,
  27. IsInstallation: true,
  28. Version: version,
  29. }, nil
  30. }
  31. type CreateGitActionOptional struct {
  32. GitRepo string `json:"git_repo"`
  33. GitBranch string `json:"git_branch"`
  34. ImageRepoURI string `json:"image_repo_uri"`
  35. DockerfilePath string `json:"dockerfile_path"`
  36. FolderPath string `json:"folder_path"`
  37. GitRepoID uint `json:"git_repo_id"`
  38. BuildEnv map[string]string `json:"env"`
  39. RegistryID uint `json:"registry_id"`
  40. }