Skip to content

Commit f9f3254

Browse files
authored
Merge pull request #242 from nicholasSUSE/quick-fix-stg-missing-img
handling cases when repository does not exist
2 parents b2e93da + f21a4f0 commit f9f3254

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pkg/registries/remote.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
authn "github.com/google/go-containerregistry/pkg/authn"
1919
name "github.com/google/go-containerregistry/pkg/name"
2020
remote "github.com/google/go-containerregistry/pkg/v1/remote"
21+
transport "github.com/google/go-containerregistry/pkg/v1/remote/transport"
2122
)
2223

2324
const (
@@ -97,7 +98,9 @@ var listRegistryImageTags = func(ctx context.Context, imageTagMap map[string][]s
9798
}
9899

99100
logger.Log(ctx, slog.LevelDebug, "", slog.Any("tags", tags))
100-
remoteImgTagMap[asset] = tags
101+
if len(tags) > 0 {
102+
remoteImgTagMap[asset] = tags
103+
}
101104
}
102105

103106
return remoteImgTagMap, nil
@@ -140,6 +143,15 @@ var fetchTagsFromRegistryRepo = func(ctx context.Context, registry, asset string
140143
// but remote package handles pagination internally if needed
141144
tags, err := remote.List(repo, options...)
142145
if err != nil {
146+
var transportError *transport.Error
147+
if errors.As(err, &transportError) {
148+
for _, d := range transportError.Errors {
149+
if d.Code == "NAME_UNKNOWN" {
150+
logger.Log(ctx, slog.LevelWarn, "repository not found", slog.String("repo", repo.Name()))
151+
return []string{}, nil
152+
}
153+
}
154+
}
143155
logger.Log(ctx, slog.LevelError, "list failure", logger.Err(err))
144156
return nil, err
145157
}

0 commit comments

Comments
 (0)