File tree Expand file tree Collapse file tree 5 files changed +28
-2
lines changed Expand file tree Collapse file tree 5 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package name
1717import (
1818 // nolint: depguard
1919 _ "crypto/sha256" // Recommended by go-digest.
20+ "encoding"
2021 "encoding/json"
2122 "strings"
2223
@@ -32,8 +33,11 @@ type Digest struct {
3233 original string
3334}
3435
35- // Ensure Digest implements Reference
3636var _ Reference = (* Digest )(nil )
37+ var _ encoding.TextMarshaler = (* Digest )(nil )
38+ var _ encoding.TextUnmarshaler = (* Digest )(nil )
39+ var _ json.Marshaler = (* Digest )(nil )
40+ var _ json.Unmarshaler = (* Digest )(nil )
3741
3842// Context implements Reference.
3943func (d Digest ) Context () Repository {
Original file line number Diff line number Diff line change 1515package name
1616
1717import (
18+ "encoding"
1819 "encoding/json"
1920 "net"
2021 "net/url"
@@ -38,6 +39,11 @@ type Registry struct {
3839 registry string
3940}
4041
42+ var _ encoding.TextMarshaler = (* Registry )(nil )
43+ var _ encoding.TextUnmarshaler = (* Registry )(nil )
44+ var _ json.Marshaler = (* Registry )(nil )
45+ var _ json.Unmarshaler = (* Registry )(nil )
46+
4147// RegistryStr returns the registry component of the Registry.
4248func (r Registry ) RegistryStr () string {
4349 return r .registry
Original file line number Diff line number Diff line change 1515package name
1616
1717import (
18+ "encoding"
1819 "encoding/json"
1920 "fmt"
2021 "strings"
@@ -32,6 +33,11 @@ type Repository struct {
3233 repository string
3334}
3435
36+ var _ encoding.TextMarshaler = (* Repository )(nil )
37+ var _ encoding.TextUnmarshaler = (* Repository )(nil )
38+ var _ json.Marshaler = (* Repository )(nil )
39+ var _ json.Unmarshaler = (* Repository )(nil )
40+
3541// See https://docs.docker.com/docker-hub/official_repos
3642func hasImplicitNamespace (repo string , reg Registry ) bool {
3743 return ! strings .ContainsRune (repo , '/' ) && reg .RegistryStr () == DefaultRegistry
Original file line number Diff line number Diff line change 1515package name
1616
1717import (
18+ "encoding"
1819 "encoding/json"
1920 "strings"
2021)
@@ -32,8 +33,11 @@ type Tag struct {
3233 original string
3334}
3435
35- // Ensure Tag implements Reference
3636var _ Reference = (* Tag )(nil )
37+ var _ encoding.TextMarshaler = (* Tag )(nil )
38+ var _ encoding.TextUnmarshaler = (* Tag )(nil )
39+ var _ json.Marshaler = (* Tag )(nil )
40+ var _ json.Unmarshaler = (* Tag )(nil )
3741
3842// Context implements Reference.
3943func (t Tag ) Context () Repository {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ package v1
1616
1717import (
1818 "crypto"
19+ "encoding"
1920 "encoding/hex"
2021 "encoding/json"
2122 "fmt"
@@ -33,6 +34,11 @@ type Hash struct {
3334 Hex string
3435}
3536
37+ var _ encoding.TextMarshaler = (* Hash )(nil )
38+ var _ encoding.TextUnmarshaler = (* Hash )(nil )
39+ var _ json.Marshaler = (* Hash )(nil )
40+ var _ json.Unmarshaler = (* Hash )(nil )
41+
3642// String reverses NewHash returning the string-form of the hash.
3743func (h Hash ) String () string {
3844 return fmt .Sprintf ("%s:%s" , h .Algorithm , h .Hex )
You can’t perform that action at this time.
0 commit comments