mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-18 05:18:24 +02:00
fix(kaniko): backwards compatibility with kaniko 1.3.0 (#3583)
* fix(kaniko): jnlp issues * fix * fix(kanikoExecute): backwards compatibility with kaniko 1.3.0 Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
This commit is contained in:
parent
d6916e8953
commit
956cab5de3
@ -134,7 +134,7 @@ func runKanikoExecute(config *kanikoExecuteOptions, telemetryData *telemetry.Cus
|
||||
containerImageNameAndTag := fmt.Sprintf("%v:%v", image, containerImageTag)
|
||||
dest = []string{"--destination", fmt.Sprintf("%v/%v", containerRegistry, containerImageNameAndTag)}
|
||||
buildOpts := append(config.BuildOptions, dest...)
|
||||
err = runKaniko(file, buildOpts, execRunner, fileUtils, commonPipelineEnvironment)
|
||||
err = runKaniko(file, buildOpts, config.ReadImageDigest, execRunner, fileUtils, commonPipelineEnvironment)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to build image '%v' using '%v': %w", image, file, err)
|
||||
}
|
||||
@ -206,15 +206,18 @@ func runKanikoExecute(config *kanikoExecuteOptions, telemetryData *telemetry.Cus
|
||||
}
|
||||
|
||||
// no support for building multiple containers
|
||||
return runKaniko(config.DockerfilePath, config.BuildOptions, execRunner, fileUtils, commonPipelineEnvironment)
|
||||
return runKaniko(config.DockerfilePath, config.BuildOptions, config.ReadImageDigest, execRunner, fileUtils, commonPipelineEnvironment)
|
||||
}
|
||||
|
||||
func runKaniko(dockerFilepath string, buildOptions []string, execRunner command.ExecRunner, fileUtils piperutils.FileUtils, commonPipelineEnvironment *kanikoExecuteCommonPipelineEnvironment) error {
|
||||
func runKaniko(dockerFilepath string, buildOptions []string, readDigest bool, execRunner command.ExecRunner, fileUtils piperutils.FileUtils, commonPipelineEnvironment *kanikoExecuteCommonPipelineEnvironment) error {
|
||||
cwd, err := fileUtils.Getwd()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get current working directory: %w", err)
|
||||
}
|
||||
|
||||
kanikoOpts := []string{"--dockerfile", dockerFilepath, "--context", cwd, "--reproducible"}
|
||||
kanikoOpts = append(kanikoOpts, buildOptions...)
|
||||
|
||||
tmpDir, err := fileUtils.TempDir("", "*-kanikoExecute")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create tmp dir for kanikoExecute: %w", err)
|
||||
@ -222,8 +225,9 @@ func runKaniko(dockerFilepath string, buildOptions []string, execRunner command.
|
||||
|
||||
digestFilePath := fmt.Sprintf("%s/digest.txt", tmpDir)
|
||||
|
||||
kanikoOpts := []string{"--dockerfile", dockerFilepath, "--context", cwd, "--reproducible", "--digest-file", digestFilePath}
|
||||
kanikoOpts = append(kanikoOpts, buildOptions...)
|
||||
if readDigest {
|
||||
kanikoOpts = append(kanikoOpts, "--digest-file", digestFilePath)
|
||||
}
|
||||
|
||||
err = execRunner.RunExecutable("/kaniko/executor", kanikoOpts...)
|
||||
if err != nil {
|
||||
@ -244,8 +248,6 @@ func runKaniko(dockerFilepath string, buildOptions []string, execRunner command.
|
||||
|
||||
commonPipelineEnvironment.container.imageDigest = string(digestStr)
|
||||
commonPipelineEnvironment.container.imageDigests = append(commonPipelineEnvironment.container.imageDigests, digestStr)
|
||||
} else {
|
||||
log.Entry().Warn("couldn't resolve image digest")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -32,6 +32,7 @@ type kanikoExecuteOptions struct {
|
||||
DockerConfigJSON string `json:"dockerConfigJSON,omitempty"`
|
||||
DockerfilePath string `json:"dockerfilePath,omitempty"`
|
||||
TargetArchitectures []string `json:"targetArchitectures,omitempty"`
|
||||
ReadImageDigest bool `json:"readImageDigest,omitempty"`
|
||||
}
|
||||
|
||||
type kanikoExecuteCommonPipelineEnvironment struct {
|
||||
@ -182,7 +183,7 @@ You can activate multiple builds using the parameters
|
||||
}
|
||||
|
||||
func addKanikoExecuteFlags(cmd *cobra.Command, stepConfig *kanikoExecuteOptions) {
|
||||
cmd.Flags().StringSliceVar(&stepConfig.BuildOptions, "buildOptions", []string{`--skip-tls-verify-pull`, `--ignore-path=/`}, "Defines a list of build options for the [kaniko](https://github.com/GoogleContainerTools/kaniko) build.")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.BuildOptions, "buildOptions", []string{`--skip-tls-verify-pull`, `--ignore-path=/busybox`}, "Defines a list of build options for the [kaniko](https://github.com/GoogleContainerTools/kaniko) build.")
|
||||
cmd.Flags().StringVar(&stepConfig.BuildSettingsInfo, "buildSettingsInfo", os.Getenv("PIPER_buildSettingsInfo"), "Build settings info is typically filled by the step automatically to create information about the build settings that were used during the mta build. This information is typically used for compliance related processes.")
|
||||
cmd.Flags().BoolVar(&stepConfig.ContainerMultiImageBuild, "containerMultiImageBuild", false, "Defines if multiple containers should be build. Dockerfiles are used using the pattern **/Dockerfile*. Excludes can be defined via [`containerMultiImageBuildExcludes`](#containermultiimagebuildexscludes).")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.ContainerMultiImageBuildExcludes, "containerMultiImageBuildExcludes", []string{}, "Defines a list of Dockerfile paths to exclude from the build when using [`containerMultiImageBuild`](#containermultiimagebuild).")
|
||||
@ -196,6 +197,7 @@ func addKanikoExecuteFlags(cmd *cobra.Command, stepConfig *kanikoExecuteOptions)
|
||||
cmd.Flags().StringVar(&stepConfig.DockerConfigJSON, "dockerConfigJSON", os.Getenv("PIPER_dockerConfigJSON"), "Path to the file `.docker/config.json` - this is typically provided by your CI/CD system. You can find more details about the Docker credentials in the [Docker documentation](https://docs.docker.com/engine/reference/commandline/login/).")
|
||||
cmd.Flags().StringVar(&stepConfig.DockerfilePath, "dockerfilePath", `Dockerfile`, "Defines the location of the Dockerfile relative to the Jenkins workspace.")
|
||||
cmd.Flags().StringSliceVar(&stepConfig.TargetArchitectures, "targetArchitectures", []string{``}, "Defines the target architectures for which the build should run using OS and architecture separated by a comma. (EXPERIMENTAL)")
|
||||
cmd.Flags().BoolVar(&stepConfig.ReadImageDigest, "readImageDigest", false, "")
|
||||
|
||||
}
|
||||
|
||||
@ -220,7 +222,7 @@ func kanikoExecuteMetadata() config.StepData {
|
||||
Type: "[]string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Default: []string{`--skip-tls-verify-pull`, `--ignore-path=/`},
|
||||
Default: []string{`--skip-tls-verify-pull`, `--ignore-path=/busybox`},
|
||||
},
|
||||
{
|
||||
Name: "buildSettingsInfo",
|
||||
@ -370,6 +372,15 @@ func kanikoExecuteMetadata() config.StepData {
|
||||
Aliases: []config.Alias{},
|
||||
Default: []string{``},
|
||||
},
|
||||
{
|
||||
Name: "readImageDigest",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"STEPS", "STAGES", "PARAMETERS"},
|
||||
Type: "bool",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
Default: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
Containers: []config.Container{
|
||||
|
@ -62,6 +62,56 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
runner := &mock.ExecMockRunner{}
|
||||
commonPipelineEnvironment := kanikoExecuteCommonPipelineEnvironment{}
|
||||
|
||||
certClient := &kanikoMockClient{
|
||||
responseBody: "testCert",
|
||||
}
|
||||
fileUtils := &mock.FilesMock{}
|
||||
fileUtils.AddFile("path/to/docker/config.json", []byte(`{"auths":{"custom":"test"}}`))
|
||||
fileUtils.AddFile("/kaniko/ssl/certs/ca-certificates.crt", []byte(``))
|
||||
|
||||
err := runKanikoExecute(config, &telemetry.CustomData{}, &commonPipelineEnvironment, runner, certClient, fileUtils)
|
||||
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "rm", runner.Calls[0].Exec)
|
||||
assert.Equal(t, []string{"-f", "/kaniko/.docker/config.json"}, runner.Calls[0].Params)
|
||||
|
||||
assert.Equal(t, config.CustomTLSCertificateLinks, certClient.urlsCalled)
|
||||
c, err := fileUtils.FileRead("/kaniko/.docker/config.json")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, `{"auths":{"custom":"test"}}`, string(c))
|
||||
|
||||
assert.Equal(t, "/kaniko/executor", runner.Calls[1].Exec)
|
||||
cwd, _ := fileUtils.Getwd()
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--skip-tls-verify-pull", "--destination", "myImage:tag"}, runner.Calls[1].Params)
|
||||
|
||||
assert.Contains(t, commonPipelineEnvironment.custom.buildSettingsInfo, `"mavenExecuteBuild":[{"dockerImage":"maven"}]`)
|
||||
assert.Contains(t, commonPipelineEnvironment.custom.buildSettingsInfo, `"kanikoExecute":[{"dockerImage":"gcr.io/kaniko-project/executor:debug"}]`)
|
||||
|
||||
assert.Equal(t, "myImage:tag", commonPipelineEnvironment.container.imageNameTag)
|
||||
assert.Equal(t, "https://index.docker.io", commonPipelineEnvironment.container.registryURL)
|
||||
assert.Equal(t, []string{"myImage"}, commonPipelineEnvironment.container.imageNames)
|
||||
assert.Equal(t, []string{"myImage:tag"}, commonPipelineEnvironment.container.imageNameTags)
|
||||
|
||||
assert.Equal(t, "", commonPipelineEnvironment.container.imageDigest)
|
||||
assert.Empty(t, commonPipelineEnvironment.container.imageDigests)
|
||||
})
|
||||
|
||||
t.Run("success case - pass image digest to cpe if activated", func(t *testing.T) {
|
||||
config := &kanikoExecuteOptions{
|
||||
BuildOptions: []string{"--skip-tls-verify-pull"},
|
||||
ContainerImage: "myImage:tag",
|
||||
ContainerPreparationCommand: "rm -f /kaniko/.docker/config.json",
|
||||
CustomTLSCertificateLinks: []string{"https://test.url/cert.crt"},
|
||||
DockerfilePath: "Dockerfile",
|
||||
DockerConfigJSON: "path/to/docker/config.json",
|
||||
BuildSettingsInfo: `{"mavenExecuteBuild":[{"dockerImage":"maven"}]}`,
|
||||
ReadImageDigest: true,
|
||||
}
|
||||
|
||||
runner := &mock.ExecMockRunner{}
|
||||
commonPipelineEnvironment := kanikoExecuteCommonPipelineEnvironment{}
|
||||
|
||||
certClient := &kanikoMockClient{
|
||||
responseBody: "testCert",
|
||||
}
|
||||
@ -84,7 +134,7 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
|
||||
assert.Equal(t, "/kaniko/executor", runner.Calls[1].Exec)
|
||||
cwd, _ := fileUtils.Getwd()
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--skip-tls-verify-pull", "--destination", "myImage:tag"}, runner.Calls[1].Params)
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--skip-tls-verify-pull", "--destination", "myImage:tag", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt"}, runner.Calls[1].Params)
|
||||
|
||||
assert.Contains(t, commonPipelineEnvironment.custom.buildSettingsInfo, `"mavenExecuteBuild":[{"dockerImage":"maven"}]`)
|
||||
assert.Contains(t, commonPipelineEnvironment.custom.buildSettingsInfo, `"kanikoExecute":[{"dockerImage":"gcr.io/kaniko-project/executor:debug"}]`)
|
||||
@ -119,7 +169,6 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
fileUtils := &mock.FilesMock{}
|
||||
fileUtils.AddFile("path/to/docker/config.json", []byte(`{"auths":{"custom":"test"}}`))
|
||||
fileUtils.AddFile("/kaniko/ssl/certs/ca-certificates.crt", []byte(``))
|
||||
fileUtils.AddFile("/tmp/*-kanikoExecutetest/digest.txt", []byte(`sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0`))
|
||||
|
||||
err := runKanikoExecute(config, &telemetry.CustomData{}, &commonPipelineEnvironment, runner, certClient, fileUtils)
|
||||
|
||||
@ -135,15 +184,15 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
|
||||
assert.Equal(t, "/kaniko/executor", runner.Calls[1].Exec)
|
||||
cwd, _ := fileUtils.Getwd()
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--skip-tls-verify-pull", "--destination", "my.registry.com:50000/myImage:1.2.3-a-x"}, runner.Calls[1].Params)
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--skip-tls-verify-pull", "--destination", "my.registry.com:50000/myImage:1.2.3-a-x"}, runner.Calls[1].Params)
|
||||
|
||||
assert.Equal(t, "myImage:1.2.3-a-x", commonPipelineEnvironment.container.imageNameTag)
|
||||
assert.Equal(t, "https://my.registry.com:50000", commonPipelineEnvironment.container.registryURL)
|
||||
assert.Equal(t, []string{"myImage"}, commonPipelineEnvironment.container.imageNames)
|
||||
assert.Equal(t, []string{"myImage:1.2.3-a-x"}, commonPipelineEnvironment.container.imageNameTags)
|
||||
|
||||
assert.Equal(t, "sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0", commonPipelineEnvironment.container.imageDigest)
|
||||
assert.Equal(t, []string{"sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0"}, commonPipelineEnvironment.container.imageDigests)
|
||||
assert.Equal(t, "", commonPipelineEnvironment.container.imageDigest)
|
||||
assert.Empty(t, commonPipelineEnvironment.container.imageDigests)
|
||||
})
|
||||
|
||||
t.Run("success case - image params with custom destination", func(t *testing.T) {
|
||||
@ -164,7 +213,6 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
fileUtils := &mock.FilesMock{}
|
||||
fileUtils.AddFile("path/to/docker/config.json", []byte(`{"auths":{"custom":"test"}}`))
|
||||
fileUtils.AddFile("/kaniko/ssl/certs/ca-certificates.crt", []byte(``))
|
||||
fileUtils.AddFile("/tmp/*-kanikoExecutetest/digest.txt", []byte(`sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0`))
|
||||
|
||||
err := runKanikoExecute(config, &telemetry.CustomData{}, &commonPipelineEnvironment, runner, certClient, fileUtils)
|
||||
|
||||
@ -180,15 +228,15 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
|
||||
assert.Equal(t, "/kaniko/executor", runner.Calls[1].Exec)
|
||||
cwd, _ := fileUtils.Getwd()
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--skip-tls-verify-pull", "--destination", "my.other.registry.com:50000/myImage:3.2.1-a-x"}, runner.Calls[1].Params)
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--skip-tls-verify-pull", "--destination", "my.other.registry.com:50000/myImage:3.2.1-a-x"}, runner.Calls[1].Params)
|
||||
|
||||
assert.Equal(t, "myImage:3.2.1-a-x", commonPipelineEnvironment.container.imageNameTag)
|
||||
assert.Equal(t, "https://my.other.registry.com:50000", commonPipelineEnvironment.container.registryURL)
|
||||
assert.Equal(t, []string{"myImage"}, commonPipelineEnvironment.container.imageNames)
|
||||
assert.Equal(t, []string{"myImage:3.2.1-a-x"}, commonPipelineEnvironment.container.imageNameTags)
|
||||
|
||||
assert.Equal(t, "sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0", commonPipelineEnvironment.container.imageDigest)
|
||||
assert.Equal(t, []string{"sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0"}, commonPipelineEnvironment.container.imageDigests)
|
||||
assert.Equal(t, "", commonPipelineEnvironment.container.imageDigest)
|
||||
assert.Empty(t, []string{}, commonPipelineEnvironment.container.imageDigests)
|
||||
})
|
||||
|
||||
t.Run("no error case - when cert update skipped", func(t *testing.T) {
|
||||
@ -210,7 +258,6 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
fileUtils := &mock.FilesMock{}
|
||||
fileUtils.AddFile("path/to/docker/config.json", []byte(``))
|
||||
fileUtils.FileReadErrors = map[string]error{"/kaniko/ssl/certs/ca-certificates.crt": fmt.Errorf("read error")}
|
||||
fileUtils.AddFile("/tmp/*-kanikoExecutetest/digest.txt", []byte(`sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0`))
|
||||
|
||||
err := runKanikoExecute(config, &telemetry.CustomData{}, &commonPipelineEnvironment, runner, certClient, fileUtils)
|
||||
|
||||
@ -233,7 +280,6 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
}
|
||||
fileUtils := &mock.FilesMock{}
|
||||
fileUtils.AddFile("/kaniko/ssl/certs/ca-certificates.crt", []byte(``))
|
||||
fileUtils.AddFile("/tmp/*-kanikoExecutetest/digest.txt", []byte(`sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0`))
|
||||
|
||||
err := runKanikoExecute(config, &telemetry.CustomData{}, &commonPipelineEnvironment, runner, certClient, fileUtils)
|
||||
|
||||
@ -244,7 +290,7 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
assert.Equal(t, `{"auths":{}}`, string(c))
|
||||
|
||||
cwd, _ := fileUtils.Getwd()
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--skip-tls-verify-pull", "--no-push"}, runner.Calls[1].Params)
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--skip-tls-verify-pull", "--no-push"}, runner.Calls[1].Params)
|
||||
})
|
||||
|
||||
t.Run("success case - backward compatibility", func(t *testing.T) {
|
||||
@ -266,13 +312,12 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
fileUtils := &mock.FilesMock{}
|
||||
fileUtils.AddFile("path/to/docker/config.json", []byte(`{"auths":{"custom":"test"}}`))
|
||||
fileUtils.AddFile("/kaniko/ssl/certs/ca-certificates.crt", []byte(``))
|
||||
fileUtils.AddFile("/tmp/*-kanikoExecutetest/digest.txt", []byte(`sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0`))
|
||||
|
||||
err := runKanikoExecute(config, &telemetry.CustomData{}, &commonPipelineEnvironment, runner, certClient, fileUtils)
|
||||
|
||||
assert.NoError(t, err)
|
||||
cwd, _ := fileUtils.Getwd()
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--skip-tls-verify-pull", "--destination", "myImage:tag"}, runner.Calls[1].Params)
|
||||
assert.Equal(t, []string{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--skip-tls-verify-pull", "--destination", "myImage:tag"}, runner.Calls[1].Params)
|
||||
})
|
||||
|
||||
t.Run("success case - multi image build with root image", func(t *testing.T) {
|
||||
@ -290,7 +335,6 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
fileUtils.AddFile("Dockerfile", []byte("some content"))
|
||||
fileUtils.AddFile("sub1/Dockerfile", []byte("some content"))
|
||||
fileUtils.AddFile("sub2/Dockerfile", []byte("some content"))
|
||||
fileUtils.AddFile("/tmp/*-kanikoExecutetest/digest.txt", []byte(`sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0`))
|
||||
|
||||
err := runKanikoExecute(config, &telemetry.CustomData{}, &commonPipelineEnvironment, runner, nil, fileUtils)
|
||||
|
||||
@ -303,9 +347,9 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
|
||||
cwd, _ := fileUtils.Getwd()
|
||||
expectedParams := [][]string{
|
||||
{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--destination", "my.registry.com:50000/myImage:myTag"},
|
||||
{"--dockerfile", filepath.Join("sub1", "Dockerfile"), "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--destination", "my.registry.com:50000/myImage-sub1:myTag"},
|
||||
{"--dockerfile", filepath.Join("sub2", "Dockerfile"), "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--destination", "my.registry.com:50000/myImage-sub2:myTag"},
|
||||
{"--dockerfile", "Dockerfile", "--context", cwd, "--reproducible", "--destination", "my.registry.com:50000/myImage:myTag"},
|
||||
{"--dockerfile", filepath.Join("sub1", "Dockerfile"), "--context", cwd, "--reproducible", "--destination", "my.registry.com:50000/myImage-sub1:myTag"},
|
||||
{"--dockerfile", filepath.Join("sub2", "Dockerfile"), "--context", cwd, "--reproducible", "--destination", "my.registry.com:50000/myImage-sub2:myTag"},
|
||||
}
|
||||
// need to go this way since we cannot count on the correct order
|
||||
for _, call := range runner.Calls {
|
||||
@ -328,8 +372,8 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
assert.Contains(t, commonPipelineEnvironment.container.imageNameTags, "myImage-sub1:myTag")
|
||||
assert.Contains(t, commonPipelineEnvironment.container.imageNameTags, "myImage-sub2:myTag")
|
||||
|
||||
assert.Equal(t, commonPipelineEnvironment.container.imageDigest, "sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0")
|
||||
assert.Equal(t, commonPipelineEnvironment.container.imageDigests, []string{"sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0", "sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0", "sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0"})
|
||||
assert.Equal(t, "", commonPipelineEnvironment.container.imageDigest)
|
||||
assert.Empty(t, commonPipelineEnvironment.container.imageDigests)
|
||||
})
|
||||
|
||||
t.Run("success case - multi image build excluding root image", func(t *testing.T) {
|
||||
@ -348,7 +392,6 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
fileUtils.AddFile("Dockerfile", []byte("some content"))
|
||||
fileUtils.AddFile("sub1/Dockerfile", []byte("some content"))
|
||||
fileUtils.AddFile("sub2/Dockerfile", []byte("some content"))
|
||||
fileUtils.AddFile("/tmp/*-kanikoExecutetest/digest.txt", []byte(`sha256:468dd1253cc9f498fc600454bb8af96d880fec3f9f737e7057692adfe9f7d5b0`))
|
||||
|
||||
err := runKanikoExecute(config, &telemetry.CustomData{}, &commonPipelineEnvironment, runner, nil, fileUtils)
|
||||
|
||||
@ -360,8 +403,8 @@ func TestRunKanikoExecute(t *testing.T) {
|
||||
|
||||
cwd, _ := fileUtils.Getwd()
|
||||
expectedParams := [][]string{
|
||||
{"--dockerfile", filepath.Join("sub1", "Dockerfile"), "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--destination", "my.registry.com:50000/myImage-sub1:myTag"},
|
||||
{"--dockerfile", filepath.Join("sub2", "Dockerfile"), "--context", cwd, "--reproducible", "--digest-file", "/tmp/*-kanikoExecutetest/digest.txt", "--destination", "my.registry.com:50000/myImage-sub2:myTag"},
|
||||
{"--dockerfile", filepath.Join("sub1", "Dockerfile"), "--context", cwd, "--reproducible", "--destination", "my.registry.com:50000/myImage-sub1:myTag"},
|
||||
{"--dockerfile", filepath.Join("sub2", "Dockerfile"), "--context", cwd, "--reproducible", "--destination", "my.registry.com:50000/myImage-sub2:myTag"},
|
||||
}
|
||||
// need to go this way since we cannot count on the correct order
|
||||
for _, call := range runner.Calls {
|
||||
|
@ -36,7 +36,7 @@ spec:
|
||||
- --skip-tls-verify-pull
|
||||
# fixing Kaniko issue https://github.com/GoogleContainerTools/kaniko/issues/1586
|
||||
# as per comment https://github.com/GoogleContainerTools/kaniko/issues/1586#issuecomment-945718536
|
||||
- --ignore-path=/
|
||||
- --ignore-path=/busybox
|
||||
- name: buildSettingsInfo
|
||||
type: string
|
||||
description: Build settings info is typically filled by the step automatically to create information about the build settings that were used during the mta build. This information is typically used for compliance related processes.
|
||||
@ -166,6 +166,13 @@ spec:
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
- name: readImageDigest
|
||||
type: bool
|
||||
default: false
|
||||
scope:
|
||||
- STEPS
|
||||
- STAGES
|
||||
- PARAMETERS
|
||||
outputs:
|
||||
resources:
|
||||
- name: commonPipelineEnvironment
|
||||
|
Loading…
x
Reference in New Issue
Block a user