registry.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. }
  70. type CreateRegistryRepositoryRequest struct {
  71. ImageRepoURI string `json:"image_repo_uri" form:"required"`
  72. }
  73. // UpdateRegistryRequest represents the accepted values for updating a
  74. // registry (only name for now)
  75. type UpdateRegistryRequest struct {
  76. Name string `json:"name" form:"required"`
  77. }
  78. type GetRegistryTokenResponse struct {
  79. Token string `json:"token"`
  80. ExpiresAt *time.Time `json:"expires_at"`
  81. }
  82. type GetRegistryGCRTokenRequest struct {
  83. ServerURL string `schema:"server_url"`
  84. }
  85. type GetRegistryECRTokenRequest struct {
  86. Region string `schema:"region"`
  87. AccountID string `schema:"account_id"`
  88. }
  89. type GetRegistryDOCRTokenRequest struct {
  90. ServerURL string `schema:"server_url"`
  91. }
  92. type ListRegistryRepositoryResponse []*RegistryRepository
  93. type ListImageResponse []*Image