Skip to content

Commit

Permalink
Fix kaniko default behaviour
Browse files Browse the repository at this point in the history
If buildcontext isn't specified or localdir is specified, return localdir as the source
context. Otherwise, return a GCS bucket. If no value is passed in for
the bucket, one will be inferred from the project ID.
  • Loading branch information
Priya Wadhwa committed Oct 10, 2018
1 parent 9bc2ca6 commit 5f4df39
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/skaffold/build/kaniko/sources/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type BuildContextSource interface {

// Retrieve returns the correct build context based on the config
func Retrieve(cfg *latest.KanikoBuild) (BuildContextSource, error) {
if cfg.BuildContext.LocalDir != nil {
if cfg.BuildContext == nil || cfg.BuildContext.LocalDir != nil {
return &LocalDir{}, nil
}
return &GCSBucket{}, nil
Expand Down
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
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 5f4df39

Please sign in to comment.