registry.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. package types
  2. import "time"
  3. const (
  4. URLParamRegion URLParam = "region"
  5. )
  6. type Registry struct {
  7. // The ID of the registry
  8. // minimum: 1
  9. // example: 2
  10. ID uint `json:"id"`
  11. // The project that this integration belongs to
  12. // minimum: 1
  13. // example: 1
  14. ProjectID uint `json:"project_id"`
  15. // Name of the registry
  16. // example: my-ecr-reg
  17. Name string `json:"name"`
  18. // URL of the registry
  19. // example: 123456789.dkr.ecr.us-west-2.amazonaws.com
  20. URL string `json:"url"`
  21. // The integration service for this registry
  22. // enum: gcr,ecr,acr,docr,dockerhub
  23. // example: ecr
  24. Service string `json:"service"`
  25. // The infra id, if registry was provisioned with Porter
  26. // minimum: 1
  27. // example: 2
  28. InfraID uint `json:"infra_id"`
  29. // The AWS integration that was used to create or connect the registry
  30. // minimum: 1
  31. // example: 1
  32. AWSIntegrationID uint `json:"aws_integration_id,omitempty"`
  33. // The Azure integration that was used to create or connect the registry
  34. // minimum: 1
  35. // example: 0
  36. AzureIntegrationID uint `json:"azure_integration_id,omitempty"`
  37. // The GCP integration that was used to create or connect the registry
  38. // minimum: 1
  39. // example: 0
  40. GCPIntegrationID uint `json:"gcp_integration_id,omitempty"`
  41. // The DO integration that was used to create or connect the registry:
  42. // this points to an OAuthIntegrationID
  43. // minimum: 1
  44. // example: 0
  45. DOIntegrationID uint `json:"do_integration_id,omitempty"`
  46. // The basic integration that was used to connect the registry.
  47. // minimum: 1
  48. // example: 0
  49. BasicIntegrationID uint `json:"basic_integration_id,omitempty"`
  50. }
  51. // Repository is a collection of images
  52. type RegistryRepository struct {
  53. // Name of the repository
  54. Name string `json:"name"`
  55. // When the repository was created
  56. CreatedAt time.Time `json:"created_at,omitempty"`
  57. // The URI of the repository
  58. URI string `json:"uri"`
  59. }
  60. // Image is a Docker image type
  61. type Image struct {
  62. // The sha256 digest of the image manifest.
  63. Digest string `json:"digest"`
  64. // The tag used for the image.
  65. Tag string `json:"tag"`
  66. // The image manifest associated with the image.
  67. Manifest string `json:"manifest"`
  68. // The name of the repository associated with the image.
  69. RepositoryName string `json:"repository_name"`
  70. // When the image was pushed
  71. PushedAt *time.Time `json:"pushed_at"`
  72. }
  73. // Type of registry service
  74. type RegistryService string
  75. const (
  76. GCR RegistryService = "gcr"
  77. ECR RegistryService = "ecr"
  78. ACR RegistryService = "acr"
  79. DOCR RegistryService = "docr"
  80. DockerHub RegistryService = "dockerhub"
  81. )
  82. // swagger:model ListRegistriesResponse
  83. type RegistryListResponse []Registry
  84. // swagger:model
  85. type CreateRegistryRequest struct {
  86. // URL of the container registry
  87. // example: 123456789.dkr.ecr.us-west-2.amazonaws.com
  88. URL string `json:"url"`
  89. // Name of the container registry
  90. // required: true
  91. // example: my-ecr-reg
  92. Name string `json:"name" form:"required"`
  93. // The GCP integration ID to be used for this registry
  94. // minimum: 1
  95. // example: 0
  96. GCPIntegrationID uint `json:"gcp_integration_id"`
  97. // The AWS integration ID to be used for this registry
  98. // minimum: 1
  99. // example: 1
  100. AWSIntegrationID uint `json:"aws_integration_id"`
  101. // The DigitalOcean integration ID to be used for this registry
  102. // minimum: 1
  103. // example: 0
  104. DOIntegrationID uint `json:"do_integration_id"`
  105. // The Basic integration ID to be used for this registry
  106. // minimum: 1
  107. // example: 0
  108. BasicIntegrationID uint `json:"basic_integration_id"`
  109. // The Azure integration ID to be used for this registry
  110. // minimum: 1
  111. // example: 0
  112. AzureIntegrationID uint `json:"azure_integration_id"`
  113. // Additional Azure-specific fields
  114. // ACR resource group name (**Azure only**)
  115. ACRResourceGroupName string `json:"acr_resource_group_name"`
  116. // ACR name (**Azure only**)
  117. ACRName string `json:"acr_name"`
  118. }
  119. // swagger:model
  120. type CreateRegistryResponse Registry
  121. // swagger:model
  122. type GetRegistryResponse Registry
  123. // swagger:model
  124. type CreateRegistryRepositoryRequest struct {
  125. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  126. }
  127. // UpdateRegistryRequest represents the accepted values for updating a
  128. // registry (only name for now)
  129. type UpdateRegistryRequest struct {
  130. Name string `json:"name" form:"required"`
  131. }
  132. type GetRegistryTokenResponse struct {
  133. Token string `json:"token"`
  134. ExpiresAt *time.Time `json:"expires_at"`
  135. }
  136. type GetRegistryGCRTokenRequest struct {
  137. ServerURL string `schema:"server_url"`
  138. }
  139. type GetRegistryECRTokenRequest struct {
  140. Region string `schema:"region"`
  141. AccountID string `schema:"account_id"`
  142. }
  143. type GetRegistryDOCRTokenRequest struct {
  144. ServerURL string `schema:"server_url"`
  145. }
  146. // swagger:model ListRegistryRepositoriesResponse
  147. type ListRegistryRepositoryResponse []*RegistryRepository
  148. // swagger:model ListImagesResponse
  149. type ListImageResponse []*Image
  150. type V1ListImageRequest struct {
  151. Num int64 `schema:"num"`
  152. Next string `schema:"next"`
  153. NextPage uint `schema:"next_page"`
  154. }
  155. // swagger:model V1ListImageResponse
  156. type V1ListImageResponse struct {
  157. // The list of repository images with tags
  158. Images []*Image `json:"images" form:"required"`
  159. // The next page number used for pagination, when applicable
  160. NextPage uint `json:"num_page,omitempty"`
  161. // The next page string used for pagination, when application
  162. Next string `json:"next,omitempty"`
  163. }