registry.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. // The AWS integration that was used to create or connect the registry
  19. AWSIntegrationID uint `json:"aws_integration_id,omitempty"`
  20. // The GCP integration that was used to create or connect the registry
  21. GCPIntegrationID uint `json:"gcp_integration_id,omitempty"`
  22. // The DO integration that was used to create or connect the registry:
  23. // this points to an OAuthIntegrationID
  24. DOIntegrationID uint `json:"do_integration_id,omitempty"`
  25. // The basic integration that was used to connect the registry:
  26. BasicIntegrationID uint `json:"basic_integration_id,omitempty"`
  27. }
  28. // Repository is a collection of images
  29. type RegistryRepository struct {
  30. // Name of the repository
  31. Name string `json:"name"`
  32. // When the repository was created
  33. CreatedAt time.Time `json:"created_at,omitempty"`
  34. // The URI of the repository
  35. URI string `json:"uri"`
  36. }
  37. // Image is a Docker image type
  38. type Image struct {
  39. // The sha256 digest of the image manifest.
  40. Digest string `json:"digest"`
  41. // The tag used for the image.
  42. Tag string `json:"tag"`
  43. // The image manifest associated with the image.
  44. Manifest string `json:"manifest"`
  45. // The name of the repository associated with the image.
  46. RepositoryName string `json:"repository_name"`
  47. // When the image was pushed
  48. PushedAt *time.Time `json:"pushed_at"`
  49. }
  50. type RegistryService string
  51. const (
  52. GCR RegistryService = "gcr"
  53. ECR RegistryService = "ecr"
  54. DOCR RegistryService = "docr"
  55. DockerHub RegistryService = "dockerhub"
  56. )
  57. type RegistryListResponse []Registry
  58. type CreateRegistryRequest struct {
  59. URL string `json:"url"`
  60. Name string `json:"name" form:"required"`
  61. GCPIntegrationID uint `json:"gcp_integration_id"`
  62. AWSIntegrationID uint `json:"aws_integration_id"`
  63. DOIntegrationID uint `json:"do_integration_id"`
  64. BasicIntegrationID uint `json:"basic_integration_id"`
  65. }
  66. type CreateRegistryRepositoryRequest struct {
  67. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  68. }
  69. // UpdateRegistryRequest represents the accepted values for updating a
  70. // registry (only name for now)
  71. type UpdateRegistryRequest struct {
  72. Name string `json:"name" form:"required"`
  73. }
  74. type GetRegistryTokenResponse struct {
  75. Token string `json:"token"`
  76. ExpiresAt *time.Time `json:"expires_at"`
  77. }
  78. type GetRegistryGCRTokenRequest struct {
  79. ServerURL string `schema:"server_url"`
  80. }
  81. type GetRegistryECRTokenRequest struct {
  82. Region string `schema:"region"`
  83. }
  84. type GetRegistryDOCRTokenRequest struct {
  85. ServerURL string `schema:"server_url"`
  86. }
  87. type ListRegistryRepositoryResponse []*RegistryRepository
  88. type ListImageResponse []*Image