You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add JSON config validation and SDK compatibility shim
This commit enhances JSON configuration support with filename validation,
SDK compatibility handling, and comprehensive integration tests.
## JSON Config Filename Validation
JSON configuration files must now end with "tflint.json" to avoid
confusion with other JSON files like terraform.tfvars.json.
Valid names:
- .tflint.json
- my-tflint.json
- project.tflint.json
Invalid names:
- config.json
- test.json
- terraform.tfvars.json
## SDK Compatibility Shim
Added a compatibility shim for plugins using SDK version < 0.23.0 that
cannot parse JSON config files with the .json extension. The shim:
- Detects plugin SDK versions during initialization
- Re-parses JSON configs with .tf.json extension for older SDKs
- Warns users about compatibility issues
- Ensures all plugin rules work correctly
## Implementation Details
- Added validation in config.go to check JSON filename suffixes
- Implemented ReparseForCompatibility() method for config re-parsing
- Modified launchPlugins() to detect SDK versions and apply shim
- Updated all config tests to use valid JSON filenames
- Added comprehensive integration test for JSON config with plugins
- Applied gofmt formatting across affected files
The compatibility shim is applied transparently when needed, with
appropriate warnings logged to inform users about the compatibility
mode being used.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
// VersionConstraints endpoint is available in tflint-plugin-sdk v0.14+.
274
-
returnrulesetPlugin, fmt.Errorf(`Plugin "%s" SDK version is incompatible. Compatible versions: %s`, name, plugin.SDKVersionConstraints)
286
+
returnrulesetPlugin, config, sdkVersions, fmt.Errorf(`Plugin "%s" SDK version is incompatible. Compatible versions: %s`, name, plugin.SDKVersionConstraints)
275
287
} else {
276
-
returnrulesetPlugin, fmt.Errorf(`Failed to get TFLint version constraints to "%s" plugin; %w`, name, err)
288
+
returnrulesetPlugin, config, sdkVersions, fmt.Errorf(`Failed to get TFLint version constraints to "%s" plugin; %w`, name, err)
277
289
}
278
290
}
279
291
if!constraints.Check(tflint.Version) {
280
-
returnrulesetPlugin, fmt.Errorf("Failed to satisfy version constraints; tflint-ruleset-%s requires %s, but TFLint version is %s", name, constraints, tflint.Version)
292
+
returnrulesetPlugin, config, sdkVersions, fmt.Errorf("Failed to satisfy version constraints; tflint-ruleset-%s requires %s, but TFLint version is %s", name, constraints, tflint.Version)
0 commit comments