Skip to content

Commit

Permalink
make initContainer in localDir type of kaniko build param (#1727)
Browse files Browse the repository at this point in the history
make initContainer in localDir type of kaniko build param
  • Loading branch information
venkatk-25 authored and balopat committed Mar 7, 2019
1 parent 5534544 commit 7f52077
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
11 changes: 11 additions & 0 deletions docs/content/en/schemas/v1beta6.json
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,17 @@
"x-intellij-html-description": "<em>beta</em> describes how to do a build on the local docker daemon and optionally push to a repository."
},
"LocalDir": {
"properties": {
"initImage": {
"type": "string",
"description": "image used to run init container which mounts kaniko context.",
"x-intellij-html-description": "image used to run init container which mounts kaniko context."
}
},
"preferredOrder": [
"initImage"
],
"additionalProperties": false,
"description": "configures how Kaniko mounts sources directly via an `emptyDir` volume.",
"x-intellij-html-description": "configures how Kaniko mounts sources directly via an <code>emptyDir</code> volume."
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/kaniko/sources/localdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (g *LocalDir) Pod(args []string) *v1.Pod {
// Generate the init container, which will run until the /tmp/complete file is created
ic := v1.Container{
Name: initContainer,
Image: constants.DefaultBusyboxImage,
Image: g.cfg.BuildContext.LocalDir.InitImage,
Command: []string{"sh", "-c", "while [ ! -f /tmp/complete ]; do sleep 1; done"},
VolumeMounts: []v1.VolumeMount{vm},
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/skaffold/schema/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Set(c *latest.SkaffoldPipeline) error {
if err := withKanikoConfig(c,
setDefaultKanikoTimeout,
setDefaultKanikoImage,
setDefaultKanikoInitImage,
setDefaultKanikoNamespace,
setDefaultKanikoSecret,
setDefaultKanikoBuildContext,
Expand Down Expand Up @@ -216,6 +217,14 @@ func setDefaultKanikoTimeout(kaniko *latest.KanikoBuild) error {
return nil
}

func setDefaultKanikoInitImage(kaniko *latest.KanikoBuild) error {
if kaniko.BuildContext != nil && kaniko.BuildContext.LocalDir != nil {
localDir := kaniko.BuildContext.LocalDir
localDir.InitImage = valueOrDefault(localDir.InitImage, constants.DefaultBusyboxImage)
}
return nil
}

func setDefaultKanikoImage(kaniko *latest.KanikoBuild) error {
kaniko.Image = valueOrDefault(kaniko.Image, constants.DefaultKanikoImage)
return nil
Expand Down
5 changes: 4 additions & 1 deletion pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ type GoogleCloudBuild struct {
}

// LocalDir configures how Kaniko mounts sources directly via an `emptyDir` volume.
type LocalDir struct{}
type LocalDir struct {
// InitImage is the image used to run init container which mounts kaniko context.
InitImage string `yaml:"initImage,omitempty"`
}

// KanikoBuildContext contains the different fields available to specify
// a Kaniko build context.
Expand Down

0 comments on commit 7f52077

Please sign in to comment.