mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-21 21:33:22 +01:00
fix: do not set Image receiver as pointer
We can't directly call pointer receiver methods like Image.String() in go text/template.
This commit is contained in:
@@ -19,6 +19,7 @@ type Image struct {
|
|||||||
Tag string
|
Tag string
|
||||||
Digest digest.Digest
|
Digest digest.Digest
|
||||||
HubLink string
|
HubLink string
|
||||||
|
|
||||||
named reference.Named
|
named reference.Named
|
||||||
opts ParseImageOptions
|
opts ParseImageOptions
|
||||||
}
|
}
|
||||||
@@ -66,17 +67,17 @@ func ParseImage(parseOpts ParseImageOptions) (Image, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Name returns the full name representation of an image.
|
// Name returns the full name representation of an image.
|
||||||
func (i *Image) Name() string {
|
func (i Image) Name() string {
|
||||||
return i.named.Name()
|
return i.named.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the string representation of an image.
|
// String returns the string representation of an image.
|
||||||
func (i *Image) String() string {
|
func (i Image) String() string {
|
||||||
return i.named.String()
|
return i.named.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference returns either the digest if it is non-empty or the tag for the image.
|
// Reference returns either the digest if it is non-empty or the tag for the image.
|
||||||
func (i *Image) Reference() string {
|
func (i Image) Reference() string {
|
||||||
if len(i.Digest.String()) > 1 {
|
if len(i.Digest.String()) > 1 {
|
||||||
return i.Digest.String()
|
return i.Digest.String()
|
||||||
}
|
}
|
||||||
@@ -85,13 +86,13 @@ func (i *Image) Reference() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithDigest sets the digest for an image.
|
// WithDigest sets the digest for an image.
|
||||||
func (i *Image) WithDigest(digest digest.Digest) (err error) {
|
func (i Image) WithDigest(digest digest.Digest) (err error) {
|
||||||
i.Digest = digest
|
i.Digest = digest
|
||||||
i.named, err = reference.WithDigest(i.named, digest)
|
i.named, err = reference.WithDigest(i.named, digest)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) hubLink() (string, error) {
|
func (i Image) hubLink() (string, error) {
|
||||||
if i.opts.HubTpl != "" {
|
if i.opts.HubTpl != "" {
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
tmpl, err := template.New("tmpl").
|
tmpl, err := template.New("tmpl").
|
||||||
|
|||||||
Reference in New Issue
Block a user