Skip to content

Commit

Permalink
feat(kanikoExecute): add dockerfilePath param to multipleImages (#4569)
Browse files Browse the repository at this point in the history
* add containerDockerfilePath param to multipleImages

* rename ContainerDockerfilePath param to DockerfilePath

* Fix trailing spaces

---------

Co-authored-by: Egor Balakin <[email protected]>
Co-authored-by: Vyacheslav Starostin <[email protected]>
  • Loading branch information
3 people authored Sep 28, 2023
1 parent b34ea9e commit 4dec3c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cmd/kanikoExecute.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,13 @@ func runKanikoExecute(config *kanikoExecuteOptions, telemetryData *telemetry.Cus
"--context-sub-path", entry.ContextSubPath,
"--destination", fmt.Sprintf("%v/%v", containerRegistry, containerImageNameAndTag),
)
if err = runKaniko(config.DockerfilePath, buildOptions, config.ReadImageDigest, execRunner, fileUtils, commonPipelineEnvironment); err != nil {

dockerfilePath := config.DockerfilePath
if entry.DockerfilePath != "" {
dockerfilePath = entry.DockerfilePath
}

if err = runKaniko(dockerfilePath, buildOptions, config.ReadImageDigest, execRunner, fileUtils, commonPipelineEnvironment); err != nil {
return fmt.Errorf("multipleImages: failed to build image '%v' using '%v': %w", entry.ContainerImageName, config.DockerfilePath, err)
}

Expand All @@ -251,7 +257,13 @@ func runKanikoExecute(config *kanikoExecuteOptions, telemetryData *telemetry.Cus
"--context-sub-path", entry.ContextSubPath,
"--destination", entry.ContainerImage,
)
if err = runKaniko(config.DockerfilePath, buildOptions, config.ReadImageDigest, execRunner, fileUtils, commonPipelineEnvironment); err != nil {

dockerfilePath := config.DockerfilePath
if entry.DockerfilePath != "" {
dockerfilePath = entry.DockerfilePath
}

if err = runKaniko(dockerfilePath, buildOptions, config.ReadImageDigest, execRunner, fileUtils, commonPipelineEnvironment); err != nil {
return fmt.Errorf("multipleImages: failed to build image '%v' using '%v': %w", containerImageName, config.DockerfilePath, err)
}

Expand Down Expand Up @@ -405,6 +417,7 @@ func runKaniko(dockerFilepath string, buildOptions []string, readDigest bool, ex

type multipleImageConf struct {
ContextSubPath string `json:"contextSubPath,omitempty"`
DockerfilePath string `json:"dockerfilePath,omitempty"`
ContainerImageName string `json:"containerImageName,omitempty"`
ContainerImageTag string `json:"containerImageTag,omitempty"`
ContainerImage string `json:"containerImage,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions resources/metadata/kanikoExecute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ spec:
Array keys:
contextSubPath - Set a context subpath.
dockerfilePath - Dockerfile path (optional). If empty, root will be used.
containerImageName - Name of the container which will be built.
containerImageTag - Tag of the container which will be built. If empty - root containerImageTag will be used.
containerImage - Defines the full name of the Docker image to be created including registry.
Expand Down

0 comments on commit 4dec3c3

Please sign in to comment.