git_action.go 1.6 KB

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