2
0

registry.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. type RegistryListResponse []Registry
  61. type CreateRegistryRequest struct {
  62. URL string `json:"url"`
  63. Name string `json:"name" form:"required"`
  64. GCPIntegrationID uint `json:"gcp_integration_id"`
  65. AWSIntegrationID uint `json:"aws_integration_id"`
  66. DOIntegrationID uint `json:"do_integration_id"`
  67. BasicIntegrationID uint `json:"basic_integration_id"`
  68. AzureIntegrationID uint `json:"azure_integration_id"`
  69. // Additional Azure-specific fields
  70. ACRResourceGroupName string `json:"acr_resource_group_name"`
  71. ACRName string `json:"acr_name"`
  72. }
  73. type CreateRegistryRepositoryRequest struct {
  74. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  75. }
  76. // UpdateRegistryRequest represents the accepted values for updating a
  77. // registry (only name for now)
  78. type UpdateRegistryRequest struct {
  79. Name string `json:"name" form:"required"`
  80. }
  81. type GetRegistryTokenResponse struct {
  82. Token string `json:"token"`
  83. ExpiresAt *time.Time `json:"expires_at"`
  84. }
  85. type GetRegistryGCRTokenRequest struct {
  86. ServerURL string `schema:"server_url"`
  87. }
  88. type GetRegistryECRTokenRequest struct {
  89. Region string `schema:"region"`
  90. AccountID string `schema:"account_id"`
  91. }
  92. type GetRegistryDOCRTokenRequest struct {
  93. ServerURL string `schema:"server_url"`
  94. }
  95. type ListRegistryRepositoryResponse []*RegistryRepository
  96. type ListImageResponse []*Image