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

Support specific buildpacks for buildpack artifact #3584

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 10 additions & 0 deletions docs/content/en/schemas/v2alpha3.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,15 @@
"description": "builder image used.",
"x-intellij-html-description": "builder image used."
},
"buildpacks": {
"items": {
"type": "string"
},
"type": "array",
"description": "a list of strings, where each string is a specific buildpack to use with the builder. If you specify buildpacks the builder image automatic detection will be ignored. These buildpacks will be used to build the Image from your source code. Order matters.",
"x-intellij-html-description": "a list of strings, where each string is a specific buildpack to use with the builder. If you specify buildpacks the builder image automatic detection will be ignored. These buildpacks will be used to build the Image from your source code. Order matters.",
"default": "[]"
},
"dependencies": {
"$ref": "#/definitions/BuildpackDependencies",
"description": "file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact.",
Expand Down Expand Up @@ -521,6 +530,7 @@
"builder",
"runImage",
"env",
"buildpacks",
"dependencies"
],
"additionalProperties": false,
Expand Down
19 changes: 19 additions & 0 deletions pkg/skaffold/build/buildpacks/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ func TestBuild(t *testing.T) {
Image: "img:latest",
},
},
{
description: "success with buildpacks",
artifact: &latest.BuildpackArtifact{
Builder: "my/otherBuilder",
RunImage: "my/otherRun",
Buildpacks: []string{"my/buildpack", "my/otherBuildpack"},
Dependencies: defaultBuildpackDependencies(),
},
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",
},
},
{
description: "invalid ref",
artifact: &latest.BuildpackArtifact{
Expand Down
13 changes: 7 additions & 6 deletions pkg/skaffold/build/buildpacks/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ 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, pack.BuildOptions{
AppPath: workspace,
Builder: artifact.Builder,
RunImage: artifact.RunImage,
Env: envMap(env),
Image: latest,
NoPull: alreadyPulled,
AppPath: workspace,
Builder: artifact.Builder,
RunImage: artifact.RunImage,
Buildpacks: artifact.Buildpacks,
Env: envMap(env),
Image: latest,
NoPull: alreadyPulled,
}); err != nil {
return "", err
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,11 @@ type BuildpackArtifact struct {
// For example: `["key1=value1", "key2=value2", "key3={{.ENV_VARIABLE}}"]`.
Env []string `yaml:"env,omitempty"`

// Buildpacks is a list of strings, where each string is a specific buildpack to use with the builder.
// If you specify buildpacks the builder image automatic detection will be ignored. These buildpacks will be used to build the Image from your source code.
// Order matters.
Buildpacks []string `yaml:"buildpacks,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