Skip to content

Commit

Permalink
Merge pull request GoogleContainerTools#1139 from priyawadhwa/kanikobug
Browse files Browse the repository at this point in the history
Fix kaniko default behaviour
  • Loading branch information
dgageot authored Oct 12, 2018
2 parents 78e4439 + 71622f2 commit 1af9b55
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
12 changes: 6 additions & 6 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ type KanikoBuildContext struct {
// KanikoBuild contains the fields needed to do a on-cluster build using
// the kaniko image
type KanikoBuild struct {
BuildContext KanikoBuildContext `yaml:"buildContext,omitempty"`
PullSecret string `yaml:"pullSecret,omitempty"`
PullSecretName string `yaml:"pullSecretName,omitempty"`
Namespace string `yaml:"namespace,omitempty"`
Timeout string `yaml:"timeout,omitempty"`
Image string `yaml:"image,omitempty"`
BuildContext *KanikoBuildContext `yaml:"buildContext,omitempty"`
PullSecret string `yaml:"pullSecret,omitempty"`
PullSecretName string `yaml:"pullSecretName,omitempty"`
Namespace string `yaml:"namespace,omitempty"`
Timeout string `yaml:"timeout,omitempty"`
Image string `yaml:"image,omitempty"`
}

// TestCase is a struct containing all the specified test
Expand Down
10 changes: 10 additions & 0 deletions pkg/skaffold/schema/latest/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (c *SkaffoldPipeline) SetDefaultValues() error {
setDefaultKanikoImage,
setDefaultKanikoNamespace,
setDefaultKanikoSecret,
setDefaultKanikoBuildContext,
); err != nil {
return err
}
Expand Down Expand Up @@ -173,6 +174,15 @@ func setDefaultKanikoSecret(kaniko *KanikoBuild) error {
return nil
}

func setDefaultKanikoBuildContext(kaniko *KanikoBuild) error {
if kaniko.BuildContext == nil {
kaniko.BuildContext = &KanikoBuildContext{
LocalDir: &LocalDir{},
}
}
return nil
}

func valueOrDefault(v, def string) string {
if v != "" {
return v
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func withGoogleCloudBuild(id string, ops ...func(*latest.BuildConfig)) func(*lat
func withKanikoBuild(bucket, secretName, namespace, secret string, timeout string, ops ...func(*latest.BuildConfig)) func(*latest.SkaffoldPipeline) {
return func(cfg *latest.SkaffoldPipeline) {
b := latest.BuildConfig{BuildType: latest.BuildType{KanikoBuild: &latest.KanikoBuild{
BuildContext: latest.KanikoBuildContext{
BuildContext: &latest.KanikoBuildContext{
GCSBucket: bucket,
},
PullSecretName: secretName,
Expand Down

0 comments on commit 1af9b55

Please sign in to comment.