1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-03 15:02:35 +02:00

Whitesource Docker scan : use the project name as the tar file path (#3256)

* add file path as project name

* fix test for containerSaveImage

Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
This commit is contained in:
Giridhar Shenoy 2021-12-13 16:14:32 +01:00 committed by GitHub
parent 38e4e0a133
commit ad0a3bda2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -51,6 +51,8 @@ func runContainerSaveImage(config *containerSaveImageOptions, telemetryData *tel
tarfilePath := config.FilePath
if len(tarfilePath) == 0 {
tarfilePath = filenameFromContainer(rootPath, config.ContainerImage)
} else {
tarfilePath = filenameFromContainer(rootPath, tarfilePath)
}
tarFile, err := os.Create(tarfilePath)

View File

@ -61,7 +61,7 @@ func TestRunContainerSaveImage(t *testing.T) {
cacheFolder := filepath.Join(tmpFolder, "cache")
config.FilePath = filepath.Join(tmpFolder, "testfile")
config.FilePath = "testfile"
dClient := containerMock{}
@ -71,7 +71,7 @@ func TestRunContainerSaveImage(t *testing.T) {
assert.Equal(t, cacheFolder, dClient.filePath)
assert.Equal(t, "imageSource", dClient.imageSource)
content, err := ioutil.ReadFile(config.FilePath)
content, err := ioutil.ReadFile(filepath.Join(tmpFolder, "testfile.tar"))
assert.NoError(t, err)
assert.Equal(t, "This is a test", string(content))
})

View File

@ -171,6 +171,7 @@ func runWhitesourceScan(config *ScanOptions, scan *ws.Scan, utils whitesourceUti
ContainerImage: config.ScanImage,
ContainerRegistryURL: config.ScanImageRegistryURL,
IncludeLayers: config.ScanImageIncludeLayers,
FilePath: config.ProjectName,
}
dClientOptions := piperDocker.ClientOptions{ImageName: saveImageOptions.ContainerImage, RegistryURL: saveImageOptions.ContainerRegistryURL, LocalPath: "", IncludeLayers: saveImageOptions.IncludeLayers}
dClient := &piperDocker.Client{}