From 0077fcd3d47e5c08a12b512faad62586cd285110 Mon Sep 17 00:00:00 2001 From: Or Geva Date: Tue, 28 Mar 2023 09:23:10 +0300 Subject: [PATCH] Apply CR changes --- artifactory/utils/container/buildinfo.go | 5 ++--- artifactory/utils/container/buildinfo_test.go | 6 +++--- artifactory/utils/container/localagent.go | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/artifactory/utils/container/buildinfo.go b/artifactory/utils/container/buildinfo.go index a0dcad4ab..fe86b322b 100644 --- a/artifactory/utils/container/buildinfo.go +++ b/artifactory/utils/container/buildinfo.go @@ -2,7 +2,6 @@ package container import ( "encoding/json" - "errors" "os" "path" "strings" @@ -437,13 +436,13 @@ func getDependenciesFromManifestConfig(candidateLayers map[string]*utils.ResultI var dependencies []buildinfo.Dependency manifestSearchResults, found := candidateLayers["manifest.json"] if !found { - return nil, errors.New("failed to collect build-info. The manifest.json was not found in Artifactory") + return nil, errorutils.CheckErrorf("failed to collect build-info. The manifest.json was not found in Artifactory") } dependencies = append(dependencies, getManifestDependency(manifestSearchResults)) imageDetails, found := candidateLayers[digestToLayer(imageSha2)] if !found { - return nil, errors.New("failed to collect build-info. Image '" + imageSha2 + "' was not found in Artifactory") + return nil, errorutils.CheckErrorf("failed to collect build-info. Image '" + imageSha2 + "' was not found in Artifactory") } return append(dependencies, imageDetails.ToDependency()), nil diff --git a/artifactory/utils/container/buildinfo_test.go b/artifactory/utils/container/buildinfo_test.go index c7b16fa25..cb62c1d49 100644 --- a/artifactory/utils/container/buildinfo_test.go +++ b/artifactory/utils/container/buildinfo_test.go @@ -69,7 +69,7 @@ func createManifestConfig() (map[string]*utils.ResultItem, string) { func TestManifestConfigNoManifestFound(t *testing.T) { _, err := getDependenciesFromManifestConfig(createEmptyManifestConfig()) - assert.Error(t, err) + assert.ErrorContains(t, err, "The manifest.json was not found in Artifactory") } func createEmptyManifestConfig() (map[string]*utils.ResultItem, string) { @@ -79,7 +79,7 @@ func createEmptyManifestConfig() (map[string]*utils.ResultItem, string) { func TestManifestConfigNoLayer(t *testing.T) { _, err := getDependenciesFromManifestConfig(createManifestConfigWithNoLayer()) - assert.Error(t, err) + assert.ErrorContains(t, err, "Image 'sha:123' was not found in Artifactory") } func createManifestConfigWithNoLayer() (map[string]*utils.ResultItem, string) { @@ -112,7 +112,7 @@ func createManifestConfigWithLayer() (map[string]*utils.ResultItem, *manifest) { func TestMissingDependenciesInManifestLayer(t *testing.T) { searchResults, manifest := createManifestConfigWithMissingLayer() _, err := getDependenciesFromManifestLayer(searchResults, manifest) - assert.Error(t, err) + assert.ErrorContains(t, err, "Could not find layer: sha__2 in Artifactory") } func createManifestConfigWithMissingLayer() (map[string]*utils.ResultItem, *manifest) { diff --git a/artifactory/utils/container/localagent.go b/artifactory/utils/container/localagent.go index 48ad1139f..9987dfc71 100644 --- a/artifactory/utils/container/localagent.go +++ b/artifactory/utils/container/localagent.go @@ -56,7 +56,7 @@ func (labib *localAgentbuildInfoBuilder) Build(module string) (*buildinfo.BuildI log.Debug(err.Error()) return nil, nil } else { - log.Debug("Found the following manifest.json with layers to create build-info:", candidateLayers) + log.Debug("Found manifest.json with the following layers to create build-info:", candidateLayers) } // Create build-info from search results. return labib.buildInfoBuilder.createBuildInfo(labib.commandType, manifest, candidateLayers, module)