Skip to content

Commit 1e65877

Browse files
committed
ensure satisfaction
Signed-off-by: Jason Hall <[email protected]>
1 parent 43ff88a commit 1e65877

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

pkg/name/digest.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package name
1717
import (
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
3636
var _ 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.
3943
func (d Digest) Context() Repository {

pkg/name/registry.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package name
1616

1717
import (
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.
4248
func (r Registry) RegistryStr() string {
4349
return r.registry

pkg/name/repository.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package name
1616

1717
import (
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
3642
func hasImplicitNamespace(repo string, reg Registry) bool {
3743
return !strings.ContainsRune(repo, '/') && reg.RegistryStr() == DefaultRegistry

pkg/name/tag.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package name
1616

1717
import (
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
3636
var _ 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.
3943
func (t Tag) Context() Repository {

pkg/v1/hash.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package v1
1616

1717
import (
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.
3743
func (h Hash) String() string {
3844
return fmt.Sprintf("%s:%s", h.Algorithm, h.Hex)

0 commit comments

Comments
 (0)