Skip to content

Commit f7102fb

Browse files
committed
project.toml path can be overriden
Signed-off-by: David Gageot <[email protected]>
1 parent 012dcde commit f7102fb

File tree

7 files changed

+21
-5
lines changed

7 files changed

+21
-5
lines changed

docs/content/en/schemas/v2beta5.json

+7
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,12 @@
524524
"[\"key1=value1\", \"key2=value2\", \"key3={{.ENV_VARIABLE}}\"]"
525525
]
526526
},
527+
"projectDescriptor": {
528+
"type": "string",
529+
"description": "path to the toml project descriptor.",
530+
"x-intellij-html-description": "path to the toml project descriptor.",
531+
"default": "project.toml"
532+
},
527533
"runImage": {
528534
"type": "string",
529535
"description": "overrides the stack's default run image.",
@@ -535,6 +541,7 @@
535541
"runImage",
536542
"env",
537543
"buildpacks",
544+
"projectDescriptor",
538545
"dependencies"
539546
],
540547
"additionalProperties": false,

pkg/skaffold/build/buildpacks/build_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ func buildpacksArtifact(builder, runImage string) *latest.Artifact {
237237
Workspace: ".",
238238
ArtifactType: latest.ArtifactType{
239239
BuildpackArtifact: &latest.BuildpackArtifact{
240-
Builder: builder,
241-
RunImage: runImage,
240+
Builder: builder,
241+
RunImage: runImage,
242+
ProjectDescriptor: "project.toml",
242243
Dependencies: &latest.BuildpackDependencies{
243244
Paths: []string{"."},
244245
},

pkg/skaffold/build/buildpacks/lifecycle.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import (
3434
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
3535
)
3636

37-
const projectTOML = "project.toml"
38-
3937
// For testing
4038
var (
4139
runPackBuildFunc = runPackBuild
@@ -51,7 +49,7 @@ func (b *Builder) build(ctx context.Context, out io.Writer, a *latest.Artifact,
5149
workspace := a.Workspace
5250

5351
// Read `project.toml` if it exists.
54-
path := filepath.Join(a.Workspace, projectTOML)
52+
path := filepath.Join(workspace, artifact.ProjectDescriptor)
5553
projectDescriptor, err := ReadProjectDescriptor(path)
5654
if err != nil && !os.IsNotExist(err) {
5755
return "", fmt.Errorf("failed to read project descriptor %q: %w", path, err)

pkg/skaffold/constants/constants.go

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ const (
6464
DefaultPortForwardNamespace = "default"
6565
DefaultPortForwardAddress = "127.0.0.1"
6666

67+
DefaultProjectDescriptor = "project.toml"
68+
6769
LeeroyAppResponse = "leeroooooy app!!\n"
6870
)
6971

pkg/skaffold/schema/defaults/defaults.go

+3
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ func setCustomArtifactDefaults(a *latest.CustomArtifact) {
200200
}
201201

202202
func setBuildpackArtifactDefaults(a *latest.BuildpackArtifact) {
203+
if a.ProjectDescriptor == "" {
204+
a.ProjectDescriptor = constants.DefaultProjectDescriptor
205+
}
203206
if a.Dependencies == nil {
204207
a.Dependencies = &latest.BuildpackDependencies{
205208
Paths: []string{"."},

pkg/skaffold/schema/defaults/defaults_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func TestSetDefaults(t *testing.T) {
8989
testutil.CheckDeepEqual(t, "fourth", cfg.Build.Artifacts[3].ImageName)
9090
testutil.CheckDeepEqual(t, []string{"."}, cfg.Build.Artifacts[3].BuildpackArtifact.Dependencies.Paths)
9191
testutil.CheckDeepEqual(t, []string(nil), cfg.Build.Artifacts[3].BuildpackArtifact.Dependencies.Ignore)
92+
testutil.CheckDeepEqual(t, "project.toml", cfg.Build.Artifacts[3].BuildpackArtifact.ProjectDescriptor)
9293
testutil.CheckDeepEqual(t, &latest.Auto{}, cfg.Build.Artifacts[3].Sync.Auto)
9394

9495
testutil.CheckDeepEqual(t, "fifth", cfg.Build.Artifacts[4].ImageName)

pkg/skaffold/schema/latest/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,10 @@ type BuildpackArtifact struct {
750750
// Order matters.
751751
Buildpacks []string `yaml:"buildpacks,omitempty"`
752752

753+
// ProjectDescriptor is the path to the toml project descriptor.
754+
// Defaults to `project.toml`.
755+
ProjectDescriptor string `yaml:"projectDescriptor,omitempty"`
756+
753757
// Dependencies are the file dependencies that skaffold should watch for both rebuilding and file syncing for this artifact.
754758
Dependencies *BuildpackDependencies `yaml:"dependencies,omitempty"`
755759
}

0 commit comments

Comments
 (0)