reference_deprecated.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. // Package reference is deprecated, and has moved to github.com/distribution/reference.
  2. //
  3. // Deprecated: use github.com/distribution/reference instead.
  4. package reference
  5. import (
  6. "github.com/distribution/reference"
  7. "github.com/opencontainers/go-digest"
  8. )
  9. const (
  10. // NameTotalLengthMax is the maximum total number of characters in a repository name.
  11. //
  12. // Deprecated: use [reference.NameTotalLengthMax].
  13. NameTotalLengthMax = reference.NameTotalLengthMax
  14. )
  15. var (
  16. // ErrReferenceInvalidFormat represents an error while trying to parse a string as a reference.
  17. //
  18. // Deprecated: use [reference.ErrReferenceInvalidFormat].
  19. ErrReferenceInvalidFormat = reference.ErrReferenceInvalidFormat
  20. // ErrTagInvalidFormat represents an error while trying to parse a string as a tag.
  21. //
  22. // Deprecated: use [reference.ErrTagInvalidFormat].
  23. ErrTagInvalidFormat = reference.ErrTagInvalidFormat
  24. // ErrDigestInvalidFormat represents an error while trying to parse a string as a tag.
  25. //
  26. // Deprecated: use [reference.ErrDigestInvalidFormat].
  27. ErrDigestInvalidFormat = reference.ErrDigestInvalidFormat
  28. // ErrNameContainsUppercase is returned for invalid repository names that contain uppercase characters.
  29. //
  30. // Deprecated: use [reference.ErrNameContainsUppercase].
  31. ErrNameContainsUppercase = reference.ErrNameContainsUppercase
  32. // ErrNameEmpty is returned for empty, invalid repository names.
  33. //
  34. // Deprecated: use [reference.ErrNameEmpty].
  35. ErrNameEmpty = reference.ErrNameEmpty
  36. // ErrNameTooLong is returned when a repository name is longer than NameTotalLengthMax.
  37. //
  38. // Deprecated: use [reference.ErrNameTooLong].
  39. ErrNameTooLong = reference.ErrNameTooLong
  40. // ErrNameNotCanonical is returned when a name is not canonical.
  41. //
  42. // Deprecated: use [reference.ErrNameNotCanonical].
  43. ErrNameNotCanonical = reference.ErrNameNotCanonical
  44. )
  45. // Reference is an opaque object reference identifier that may include
  46. // modifiers such as a hostname, name, tag, and digest.
  47. //
  48. // Deprecated: use [reference.Reference].
  49. type Reference = reference.Reference
  50. // Field provides a wrapper type for resolving correct reference types when
  51. // working with encoding.
  52. //
  53. // Deprecated: use [reference.Field].
  54. type Field = reference.Field
  55. // AsField wraps a reference in a Field for encoding.
  56. //
  57. // Deprecated: use [reference.AsField].
  58. func AsField(ref reference.Reference) reference.Field {
  59. return reference.AsField(ref)
  60. }
  61. // Named is an object with a full name
  62. //
  63. // Deprecated: use [reference.Named].
  64. type Named = reference.Named
  65. // Tagged is an object which has a tag
  66. //
  67. // Deprecated: use [reference.Tagged].
  68. type Tagged = reference.Tagged
  69. // NamedTagged is an object including a name and tag.
  70. //
  71. // Deprecated: use [reference.NamedTagged].
  72. type NamedTagged reference.NamedTagged
  73. // Digested is an object which has a digest
  74. // in which it can be referenced by
  75. //
  76. // Deprecated: use [reference.Digested].
  77. type Digested reference.Digested
  78. // Canonical reference is an object with a fully unique
  79. // name including a name with domain and digest
  80. //
  81. // Deprecated: use [reference.Canonical].
  82. type Canonical reference.Canonical
  83. // Domain returns the domain part of the [Named] reference.
  84. //
  85. // Deprecated: use [reference.Domain].
  86. func Domain(named reference.Named) string {
  87. return reference.Domain(named)
  88. }
  89. // Path returns the name without the domain part of the [Named] reference.
  90. //
  91. // Deprecated: use [reference.Path].
  92. func Path(named reference.Named) (name string) {
  93. return reference.Path(named)
  94. }
  95. // SplitHostname splits a named reference into a
  96. // hostname and name string. If no valid hostname is
  97. // found, the hostname is empty and the full value
  98. // is returned as name
  99. //
  100. // Deprecated: Use [reference.Domain] or [reference.Path].
  101. func SplitHostname(named reference.Named) (string, string) {
  102. return reference.SplitHostname(named)
  103. }
  104. // Parse parses s and returns a syntactically valid Reference.
  105. // If an error was encountered it is returned, along with a nil Reference.
  106. //
  107. // Deprecated: use [reference.Parse].
  108. func Parse(s string) (reference.Reference, error) {
  109. return reference.Parse(s)
  110. }
  111. // ParseNamed parses s and returns a syntactically valid reference implementing
  112. // the Named interface. The reference must have a name and be in the canonical
  113. // form, otherwise an error is returned.
  114. // If an error was encountered it is returned, along with a nil Reference.
  115. //
  116. // Deprecated: use [reference.ParseNamed].
  117. func ParseNamed(s string) (reference.Named, error) {
  118. return reference.ParseNamed(s)
  119. }
  120. // WithName returns a named object representing the given string. If the input
  121. // is invalid ErrReferenceInvalidFormat will be returned.
  122. //
  123. // Deprecated: use [reference.WithName].
  124. func WithName(name string) (reference.Named, error) {
  125. return reference.WithName(name)
  126. }
  127. // WithTag combines the name from "name" and the tag from "tag" to form a
  128. // reference incorporating both the name and the tag.
  129. //
  130. // Deprecated: use [reference.WithTag].
  131. func WithTag(name reference.Named, tag string) (reference.NamedTagged, error) {
  132. return reference.WithTag(name, tag)
  133. }
  134. // WithDigest combines the name from "name" and the digest from "digest" to form
  135. // a reference incorporating both the name and the digest.
  136. //
  137. // Deprecated: use [reference.WithDigest].
  138. func WithDigest(name reference.Named, digest digest.Digest) (reference.Canonical, error) {
  139. return reference.WithDigest(name, digest)
  140. }
  141. // TrimNamed removes any tag or digest from the named reference.
  142. //
  143. // Deprecated: use [reference.TrimNamed].
  144. func TrimNamed(ref reference.Named) reference.Named {
  145. return reference.TrimNamed(ref)
  146. }