Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix: harbor regular NOT_FOUND error treated as 'broken image' interna…
…l registry error Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
- Loading branch information
1 parent
a7eb34b
commit bc4ef3d
Showing
5 changed files
with
67 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package docker_registry | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/google/go-containerregistry/pkg/v1/remote/transport" | ||
) | ||
|
||
var ( | ||
BrokenImageCodes = []transport.ErrorCode{ | ||
transport.BlobUnknownErrorCode, | ||
transport.BlobUploadInvalidErrorCode, | ||
transport.BlobUploadUnknownErrorCode, | ||
transport.DigestInvalidErrorCode, | ||
transport.ManifestBlobUnknownErrorCode, | ||
transport.ManifestInvalidErrorCode, | ||
transport.ManifestUnverifiedErrorCode, | ||
transport.NameInvalidErrorCode, | ||
} | ||
|
||
NotFoundImageCodes = []transport.ErrorCode{ | ||
transport.ManifestUnknownErrorCode, | ||
transport.NameUnknownErrorCode, | ||
} | ||
) | ||
|
||
func isErrorMatched(err error, codes []transport.ErrorCode) bool { | ||
if err != nil { | ||
for _, code := range codes { | ||
if strings.Contains(err.Error(), string(code)) { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func IsBrokenImageError(err error) bool { | ||
return isErrorMatched(err, BrokenImageCodes) || IsQuayTagExpiredErr(err) | ||
} | ||
|
||
func IsImageNotFoundError(err error) bool { | ||
return isErrorMatched(err, NotFoundImageCodes) || IsHarborNotFoundError(err) | ||
} | ||
|
||
func IsHarborNotFoundError(err error) bool { | ||
return (err != nil) && strings.Contains(err.Error(), "NOT_FOUND") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters