-
Notifications
You must be signed in to change notification settings - Fork 309
Set top-level LintConfig
and BreakingConfig
and use for image inputs
#3111
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
Changes from 2 commits
a6a8dac
a657483
1b5e809
4d71dc2
039bd18
2823e3f
c767e16
30e4286
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,13 +76,13 @@ type BufYAMLFile interface { | |
ModuleConfigs() []ModuleConfig | ||
// DefaultLintConfig returns the DefaultLintConfig for the File. | ||
// | ||
// For v1 buf.yaml files, this will be the default v1 lint config. | ||
// For v1 buf.yaml files, there is only ever a single ModuleConfig, so that is returned. | ||
// For v2 buf.yaml files, if a top-level lint config exists, then it will be the top-level | ||
// lint config. Otherwise it is the default v2 lint config. | ||
DefaultLintConfig() LintConfig | ||
// DefaultBreakingConfig returns the DefaultBreakingConfig for the File. | ||
// | ||
// For v1 buf.yaml, this will be the default v1 breaking config. | ||
// For v1 buf.yaml files, there is only ever a single ModuleConfig, so that is returned. | ||
doriable marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// For v2 buf.yaml files, if a top-level breaking config exists, then it will be the top-level | ||
// breaking config. Otherwise it is the default v2 breaking config. | ||
DefaultBreakingConfig() BreakingConfig | ||
|
@@ -301,10 +301,16 @@ func (c *bufYAMLFile) ModuleConfigs() []ModuleConfig { | |
} | ||
|
||
func (c *bufYAMLFile) DefaultLintConfig() LintConfig { | ||
if c.defaultLintConfig == nil { | ||
return c.moduleConfigs[0].LintConfig() | ||
} | ||
return c.defaultLintConfig | ||
} | ||
|
||
func (c *bufYAMLFile) DefaultBreakingConfig() BreakingConfig { | ||
if c.defaultBreakingConfig == nil { | ||
return c.moduleConfigs[0].BreakingConfig() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't actually correct - this is just choosing a single configuration among potentially many and calling it the default, which is what we've tried to avoid pretty consistently with v2. I think what you're actually looking for in this PR is some concept of "if there is a single configuration, give it to me, otherwise tell me it is not present". What this logic looks like:
If you get false, do nothing, as we do right now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if a user passes the following file to
Wouldn't we want them to pick up the top-level configs for the default in the case of:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd probably want to error, or at least print a warning along the lines of:
I could see an argument to also modify the logic to "if >1 modules, return the top-level module", but that may just leave us open to even more support stuff in the long-term. Going a different direction, we could take the position that for image inputs only, we always take the top-level configuration, and never look into specific module configs. This would mean that if you had the following:
The This may be what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am a fan of the latter approach for images. For |
||
} | ||
return c.defaultBreakingConfig | ||
doriable marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ var ( | |
false, | ||
false, | ||
"", | ||
false, | ||
true, // We default to allowing comment ignores in v2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pkwarren caught an issue with the default
|
||
) | ||
) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.