diff --git a/internal/name/remotename/remotename.go b/internal/name/remotename/remotename.go index 494bd2c..946816f 100644 --- a/internal/name/remotename/remotename.go +++ b/internal/name/remotename/remotename.go @@ -43,8 +43,7 @@ func NewFromString(s string) (RemoteName, error) { return RemoteName{}, fmt.Errorf("%w: remote name cannot have both a tag and a digest", ErrFailedToParse) case !isTagged && !isDigested: - return RemoteName{}, fmt.Errorf("%w: remote name should either have a tag or a digest", - ErrFailedToParse) + remoteName.Tag = "latest" case isTagged: remoteName.Tag = tagged.Tag() case isDigested: diff --git a/internal/name/remotename/remotename_test.go b/internal/name/remotename/remotename_test.go index f5184f1..25ed709 100644 --- a/internal/name/remotename/remotename_test.go +++ b/internal/name/remotename/remotename_test.go @@ -50,9 +50,14 @@ func TestInvalidNoNamespace(t *testing.T) { require.ErrorIs(t, err, remotename.ErrFailedToParse) } -func TestInvalidNoTagOrDigest(t *testing.T) { - _, err := remotename.NewFromString("ghcr.io/what/ever") - require.ErrorIs(t, err, remotename.ErrFailedToParse) +func TestDefaultToLatestTag(t *testing.T) { + parsedRemoteName, err := remotename.NewFromString("ghcr.io/what/ever") + require.NoError(t, err) + require.Equal(t, remotename.RemoteName{ + Registry: "ghcr.io", + Namespace: "what/ever", + Tag: "latest", + }, parsedRemoteName) } func TestInvalidBothTagAndDigest(t *testing.T) {