Skip to content

Commit

Permalink
[buildpacks] Support trusted builders
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <[email protected]>
  • Loading branch information
dgageot committed May 28, 2020
1 parent f30af02 commit 4fb92e1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
7 changes: 7 additions & 0 deletions docs/content/en/schemas/v2beta5.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,20 @@
"type": "string",
"description": "overrides the stack's default run image.",
"x-intellij-html-description": "overrides the stack's default run image."
},
"trustBuilder": {
"type": "boolean",
"description": "indicates that the builder should be trusted.",
"x-intellij-html-description": "indicates that the builder should be trusted.",
"default": "false"
}
},
"preferredOrder": [
"builder",
"runImage",
"env",
"buildpacks",
"trustBuilder",
"dependencies"
],
"additionalProperties": false,
Expand Down
19 changes: 12 additions & 7 deletions pkg/skaffold/build/buildpacks/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ func TestBuild(t *testing.T) {
},
{
description: "success with buildpacks",
artifact: withBuildpacks([]string{"my/buildpack", "my/otherBuildpack"}, buildpacksArtifact("my/otherBuilder", "my/otherRun")),
artifact: withTrustedBuilder(withBuildpacks([]string{"my/buildpack", "my/otherBuildpack"}, buildpacksArtifact("my/otherBuilder", "my/otherRun"))),
tag: "img:tag",
api: &testutil.FakeAPIClient{},
expectedOptions: &pack.BuildOptions{
AppPath: ".",
Builder: "my/otherBuilder",
RunImage: "my/otherRun",
Buildpacks: []string{"my/buildpack", "my/otherBuildpack"},
Env: map[string]string{},
Image: "img:latest",
AppPath: ".",
Builder: "my/otherBuilder",
RunImage: "my/otherRun",
Buildpacks: []string{"my/buildpack", "my/otherBuildpack"},
TrustBuilder: true,
Env: map[string]string{},
Image: "img:latest",
},
},
{
Expand Down Expand Up @@ -257,6 +258,10 @@ func withSync(sync *latest.Sync, artifact *latest.Artifact) *latest.Artifact {
return artifact
}

func withTrustedBuilder(artifact *latest.Artifact) *latest.Artifact {
artifact.BuildpackArtifact.TrustBuilder = true
return artifact
}
func withBuildpacks(buildpacks []string, artifact *latest.Artifact) *latest.Artifact {
artifact.BuildpackArtifact.Buildpacks = buildpacks
return artifact
Expand Down
15 changes: 8 additions & 7 deletions pkg/skaffold/build/buildpacks/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ func (b *Builder) build(ctx context.Context, out io.Writer, a *latest.Artifact,
alreadyPulled := images.AreAlreadyPulled(artifact.Builder, artifact.RunImage)

if err := runPackBuildFunc(ctx, out, b.localDocker, pack.BuildOptions{
AppPath: workspace,
Builder: artifact.Builder,
RunImage: artifact.RunImage,
Buildpacks: buildpacks,
Env: env,
Image: latest,
NoPull: alreadyPulled,
AppPath: workspace,
Builder: artifact.Builder,
RunImage: artifact.RunImage,
Buildpacks: buildpacks,
Env: env,
Image: latest,
NoPull: alreadyPulled,
TrustBuilder: artifact.TrustBuilder,
// TODO(dgageot): Support project.toml include/exclude.
// FileFilter: func(string) bool { return true },
}); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,9 @@ type BuildpackArtifact struct {
// Order matters.
Buildpacks []string `yaml:"buildpacks,omitempty"`

// TrustBuilder indicates that the builder should be trusted.
TrustBuilder bool `yaml:"trustBuilder,omitempty"`

// Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact.
Dependencies *BuildpackDependencies `yaml:"dependencies,omitempty"`
}
Expand Down

0 comments on commit 4fb92e1

Please sign in to comment.