Commit Graph

12 Commits (v2.3.0-rc.1)

Author SHA1 Message Date
Rodolfo Carvalho e0fe14618f Fix godoc
`RepositoryNameTotalLengthMax` doesn't exist anymore.

Signed-off-by: Rodolfo Carvalho <rhcarvalho@gmail.com>
2015-12-22 12:26:05 +01:00
Stephen J Day 3150937b9f reference: refactor grammar and regular expressions
To resolve some inconsistencies between the grammar and the regular
expressions, the grammar has been slightly refactored to match the intent. The
regular expressions have been redefined with the same structure to make it
easier to verify the grammar is correct.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2015-12-04 17:54:23 -08:00
Tonis Tiigi f015982f0f Validate digest length on parsing
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2015-12-02 16:04:06 -08:00
Aaron Lehmann 073bd89262 Check length of input in WithName
There is a constraint on the length of the name in a reference, so
WithName should be checking this instead of potentially creating a
reference that doesn't comply with the rules.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-11-02 09:12:21 -08:00
Aaron Lehmann 985ee759e7 Use correct regexp in reference.WithTag
This was using a different regexp from the intended one. This meant that
tags with uppercase characters were not accepted.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-10-28 18:22:00 -07:00
Aaron Lehmann 16eea0cc47 Usability improvements for reference package
Various improvements motivated by early real-world use in engine code
under development:

- Make `WithDigest` return `Canonical`, since the return value always
  has a name and a digest.

- Introduce a `NamedTagged` type, which can be used for strongly typing
  cases where something must have a name and a tag.

- Rename `ParseNamed` to `WithName`, and create a
  `ParseNamed` that accepts tags and digests (returning a `Named` type).
  The new `ParseNamed` makes code using the reference package much less
  verbose, since typical use cases require a name, and this is an
  additional type assertion and error case after every `Parse` call.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-10-13 16:07:34 -07:00
Aaron Lehmann b07d759241 Add WithTag and WithDigest combinator functions
These functions allow a Named type to be combined with a tag or a
digest. WithTag will replace the ImageReference function in
github.com/docker/docker/utils as the Docker Engine transitions to the
reference package.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-10-12 16:00:33 -07:00
Derek McGowan 3943c4165c Make Named,Tagged, and Digested implement Reference
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2015-10-09 16:14:08 -07:00
Derek McGowan 6bd5b8c24e Update regexp to support repeated dash and double underscore
In order to support valid hostnames as name components, supporting repeated dash was added.
Additionally double underscore is now allowed as a separator to loosen the restriction for previously supported names.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2015-10-09 16:14:08 -07:00
Derek McGowan bcda04d6cd Add field type for serialization
Since reference itself may be represented by multiple types which implement the reference inteface, serialization can lead to ambiguous type which cannot be deserialized.
Field wraps the reference object to ensure that the correct type is always deserialized, requiring an extra unwrap of the reference after deserialization.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2015-10-09 16:05:49 -07:00
Derek McGowan 31a448a628 Update to provide small and clear interfaces
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2015-10-09 16:05:49 -07:00
Tibor Vass f8c09b6a7d Add a new reference package abstracting repositories, tags and digests
There seems to be a need for a type that represents a way of pointing
to an image, irrespective of the implementation.

This patch defines a Reference interface and provides 3 implementations:
- TagReference: when only a tag is provided
- DigestReference: when a digest (according to the digest package) is
  provided, can include optional tag as well

Validation of references are purely syntactic.

There is also a strong type for tags, analogous to digests, as well
as a strong type for Repository from which clients can access the
hostname alone, or the repository name without the hostname, or both
together via the String() method.

For Repository, the files names.go and names_test.go were moved from
the v2 package.

Signed-off-by: Tibor Vass <tibor@docker.com>
2015-10-09 16:05:34 -07:00