Skip to content

Commit 74eeb52

Browse files
authored
doc: revise doc of registry.Reference (#358)
Closes #332 Signed-off-by: Nima Talebi <ntd@amazon.com>
1 parent 9e5b141 commit 74eeb52

File tree

1 file changed

+41
-20
lines changed

1 file changed

+41
-20
lines changed

registry/reference.go

+41-20
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,22 @@ var (
4242
tagRegexp = regexp.MustCompile(`^[\w][\w.-]{0,127}$`)
4343
)
4444

45-
// Reference references to a descriptor in the registry.
45+
// Reference references either a resource descriptor (where Reference.Reference
46+
// is a tag or a digest), or a resource repository (where Reference.Reference
47+
// is the empty string).
4648
type Reference struct {
47-
// Registry is the name of the registry.
48-
// It is usually the domain name of the registry optionally with a port.
49+
// Registry is the name of the registry. It is usually the domain name of
50+
// the registry optionally with a port.
4951
Registry string
5052

5153
// Repository is the name of the repository.
5254
Repository string
5355

54-
// Reference is the reference of the object in the repository.
55-
// A reference can be a tag or a digest.
56+
// Reference is the reference of the object in the repository. This field
57+
// can take any one of the four valid forms (see ParseReference). In the
58+
// case where it's the empty string, it necessarily implies valid form D,
59+
// and where it is non-empty, then it is either a tag, or a digest
60+
// (implying one of valid forms A, B, or C).
5661
Reference string
5762
}
5863

@@ -61,25 +66,41 @@ type Reference struct {
6166
// Note: An "image" is an "artifact", however, an "artifact" is not necessarily
6267
// an "image".
6368
//
64-
// The parameter `artifact` is an opaque polymorphic string, composed of two
65-
// other opaque tokens; namely `socketaddr` and `path`: These can in turn take
66-
// on their own polymorphic forms. To do this, the Backus–Naur Form (BNF)
67-
// notation has been adopted, with the exception that *lowercase* labels here
68-
// imply opaque values (composed of other components), and *uppercase* labels
69-
// imply resolute/final values (can not be expanded further into subcomponents).
69+
// The token `artifact` is composed of other tokens, and those in turn are
70+
// composed of others. This definition recursivity requires a notation capable
71+
// of recursion, thus the following two forms have been adopted:
7072
//
71-
// <artifact> ::= <socketaddr> "/" <path>
73+
// 1. Backus–Naur Form (BNF) has been adopted to address the recursive nature
74+
// of the definition.
75+
// 2. Token opacity is revealed via its label letter-casing. That is, "opaque"
76+
// tokens (i.e., tokens that are not final, and must therefore be further
77+
// broken down into their constituents) are denoted in *lowercase*, while
78+
// final tokens (i.e., leaf-node tokens that are final) are denoted in
79+
// *uppercase*.
7280
//
73-
// <socketaddr> ::= <host> | <host> ":" <PORT>
74-
// <host> ::= <ip> | <FQDN>
75-
// <ip> ::= <IPV4-ADDR> | <IPV6-ADDR>
81+
// Finally, note that a number of the opaque tokens are polymorphic in nature;
82+
// that is, they can take on one of numerous forms, not restricted to a single
83+
// defining form.
7684
//
77-
// <path> ::= <REPOSITORY> | <REPOSITORY> <reference>
78-
// <reference> ::= "@" <digest> | ":" <TAG> "@" <DIGEST> | ":" <TAG>
79-
// <digest> ::= <ALGO> ":" <HASH>
85+
// The top-level token, `artifact`, is composed of two (opaque) tokens; namely
86+
// `socketaddr` and `path`:
8087
//
81-
// That is, of all the possible forms that `path` can take, there are exactly 4
82-
// that are considered valid. Expanding the BNF notation for `path`, the 4 are:
88+
// <artifact> ::= <socketaddr> "/" <path>
89+
//
90+
// The former is described as follows:
91+
//
92+
// <socketaddr> ::= <host> | <host> ":" <PORT>
93+
// <host> ::= <ip> | <FQDN>
94+
// <ip> ::= <IPV4-ADDR> | <IPV6-ADDR>
95+
//
96+
// The latter, which is of greater interest here, is described as follows:
97+
//
98+
// <path> ::= <REPOSITORY> | <REPOSITORY> <reference>
99+
// <reference> ::= "@" <digest> | ":" <TAG> "@" <DIGEST> | ":" <TAG>
100+
// <digest> ::= <ALGO> ":" <HASH>
101+
//
102+
// This second token--`path`--can take on exactly four forms, each of which will
103+
// now be illustrated:
83104
//
84105
// <--- path --------------------------------------------> | - Decode `path`
85106
// <=== REPOSITORY ===> <--- reference ------------------> | - Decode `reference`

0 commit comments

Comments
 (0)