Skip to content

Commit

Permalink
Fix related check configs for ls-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
doriable committed Dec 18, 2024
1 parent 42c9619 commit 7df5950
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions private/buf/cmd/buf/command/config/internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,6 @@ func lsRun(
var rules []bufcheck.Rule
if flags.ConfiguredOnly {
moduleConfigs := bufYAMLFile.ModuleConfigs()
allCheckConfigs := append(
slicesext.Map(moduleConfigs, func(moduleConfig bufconfig.ModuleConfig) bufconfig.CheckConfig { return moduleConfig.LintConfig() }),
slicesext.Map(moduleConfigs, func(moduleConfig bufconfig.ModuleConfig) bufconfig.CheckConfig { return moduleConfig.BreakingConfig() })...,
)
var moduleConfig bufconfig.ModuleConfig
switch fileVersion := bufYAMLFile.FileVersion(); fileVersion {
case bufconfig.FileVersionV1Beta1, bufconfig.FileVersionV1:
Expand All @@ -241,17 +237,20 @@ func lsRun(
return syserror.Newf("unknown FileVersion: %v", fileVersion)
}
var checkConfig bufconfig.CheckConfig
var relatedCheckConfigsForType []bufconfig.CheckConfig
switch ruleType {
case check.RuleTypeLint:
checkConfig = moduleConfig.LintConfig()
relatedCheckConfigsForType = slicesext.Map(moduleConfigs, func(moduleConfig bufconfig.ModuleConfig) bufconfig.CheckConfig { return moduleConfig.LintConfig() })
case check.RuleTypeBreaking:
checkConfig = moduleConfig.BreakingConfig()
relatedCheckConfigsForType = slicesext.Map(moduleConfigs, func(moduleConfig bufconfig.ModuleConfig) bufconfig.CheckConfig { return moduleConfig.BreakingConfig() })
default:
return fmt.Errorf("unknown check.RuleType: %v", ruleType)
}
configuredRuleOptions := []bufcheck.ConfiguredRulesOption{
bufcheck.WithPluginConfigs(bufYAMLFile.PluginConfigs()...),
bufcheck.WithRelatedCheckConfigs(allCheckConfigs...),
bufcheck.WithRelatedCheckConfigs(relatedCheckConfigsForType...),
}
rules, err = client.ConfiguredRules(
ctx,
Expand Down

0 comments on commit 7df5950

Please sign in to comment.