Skip to content

Commit

Permalink
project.toml path can be overriden
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <[email protected]>
  • Loading branch information
dgageot committed May 27, 2020
1 parent 2b699f9 commit 5d0581e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 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 @@ -524,6 +524,12 @@
"[\"key1=value1\", \"key2=value2\", \"key3={{.ENV_VARIABLE}}\"]"
]
},
"projectDescriptor": {
"type": "string",
"description": "path to the toml project descriptor.",
"x-intellij-html-description": "path to the toml project descriptor.",
"default": "project.toml"
},
"runImage": {
"type": "string",
"description": "overrides the stack's default run image.",
Expand All @@ -535,6 +541,7 @@
"runImage",
"env",
"buildpacks",
"projectDescriptor",
"dependencies"
],
"additionalProperties": false,
Expand Down
5 changes: 3 additions & 2 deletions pkg/skaffold/build/buildpacks/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ func buildpacksArtifact(builder, runImage string) *latest.Artifact {
Workspace: ".",
ArtifactType: latest.ArtifactType{
BuildpackArtifact: &latest.BuildpackArtifact{
Builder: builder,
RunImage: runImage,
Builder: builder,
RunImage: runImage,
ProjectDescriptor: "project.toml",
Dependencies: &latest.BuildpackDependencies{
Paths: []string{"."},
},
Expand Down
4 changes: 1 addition & 3 deletions pkg/skaffold/build/buildpacks/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

const projectTOML = "project.toml"

// For testing
var (
runPackBuildFunc = runPackBuild
Expand All @@ -51,7 +49,7 @@ func (b *Builder) build(ctx context.Context, out io.Writer, a *latest.Artifact,
workspace := a.Workspace

// Read `project.toml` if it exists.
path := filepath.Join(a.Workspace, projectTOML)
path := filepath.Join(workspace, artifact.ProjectDescriptor)
projectDescriptor, err := ReadProjectDescriptor(path)
if err != nil && !os.IsNotExist(err) {
return "", fmt.Errorf("failed to read project descriptor %q: %w", path, err)
Expand Down
2 changes: 2 additions & 0 deletions pkg/skaffold/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const (
DefaultPortForwardNamespace = "default"
DefaultPortForwardAddress = "127.0.0.1"

DefaultProjectDescriptor = "project.toml"

LeeroyAppResponse = "leeroooooy app!!\n"
)

Expand Down
3 changes: 3 additions & 0 deletions pkg/skaffold/schema/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ func setCustomArtifactDefaults(a *latest.CustomArtifact) {
}

func setBuildpackArtifactDefaults(a *latest.BuildpackArtifact) {
if a.ProjectDescriptor == "" {
a.ProjectDescriptor = constants.DefaultProjectDescriptor
}
if a.Dependencies == nil {
a.Dependencies = &latest.BuildpackDependencies{
Paths: []string{"."},
Expand Down
1 change: 1 addition & 0 deletions pkg/skaffold/schema/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func TestSetDefaults(t *testing.T) {
testutil.CheckDeepEqual(t, "fourth", cfg.Build.Artifacts[3].ImageName)
testutil.CheckDeepEqual(t, []string{"."}, cfg.Build.Artifacts[3].BuildpackArtifact.Dependencies.Paths)
testutil.CheckDeepEqual(t, []string(nil), cfg.Build.Artifacts[3].BuildpackArtifact.Dependencies.Ignore)
testutil.CheckDeepEqual(t, "project.toml", cfg.Build.Artifacts[3].BuildpackArtifact.ProjectDescriptor)
testutil.CheckDeepEqual(t, &latest.Auto{}, cfg.Build.Artifacts[3].Sync.Auto)

testutil.CheckDeepEqual(t, "fifth", cfg.Build.Artifacts[4].ImageName)
Expand Down
4 changes: 4 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,10 @@ type BuildpackArtifact struct {
// Order matters.
Buildpacks []string `yaml:"buildpacks,omitempty"`

// ProjectDescriptor is the path to the toml project descriptor.
// Defaults to `project.toml`.
ProjectDescriptor string `yaml:"projectDescriptor,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 5d0581e

Please sign in to comment.