git_action.go 1.5 KB

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