registry.go 3.7 KB

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