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

When parsing project.toml, don't warn about unexpected keys that are actually expected #2197

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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"`
Comment on lines +36 to +42
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

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"`
Comment on lines +31 to +39
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

type IO struct {
Expand Down
Loading