Skip to content

Conversation

@Bishibop
Copy link
Contributor

@Bishibop Bishibop commented Nov 7, 2025

Adds version warnings to the linter that check if configured tool versions are outdated compared to recommended versions.

Changes

  • Fetches recommended versions from replicated.app/ping API (5 second timeout)
  • Compares configured versions against recommended (major/minor only, ignores patch)
  • Displays warnings before linting starts (table and JSON output)
  • Only warns for enabled linters with explicitly pinned versions
  • Special handling for Embedded Cluster (version from manifest spec.version)

Steps to test:

Test that warnings appear when using an old version.

cd examples

Edit examples/.replicated.yaml:

  repl-lint:
    tools:
      helm: "3.12.0"  # Old version
      preflight: "latest"
      support-bundle: "latest"
      kots: "latest"

Run linter with v2 enabled

  export REPLICATED_RELEASE_VALIDATION_V2=1
  ../bin/replicated release lint

Expected output:

  • Warning displayed before linting starts:
    Warning: helm version 3.12.0 is below recommended version 3.15.x.
    Update your .replicated config:
    tools:
    helm: '3.15.x'
  • Linting still proceeds (non-blocking)
  • All lint results shown normally

@Bishibop Bishibop force-pushed the feat/add-kots-linter branch from ccddeb1 to 973cbfe Compare November 10, 2025 21:10
@Bishibop Bishibop changed the base branch from feat/add-kots-linter to feat/embedded-cluster-and-kots-linter-integrations November 12, 2025 19:26
Changes embedded-cluster linter version resolution to extract the
version from the manifest's spec.version field instead of from the
.replicated config file. This ensures the linter binary matches the
runtime version being validated.

Changes:
- Add ExtractECVersion() to extract spec.version from EC Config manifest
- Handle multi-document YAML and templated files with fallback strategy
- Update discovery logic to extract and store EC version
- Remove tools.embedded-cluster from config-based resolution
- Add warning when tools.embedded-cluster is in config (now ignored)
- Update metadata with correct version after extraction
- Add 9 comprehensive unit tests for version extraction
- Update documentation to clarify version source

The linter will use "latest" as fallback if version extraction fails,
allowing the EC linter itself to report missing version errors.
Adds automatic version checking before linting starts to warn users when
their configured tool versions are outdated compared to recommended versions
from the Replicated API.

Changes:
- Add FetchRecommendedVersions() to query replicated.app/ping (5s timeout)
- Add CompareVersions() to compare versions using semver (major/minor only)
- Add checkToolVersions() to CLI that checks all enabled linters
- Add ToolVersionWarnings field to JSON output
- Display warnings before linting starts (both table and JSON formats)
- Add comprehensive unit tests for version comparison logic
- Update documentation with tool version check behavior

Behavior:
- Only checks enabled linters with explicitly pinned versions (not "latest")
- Only warns for minor/major version differences (patch = silent)
- Makes single API call for all tools (efficient, no caching needed)
- EC version compared from manifest spec.version (not config)
- Non-blocking: warnings are informational (don't fail linting)
- Graceful degradation if API unavailable

Example warning:
  Warning: helm version 3.14.0 is below recommended version 3.15.2.
  Update your .replicated config:
    tools:
      helm: '3.15.2'
Add comprehensive integration tests for the outdated tool version warnings
feature to validate end-to-end behavior:

- TestLint_VersionWarningsDisplay: Verifies warnings appear in output
- TestLint_VersionWarningsOnlyForEnabledLinters: Verifies disabled linters don't warn
- TestLint_VersionWarningsSkipLatest: Verifies "latest" doesn't trigger warnings
- TestLint_VersionWarningsInJSON: Verifies JSON output structure
- TestLint_VersionWarningsECUsesManifest: Verifies EC version from manifest

Remove redundant unit tests for FetchRecommendedVersions() that were making
real API calls and provided no value beyond what the integration tests cover.
The actual business logic (CompareVersions) already has excellent unit test
coverage with 13 tests covering all edge cases.

Test coverage:
- 13 unit tests for version comparison logic (fast, isolated)
- 5 integration tests for full lint command flow (validates user behavior)
Remove 5 integration tests that made real API calls to replicated.app/ping.
These tests added network dependency and potential flakiness to CI.

The core version comparison logic is already comprehensively tested by
13 unit tests in pkg/tools/version_info_test.go covering all edge cases
including major/minor/patch differences, version normalization, invalid
versions, and EC format handling.

Tests removed:
- TestLint_VersionWarningsDisplay
- TestLint_VersionWarningsOnlyForEnabledLinters
- TestLint_VersionWarningsSkipLatest
- TestLint_VersionWarningsInJSON
- TestLint_VersionWarningsECUsesManifest
@Bishibop Bishibop force-pushed the feat/handle-outdated-tool-versions branch from c3b7a99 to c44191c Compare November 12, 2025 19:30
@Bishibop Bishibop requested a review from bennyyang11 November 12, 2025 19:31
@Bishibop Bishibop self-assigned this Nov 12, 2025
@Bishibop Bishibop marked this pull request as ready for review November 12, 2025 19:36
@Bishibop Bishibop merged commit 11b7d40 into feat/embedded-cluster-and-kots-linter-integrations Nov 12, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants