Skip to content

Commit a202ead

Browse files
committed
feat: integrate plugin loader into CLI flow
Complete the plugin system implementation by integrating the plugin loader into the CLI workflow. This connects the previously added components to create a fully functional plugin system. Changes: - Updated the lint method to load plugins before running the linter - Added informative message showing how many plugins were loaded - Ensured proper error handling and propagation With this change, the plugin system is now complete and operational. Users can now extend the api-linter with custom rules by: 1. Creating plugins with the AddCustomRules function 2. Building them as shared libraries (.so files) 3. Specifying them with the --rule-plugin flag when running api-linter This completes the 3-part implementation for issue googleapis#1485, providing a way for organizations to extend the linter with custom rules without forking the entire repository.
1 parent 1b55ace commit a202ead

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/api-linter/cli.go

+9
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ func (c *cli) lint(rules lint.RuleRegistry, configs lint.Configs) error {
125125
if len(c.ProtoFiles) == 0 {
126126
return fmt.Errorf("no file to lint")
127127
}
128+
129+
// Load custom rule plugins if provided
130+
if len(c.RulePluginPaths) > 0 {
131+
if err := loadCustomRulePlugins(c.RulePluginPaths, rules); err != nil {
132+
return fmt.Errorf("failed to load custom rule plugins: %v", err)
133+
}
134+
fmt.Printf("Loaded %d custom rule plugin(s)\n", len(c.RulePluginPaths))
135+
}
136+
128137
// Read linter config and append it to the default.
129138
if c.ConfigPath != "" {
130139
config, err := lint.ReadConfigsFromFile(c.ConfigPath)

0 commit comments

Comments
 (0)