Skip to content

Commit

Permalink
Apply CR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Or-Geva committed Mar 28, 2023
1 parent 54c8e6f commit 0077fcd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions artifactory/utils/container/buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package container

import (
"encoding/json"
"errors"
"os"
"path"
"strings"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions artifactory/utils/container/buildinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion artifactory/utils/container/localagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0077fcd

Please sign in to comment.