registry.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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,gar,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. GAR RegistryService = "gar"
  78. ECR RegistryService = "ecr"
  79. ACR RegistryService = "acr"
  80. DOCR RegistryService = "docr"
  81. DockerHub RegistryService = "dockerhub"
  82. )
  83. // swagger:model ListRegistriesResponse
  84. type RegistryListResponse []Registry
  85. // swagger:model
  86. type CreateRegistryRequest struct {
  87. // URL of the container registry
  88. // example: 123456789.dkr.ecr.us-west-2.amazonaws.com
  89. URL string `json:"url"`
  90. // Name of the container registry
  91. // required: true
  92. // example: my-ecr-reg
  93. Name string `json:"name" form:"required"`
  94. // The GCP integration ID to be used for this registry
  95. // minimum: 1
  96. // example: 0
  97. GCPIntegrationID uint `json:"gcp_integration_id"`
  98. // The AWS integration ID to be used for this registry
  99. // minimum: 1
  100. // example: 1
  101. AWSIntegrationID uint `json:"aws_integration_id"`
  102. // The DigitalOcean integration ID to be used for this registry
  103. // minimum: 1
  104. // example: 0
  105. DOIntegrationID uint `json:"do_integration_id"`
  106. // The Basic integration ID to be used for this registry
  107. // minimum: 1
  108. // example: 0
  109. BasicIntegrationID uint `json:"basic_integration_id"`
  110. // The Azure integration ID to be used for this registry
  111. // minimum: 1
  112. // example: 0
  113. AzureIntegrationID uint `json:"azure_integration_id"`
  114. // Additional Azure-specific fields
  115. // ACR resource group name (**Azure only**)
  116. ACRResourceGroupName string `json:"acr_resource_group_name"`
  117. // ACR name (**Azure only**)
  118. ACRName string `json:"acr_name"`
  119. }
  120. // swagger:model
  121. type CreateRegistryResponse Registry
  122. // swagger:model
  123. type GetRegistryResponse Registry
  124. // swagger:model
  125. type CreateRegistryRepositoryRequest struct {
  126. // The URL to the repository of a registry (ECR, GAR)
  127. // required: true
  128. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  129. }
  130. // UpdateRegistryRequest represents the accepted values for updating a
  131. // registry (only name for now)
  132. type UpdateRegistryRequest struct {
  133. Name string `json:"name" form:"required"`
  134. }
  135. type GetRegistryTokenResponse struct {
  136. Token string `json:"token"`
  137. ExpiresAt time.Time `json:"expires_at"`
  138. }
  139. type GetRegistryACRTokenRequest struct {
  140. ServerURL string `schema:"server_url"`
  141. }
  142. type GetRegistryGCRTokenRequest struct {
  143. ServerURL string `schema:"server_url"`
  144. }
  145. type GetRegistryGARTokenRequest struct {
  146. ServerURL string `schema:"server_url"`
  147. }
  148. type GetRegistryECRTokenRequest struct {
  149. Region string `schema:"region"`
  150. AccountID string `schema:"account_id"`
  151. }
  152. type GetRegistryDOCRTokenRequest struct {
  153. ServerURL string `schema:"server_url"`
  154. }
  155. // swagger:model ListRegistryRepositoriesResponse
  156. type ListRegistryRepositoryResponse []*RegistryRepository
  157. // swagger:model ListImagesResponse
  158. type ListImageResponse []*Image
  159. type V1ListImageRequest struct {
  160. Num int64 `schema:"num"`
  161. Next string `schema:"next"`
  162. Page uint `schema:"page"`
  163. }
  164. // swagger:model V1ListImageResponse
  165. type V1ListImageResponse struct {
  166. // The list of repository images with tags
  167. Images []*Image `json:"images" form:"required"`
  168. // The next page number used for pagination (**DigitalOcean only**)
  169. NextPage uint `json:"next_page,omitempty"`
  170. // The next page cursor used for pagination
  171. Next string `json:"next,omitempty"`
  172. }