Skip to content

Commit

Permalink
Merge pull request #2197 from buildpacks/fix/warning-project-toml
Browse files Browse the repository at this point in the history
When parsing project.toml, don't warn about unexpected keys that are actually expected
  • Loading branch information
natalieparellano authored Jul 8, 2024
2 parents 0ad4842 + 085b288 commit 2fa3260
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
5 changes: 3 additions & 2 deletions pkg/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ name = "licenses should have either a type or uri defined"

it("should warn when unsupported keys, on tables the project owns, are declared with schema v0.1", func() {
projectToml := `
# try to use some schema 0.2 configuration with 0.1 version - warning message expected
[project]
authors = ["foo", "bar"]
Expand All @@ -427,13 +426,15 @@ foo = "bar"

_, err = ReadProjectDescriptor(tmpProjectToml.Name(), logger)
h.AssertNil(t, err)
h.AssertContains(t, readStdout(), "Warning: The following keys declared in project.toml are not supported in schema version 0.1:\nWarning: - project.authors\nWarning: - io.buildpacks.build.env\nWarning: - io.buildpacks.build.env.name\nWarning: - io.buildpacks.build.env.value\nWarning: The above keys will be ignored. If this is not intentional, try updating your schema version.\n")
h.AssertContains(t, readStdout(), "Warning: The following keys declared in project.toml are not supported in schema version 0.1:\nWarning: - io.buildpacks.build.env\nWarning: - io.buildpacks.build.env.name\nWarning: - io.buildpacks.build.env.value\nWarning: The above keys will be ignored. If this is not intentional, try updating your schema version.\n")
})

it("should warn when unsupported keys, on tables the project owns, are declared with schema v0.2", func() {
projectToml := `
[_]
schema-version = "0.2"
id = "foo"
version = "bar"
# typo in a key under valid table - warning message expected
versions = "0.1"
Expand Down
11 changes: 7 additions & 4 deletions pkg/project/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ type Build struct {
}

type Project struct {
Name string `toml:"name"`
Version string `toml:"version"`
SourceURL string `toml:"source-url"`
Licenses []License `toml:"licenses"`
ID string `toml:"id"`
Name string `toml:"name"`
Version string `toml:"version"`
Authors []string `toml:"authors"`
DocumentationURL string `toml:"documentation-url"`
SourceURL string `toml:"source-url"`
Licenses []License `toml:"licenses"`
}

type License struct {
Expand Down
13 changes: 9 additions & 4 deletions pkg/project/v02/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ type Env struct {
}

type Project struct {
Name string `toml:"name"`
Licenses []types.License `toml:"licenses"`
Metadata map[string]interface{} `toml:"metadata"`
SchemaVersion string `toml:"schema-version"`
SchemaVersion string `toml:"schema-version"`
ID string `toml:"id"`
Name string `toml:"name"`
Version string `toml:"version"`
Authors []string `toml:"authors"`
Licenses []types.License `toml:"licenses"`
DocumentationURL string `toml:"documentation-url"`
SourceURL string `toml:"source-url"`
Metadata map[string]interface{} `toml:"metadata"`
}

type IO struct {
Expand Down

0 comments on commit 2fa3260

Please sign in to comment.