refactor: use slices.Contains to simplify code

Signed-off-by: tongjicoder <tongjicoder@icloud.com>
This commit is contained in:
tongjicoder
2025-05-27 14:43:50 +08:00
committed by Nicolas De loof
parent d49a68ecbf
commit 2e71440bee
14 changed files with 32 additions and 47 deletions

View File

@@ -23,6 +23,7 @@ import (
"fmt"
"net/http"
"path/filepath"
"slices"
"time"
pusherrors "github.com/containerd/containerd/v2/core/remotes/errors"
@@ -157,14 +158,7 @@ func isNonAuthClientError(statusCode int) bool {
// not a client error
return false
}
for _, v := range clientAuthStatusCodes {
if statusCode == v {
// client auth error
return false
}
}
// any other 4xx client error
return true
return !slices.Contains(clientAuthStatusCodes, statusCode)
}
func generateManifest(layers []v1.Descriptor, ociCompat api.OCIVersion) ([]Pushable, error) {