Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable auto sync mode for Buildpacks artifacts #4656

Merged
merged 1 commit into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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