go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/discovery/container_registry/errors.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package container_registry 5 6 import ( 7 "fmt" 8 "net/http" 9 10 "github.com/google/go-containerregistry/pkg/v1/remote/transport" 11 ) 12 13 func handleUnauthorizedError(err error, repoName string) error { 14 if err != nil { 15 if tErr, ok := err.(*transport.Error); ok && tErr.StatusCode == http.StatusUnauthorized { 16 err = fmt.Errorf("cannot list repo %s due to missing container registry credentials", repoName) 17 } 18 } 19 return err 20 }