infra.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package forms
  2. import (
  3. "github.com/porter-dev/porter/internal/models"
  4. )
  5. // CreateECRInfra represents the accepted values for creating an
  6. // ECR infra via the provisioning container
  7. type CreateECRInfra struct {
  8. ECRName string `json:"ecr_name" form:"required"`
  9. ProjectID uint `json:"project_id" form:"required"`
  10. AWSIntegrationID uint `json:"aws_integration_id" form:"required"`
  11. }
  12. // ToAWSInfra converts the form to a gorm aws infra model
  13. func (ce *CreateECRInfra) ToAWSInfra() (*models.AWSInfra, error) {
  14. return &models.AWSInfra{
  15. Kind: models.AWSInfraECR,
  16. ProjectID: ce.ProjectID,
  17. Status: models.StatusCreating,
  18. AWSIntegrationID: ce.AWSIntegrationID,
  19. }, nil
  20. }
  21. // CreateEKSInfra represents the accepted values for creating an
  22. // EKS infra via the provisioning container
  23. type CreateEKSInfra struct {
  24. EKSName string `json:"eks_name" form:"required"`
  25. ProjectID uint `json:"project_id" form:"required"`
  26. AWSIntegrationID uint `json:"aws_integration_id" form:"required"`
  27. }
  28. // ToAWSInfra converts the form to a gorm aws infra model
  29. func (ce *CreateEKSInfra) ToAWSInfra() (*models.AWSInfra, error) {
  30. return &models.AWSInfra{
  31. Kind: models.AWSInfraEKS,
  32. ProjectID: ce.ProjectID,
  33. Status: models.StatusCreating,
  34. AWSIntegrationID: ce.AWSIntegrationID,
  35. }, nil
  36. }