-
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 6 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 |
---|---|---|
|
@@ -74,6 +74,13 @@ type BufYAMLFile interface { | |
// All ModuleConfigs will have unique ModuleFullNames. | ||
// Sorted by DirPath. | ||
ModuleConfigs() []ModuleConfig | ||
// TopLevelModuleConfig returns the top-level ModuleConfig for the File. | ||
// | ||
// For v1 buf.yaml files, there is only ever a single ModuleConfig, so this is returned. | ||
// For v2 buf.yaml files, if a top-level module config exists, then it will be the top-level | ||
// module config. Otherwise, this will return nil, so callers should be aware this may be | ||
// empty. | ||
TopLevelModuleConfig() ModuleConfig | ||
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. Why is this a 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 used
But in that case, it would be the default anyway, so it doesn't super matter, and also since we're not printing out the warnings, I can swap it back to 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. Updated back to |
||
// ConfiguredDepModuleRefs returns the configured dependencies of the Workspace as ModuleRefs. | ||
// | ||
// These come from buf.yaml files. | ||
|
@@ -93,7 +100,13 @@ func NewBufYAMLFile( | |
moduleConfigs []ModuleConfig, | ||
configuredDepModuleRefs []bufmodule.ModuleRef, | ||
) (BufYAMLFile, error) { | ||
return newBufYAMLFile(fileVersion, nil, moduleConfigs, configuredDepModuleRefs) | ||
return newBufYAMLFile( | ||
fileVersion, | ||
nil, | ||
moduleConfigs, | ||
nil, // Do not set top-level module config, use only module configs | ||
configuredDepModuleRefs, | ||
) | ||
} | ||
|
||
// GetBufYAMLFileForPrefix gets the buf.yaml file at the given bucket prefix. | ||
|
@@ -190,13 +203,15 @@ type bufYAMLFile struct { | |
fileVersion FileVersion | ||
objectData ObjectData | ||
moduleConfigs []ModuleConfig | ||
topLevelModuleConfig ModuleConfig | ||
configuredDepModuleRefs []bufmodule.ModuleRef | ||
} | ||
|
||
func newBufYAMLFile( | ||
fileVersion FileVersion, | ||
objectData ObjectData, | ||
moduleConfigs []ModuleConfig, | ||
topLevelModuleConfig ModuleConfig, | ||
configuredDepModuleRefs []bufmodule.ModuleRef, | ||
) (*bufYAMLFile, error) { | ||
if (fileVersion == FileVersionV1Beta1 || fileVersion == FileVersionV1) && len(moduleConfigs) > 1 { | ||
|
@@ -255,6 +270,7 @@ func newBufYAMLFile( | |
fileVersion: fileVersion, | ||
objectData: objectData, | ||
moduleConfigs: moduleConfigs, | ||
topLevelModuleConfig: topLevelModuleConfig, | ||
configuredDepModuleRefs: configuredDepModuleRefs, | ||
}, nil | ||
} | ||
|
@@ -275,6 +291,10 @@ func (c *bufYAMLFile) ModuleConfigs() []ModuleConfig { | |
return slicesext.Copy(c.moduleConfigs) | ||
} | ||
|
||
func (c *bufYAMLFile) TopLevelModuleConfig() ModuleConfig { | ||
return c.topLevelModuleConfig | ||
} | ||
|
||
func (c *bufYAMLFile) ConfiguredDepModuleRefs() []bufmodule.ModuleRef { | ||
return slicesext.Copy(c.configuredDepModuleRefs) | ||
} | ||
|
@@ -351,6 +371,7 @@ func readBufYAMLFile( | |
[]ModuleConfig{ | ||
moduleConfig, | ||
}, | ||
moduleConfig, | ||
configuredDepModuleRefs, | ||
) | ||
case FileVersionV2: | ||
|
@@ -464,6 +485,46 @@ func readBufYAMLFile( | |
} | ||
moduleConfigs = append(moduleConfigs, moduleConfig) | ||
} | ||
// If either the top-level name, lint or breaking config is non-empty, we construct a top-level | ||
// module config. | ||
var topLevelModuleConfig ModuleConfig | ||
if externalBufYAMLFile.Name != "" || !defaultExternalLintConfig.isEmpty() || !defaultExternalBreakingConfig.isEmpty() { | ||
topLevelLintConfig, err := getLintConfigForExternalLintV2( | ||
fileVersion, | ||
defaultExternalLintConfig, | ||
".", // The top-level module config always has the root "." | ||
false, // Not module-specific configuration | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
topLevelBreakingConfig, err := getBreakingConfigForExternalBreaking( | ||
fileVersion, | ||
defaultExternalBreakingConfig, | ||
".", // The top-level module config always has the root "." | ||
false, // Not module-specific configuration | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var topLevelModuleFullName bufmodule.ModuleFullName | ||
if externalBufYAMLFile.Name != "" { | ||
topLevelModuleFullName, err = bufmodule.ParseModuleFullName(externalBufYAMLFile.Name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
topLevelModuleConfig, err = newModuleConfig( | ||
".", // The top-level module path is always "." | ||
topLevelModuleFullName, | ||
map[string][]string{".": {}}, // No top-level module config for excludes | ||
topLevelLintConfig, | ||
topLevelBreakingConfig, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
configuredDepModuleRefs, err := getConfiguredDepModuleRefsForExternalDeps(externalBufYAMLFile.Deps) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -472,6 +533,7 @@ func readBufYAMLFile( | |
fileVersion, | ||
objectData, | ||
moduleConfigs, | ||
topLevelModuleConfig, | ||
configuredDepModuleRefs, | ||
) | ||
default: | ||
|
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.