Skip to content

Commit

Permalink
Enable auto sync mode for Buildpacks artifacts (#4656)
Browse files Browse the repository at this point in the history
  • Loading branch information
briandealwis authored Aug 13, 2020
1 parent a33102f commit 6994b45
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
8 changes: 6 additions & 2 deletions docs/content/en/docs/pipeline-stages/filesync.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Multiple types of sync are supported by Skaffold:
This is supported by docker and kaniko artifacts and also for custom artifacts that declare a
dependency on a Dockerfile.

+ `auto`: Skaffold automatically configures the sync. This is only supported by Jib and Buildpacks artifacts.
+ `auto`: Skaffold automatically configures the sync. This mode is only supported by Jib and Buildpacks artifacts.
Auto sync mode is enabled by default for Buildpacks artifacts.

### Manual sync mode

Expand Down Expand Up @@ -77,11 +78,14 @@ File deletion will always cause a complete rebuild.

### Auto sync mode

In auto sync mode, Skaffold automatically generates sync rules for known file types. Changes to other file types will
result in a complete rebuild.

#### Buildpacks

Skaffold requires special collaboration from the Buildpacks for the `auto` sync to work.
The [gcr.io/buildpacks/builder:v1](https://github.com/GoogleCloudPlatform/buildpacks) supports Skaffold
out of the box, currently for Go and NodeJS.
out of the box, currently for Go, NodeJS, and Java.

Cloud Native Buildpacks set a `io.buildpacks.build.metadata` label on the images they create.
This labels points to json description of the [Bill-of-Materials, aka BOM](https://github.com/buildpacks/spec/blob/master/buildpack.md#bill-of-materials-toml) of the build.
Expand Down
2 changes: 0 additions & 2 deletions integration/examples/buildpacks-java/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ build:
builder: "gcr.io/buildpacks/builder:v1"
env:
- GOOGLE_RUNTIME_VERSION=8
sync:
auto: {}
profiles:
- name: gcb
build:
Expand Down
2 changes: 0 additions & 2 deletions integration/examples/buildpacks-node/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ build:
- image: skaffold-buildpacks-node
buildpacks:
builder: "gcr.io/buildpacks/builder:v1"
sync:
auto: {}
2 changes: 0 additions & 2 deletions integration/examples/buildpacks/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ build:
builder: "gcr.io/buildpacks/builder:v1"
env:
- GOPROXY={{.GOPROXY}}
sync:
auto: {}
profiles:
- name: gcb
build:
Expand Down
2 changes: 2 additions & 0 deletions pkg/skaffold/schema/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ func setDefaultSync(a *latest.Artifact) {
a.Sync.Infer = []string{"**/*"}
}
}
} else if a.BuildpackArtifact != nil {
a.Sync = &latest.Sync{Auto: &latest.Auto{}}
}
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/skaffold/schema/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func TestSetDefaults(t *testing.T) {
},
Sync: &latest.Sync{},
},
{
ImageName: "sixth",
ArtifactType: latest.ArtifactType{
BuildpackArtifact: &latest.BuildpackArtifact{},
},
},
},
},
},
Expand Down Expand Up @@ -94,6 +100,12 @@ func TestSetDefaults(t *testing.T) {

testutil.CheckDeepEqual(t, "fifth", cfg.Build.Artifacts[4].ImageName)
testutil.CheckDeepEqual(t, &latest.Auto{}, cfg.Build.Artifacts[4].Sync.Auto)

testutil.CheckDeepEqual(t, "sixth", cfg.Build.Artifacts[5].ImageName)
testutil.CheckDeepEqual(t, []string{"."}, cfg.Build.Artifacts[5].BuildpackArtifact.Dependencies.Paths)
testutil.CheckDeepEqual(t, []string(nil), cfg.Build.Artifacts[5].BuildpackArtifact.Dependencies.Ignore)
testutil.CheckDeepEqual(t, "project.toml", cfg.Build.Artifacts[5].BuildpackArtifact.ProjectDescriptor)
testutil.CheckDeepEqual(t, &latest.Auto{}, cfg.Build.Artifacts[5].Sync.Auto)
}

func TestSetDefaultsOnCluster(t *testing.T) {
Expand Down

0 comments on commit 6994b45

Please sign in to comment.