registry.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package types
  2. import "time"
  3. const (
  4. URLParamRegion URLParam = "region"
  5. )
  6. type Registry struct {
  7. ID uint `json:"id"`
  8. // The project that this integration belongs to
  9. ProjectID uint `json:"project_id"`
  10. // Name of the registry
  11. Name string `json:"name"`
  12. // URL of the registry
  13. URL string `json:"url"`
  14. // The integration service for this registry
  15. Service RegistryService `json:"service"`
  16. // The infra id, if registry was provisioned with Porter
  17. InfraID uint `json:"infra_id"`
  18. }
  19. // Repository is a collection of images
  20. type RegistryRepository struct {
  21. // Name of the repository
  22. Name string `json:"name"`
  23. // When the repository was created
  24. CreatedAt time.Time `json:"created_at,omitempty"`
  25. // The URI of the repository
  26. URI string `json:"uri"`
  27. }
  28. // Image is a Docker image type
  29. type Image struct {
  30. // The sha256 digest of the image manifest.
  31. Digest string `json:"digest"`
  32. // The tag used for the image.
  33. Tag string `json:"tag"`
  34. // The image manifest associated with the image.
  35. Manifest string `json:"manifest"`
  36. // The name of the repository associated with the image.
  37. RepositoryName string `json:"repository_name"`
  38. // When the image was pushed
  39. PushedAt *time.Time `json:"pushed_at"`
  40. }
  41. type RegistryService string
  42. const (
  43. GCR RegistryService = "gcr"
  44. ECR RegistryService = "ecr"
  45. DOCR RegistryService = "docr"
  46. DockerHub RegistryService = "dockerhub"
  47. )
  48. type RegistryListResponse []Registry
  49. type CreateRegistryRequest struct {
  50. URL string `json:"url"`
  51. Name string `json:"name" form:"required"`
  52. GCPIntegrationID uint `json:"gcp_integration_id"`
  53. AWSIntegrationID uint `json:"aws_integration_id"`
  54. DOIntegrationID uint `json:"do_integration_id"`
  55. BasicIntegrationID uint `json:"basic_integration_id"`
  56. }
  57. type CreateRegistryRepositoryRequest struct {
  58. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  59. }
  60. // UpdateRegistryRequest represents the accepted values for updating a
  61. // registry (only name for now)
  62. type UpdateRegistryRequest struct {
  63. Name string `json:"name" form:"required"`
  64. }
  65. type GetRegistryTokenResponse struct {
  66. Token string `json:"token"`
  67. ExpiresAt *time.Time `json:"expires_at"`
  68. }
  69. type GetRegistryGCRTokenRequest struct {
  70. ServerURL string `schema:"server_url"`
  71. }
  72. type GetRegistryECRTokenRequest struct {
  73. Region string `schema:"region"`
  74. }
  75. type GetRegistryDOCRTokenRequest struct {
  76. ServerURL string `schema:"server_url"`
  77. }
  78. type ListRegistryRepositoryResponse []*RegistryRepository
  79. type ListImageResponse []*Image