1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

remove duplicated log messages (#8673) (#8676)

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
Co-authored-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
This commit is contained in:
gcp-cherry-pick-bot[bot] 2023-10-18 11:49:38 +08:00 committed by GitHub
parent 28c504a3c1
commit 2c570e007e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 21 deletions

View file

@ -1665,7 +1665,7 @@ func Test_ImageNormalize(t *testing.T) {
assert.NilError(t, err)
result, err := jp.Search("")
if tc.wantErr {
assert.Error(t, err, "JMESPath function 'image_normalize': bad image: docker.io/: invalid reference format")
assert.Error(t, err, "JMESPath function 'image_normalize': bad image: docker.io/, defaultRegistry: docker.io, enableDefaultRegistryMutation: true: invalid reference format")
} else {
assert.NilError(t, err)
res, ok := result.(string)

View file

@ -6,11 +6,8 @@ import (
"github.com/distribution/distribution/reference"
"github.com/kyverno/kyverno/pkg/config"
"github.com/kyverno/kyverno/pkg/logging"
)
var logger = logging.WithName("image")
type ImageInfo struct {
// Registry is the URL address of the image registry e.g. `docker.io`
Registry string `json:"registry,omitempty"`
@ -51,17 +48,11 @@ func (i *ImageInfo) ReferenceWithTag() string {
}
func GetImageInfo(image string, cfg config.Configuration) (*ImageInfo, error) {
logger.V(3).Info(
"getting the image info",
"image", image,
"defaultRegistry", config.Configuration.GetDefaultRegistry(cfg),
"enableDefaultRegistryMutation", config.Configuration.GetEnableDefaultRegistryMutation(cfg),
)
// adding the default domain in order to properly parse image info
fullImageName := addDefaultRegistry(image, cfg)
ref, err := reference.Parse(fullImageName)
if err != nil {
return nil, fmt.Errorf("bad image: %s: %w", fullImageName, err)
return nil, fmt.Errorf("bad image: %s, defaultRegistry: %s, enableDefaultRegistryMutation: %t: %w", fullImageName, config.Configuration.GetDefaultRegistry(cfg), config.Configuration.GetEnableDefaultRegistryMutation(cfg), err)
}
var registry, path, name, tag, digest string
@ -86,16 +77,6 @@ func GetImageInfo(image string, cfg config.Configuration) (*ImageInfo, error) {
registry = ""
}
logger.V(3).Info(
"getting the image info",
"image", image,
"registry", registry,
"name", name,
"path", path,
"tag", tag,
"digest", digest,
)
return &ImageInfo{
Registry: registry,
Name: name,