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:
parent
38e4e0a133
commit
ad0a3bda2b
@ -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)
|
||||
|
@ -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))
|
||||
})
|
||||
|
@ -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{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user