Skip to content

Refactor: normalize config values at the config layer #767

@albertocavalcante

Description

@albertocavalcante

Summary

Currently, config value normalization (e.g., strings.ToLower for SHA256 hashes) happens at each call site when retrieving values. This leads to repetitive normalization calls scattered throughout the codebase.

Current Pattern

// In getExpectedSHA256
if hash := cfg.Get("BAZELISK_VERIFY_SHA256_" + suffix); hash != "" {
    return strings.ToLower(hash)
}

Similar patterns exist in other places like getBazeliskHome with strings.ToUpper.

Proposed Improvement

Normalize values once at the config layer (when storing/loading), so all consumers can assume values are already in the expected format.

This would:

  • Reduce code duplication
  • Prevent bugs from forgotten normalization
  • Make the codebase cleaner

Related

This was identified while working on #766 (platform-specific SHA256 verification).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions