mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-20 05:19:40 +02:00
bug(cnbBuild) Skip restoring image content (#3612)
Co-authored-by: Pavel Busko <pavel.busko@sap.com> Co-authored-by: Johannes Dillmann <j.dillmann@sap.com> Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
This commit is contained in:
parent
424d8ec3a7
commit
0cef702d9d
@ -371,7 +371,17 @@ func callCnbBuild(config *cnbBuildOptions, telemetryData *telemetry.CustomData,
|
||||
}
|
||||
|
||||
func runCnbBuild(config *cnbBuildOptions, telemetryData *telemetry.CustomData, telemetry *cnbBuildTelemetry, utils cnbutils.BuildUtils, commonPipelineEnvironment *cnbBuildCommonPipelineEnvironment, httpClient piperhttp.Sender) error {
|
||||
var err error
|
||||
err := cleanDir("/layers", utils)
|
||||
if err != nil {
|
||||
log.SetErrorCategory(log.ErrorBuild)
|
||||
return errors.Wrap(err, "failed to clean up layers folder /layers")
|
||||
}
|
||||
|
||||
err = cleanDir(platformPath, utils)
|
||||
if err != nil {
|
||||
log.SetErrorCategory(log.ErrorBuild)
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to clean up platform folder %s", platformPath))
|
||||
}
|
||||
|
||||
customTelemetryData := cnbBuildTelemetryData{}
|
||||
addConfigTelemetryData(utils, &customTelemetryData, config)
|
||||
@ -457,14 +467,13 @@ func runCnbBuild(config *cnbBuildOptions, telemetryData *telemetry.CustomData, t
|
||||
}
|
||||
}
|
||||
|
||||
target := "/workspace"
|
||||
|
||||
pathType, source, err := config.resolvePath(utils)
|
||||
if err != nil {
|
||||
log.SetErrorCategory(log.ErrorBuild)
|
||||
return errors.Wrapf(err, "could no resolve path")
|
||||
}
|
||||
|
||||
target := "/workspace"
|
||||
err = cleanDir(target, utils)
|
||||
if err != nil {
|
||||
log.SetErrorCategory(log.ErrorBuild)
|
||||
@ -538,6 +547,11 @@ func runCnbBuild(config *cnbBuildOptions, telemetryData *telemetry.CustomData, t
|
||||
"-buildpacks", buildpacksPath,
|
||||
"-order", orderPath,
|
||||
"-platform", platformPath,
|
||||
"-skip-restore",
|
||||
}
|
||||
|
||||
if GeneralConfig.Verbose {
|
||||
creatorArgs = append(creatorArgs, "-log-level", "debug")
|
||||
}
|
||||
|
||||
containerImage := path.Join(targetImage.ContainerRegistry.Host, targetImage.ContainerImageName)
|
||||
|
@ -848,9 +848,17 @@ func TestRunKubernetesDeploy(t *testing.T) {
|
||||
mockUtils.Calls[0].Params, "Wrong secret creation parameters")
|
||||
|
||||
assert.Equal(t, "helm", mockUtils.Calls[1].Exec, "Wrong upgrade command")
|
||||
|
||||
assert.Contains(t, mockUtils.Calls[1].Params, `image.myImage.repository=my.registry:55555/myImage,image.myImage.tag=myTag,image.myImage\.sub1.repository=my.registry:55555/myImage-sub1,image.myImage\.sub1.tag=myTag,image.myImage\.sub2.repository=my.registry:55555/myImage-sub2,image.myImage\.sub2.tag=myTag,secret.name=testSecret,secret.dockerconfigjson=ThisIsOurBase64EncodedSecret==,imagePullSecrets[0].name=testSecret,subchart.image.registry=my.registry:55555/myImage,subchart.image.tag=myTag`, "Wrong upgrade parameters")
|
||||
|
||||
assert.Equal(t, len(mockUtils.Calls[1].Params), 21, "Unexpected upgrade command")
|
||||
pos := 11
|
||||
assert.Contains(t, mockUtils.Calls[1].Params[pos], "image.myImage.repository=my.registry:55555/myImage", "Missing update parameter")
|
||||
assert.Contains(t, mockUtils.Calls[1].Params[pos], "image.myImage.tag=myTag", "Wrong upgrade parameters")
|
||||
assert.Contains(t, mockUtils.Calls[1].Params[pos], "image.myImage\\.sub1.repository=my.registry:55555/myImage-sub1", "Missing update parameter")
|
||||
assert.Contains(t, mockUtils.Calls[1].Params[pos], "image.myImage\\.sub1.tag=myTag", "Missing update parameter")
|
||||
assert.Contains(t, mockUtils.Calls[1].Params[pos], "image.myImage\\.sub2.repository=my.registry:55555/myImage-sub2", "Missing update parameter")
|
||||
assert.Contains(t, mockUtils.Calls[1].Params[pos], "image.myImage\\.sub2.tag=myTag,secret.name=testSecret,secret.dockerconfigjson=ThisIsOurBase64EncodedSecret==", "Missing update parameter")
|
||||
assert.Contains(t, mockUtils.Calls[1].Params[pos], "imagePullSecrets[0].name=testSecret", "Missing update parameter")
|
||||
assert.Contains(t, mockUtils.Calls[1].Params[pos], "subchart.image.registry=my.registry:55555/myImage", "Missing update parameter")
|
||||
assert.Contains(t, mockUtils.Calls[1].Params[pos], "subchart.image.tag=myTag", "Missing update parameter")
|
||||
})
|
||||
|
||||
t.Run("test helm v3 - with multiple images and incorrect valuesMapping", func(t *testing.T) {
|
||||
|
@ -44,15 +44,32 @@ func TestNpmProject(t *testing.T) {
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
|
||||
err := container.whenRunningPiperCommand("cnbBuild", "--customConfig", "TestCnbIntegration/config_env.yml", "--path", "TestMtaIntegration/npm", "--containerImageName", "not-found", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL)
|
||||
container2 := givenThisContainer(t, IntegrationTestDockerExecRunnerBundle{
|
||||
Image: "paketobuildpacks/builder:0.1.342-full",
|
||||
User: "cnb",
|
||||
TestDir: []string{"testdata"},
|
||||
Network: fmt.Sprintf("container:%s", registryContainer.GetContainerID()),
|
||||
})
|
||||
|
||||
err := container.whenRunningPiperCommand("cnbBuild", "--path", "TestCnbIntegration/project", "--customConfig", "TestCnbIntegration/config.yml", "--containerImageName", "node", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL)
|
||||
assert.NoError(t, err)
|
||||
container.assertHasOutput(t, "running command: /cnb/lifecycle/creator")
|
||||
container.assertHasOutput(t, "Selected Node Engine version (using BP_NODE_VERSION): 16")
|
||||
container.assertHasOutput(t, "Paketo NPM Start Buildpack")
|
||||
container.assertHasOutput(t, fmt.Sprintf("Saving %s/not-found:0.0.1", registryURL))
|
||||
container.assertHasOutput(t, fmt.Sprintf("Saving %s/node:0.0.1", registryURL))
|
||||
container.assertHasOutput(t, "*** Images (sha256:")
|
||||
container.assertHasOutput(t, "SUCCESS")
|
||||
container.terminate(t)
|
||||
|
||||
err = container2.whenRunningPiperCommand("cnbBuild", "--path", "TestCnbIntegration/project", "--customConfig", "TestCnbIntegration/config.yml", "--containerImageName", "node", "--containerImageTag", "0.0.1", "--containerRegistryUrl", registryURL)
|
||||
assert.NoError(t, err)
|
||||
container2.assertHasOutput(t, "running command: /cnb/lifecycle/creator")
|
||||
container2.assertHasOutput(t, "Selected Node Engine version (using BP_NODE_VERSION): 16")
|
||||
container2.assertHasOutput(t, "Paketo NPM Start Buildpack")
|
||||
container2.assertHasOutput(t, fmt.Sprintf("Saving %s/node:0.0.1", registryURL))
|
||||
container2.assertHasOutput(t, "*** Images (sha256:")
|
||||
container2.assertHasOutput(t, "SUCCESS")
|
||||
container2.terminate(t)
|
||||
}
|
||||
|
||||
func TestProjectDescriptor(t *testing.T) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
general:
|
||||
verbose: false
|
||||
steps:
|
||||
cnbBuild:
|
||||
bindings:
|
||||
|
Loading…
x
Reference in New Issue
Block a user