Skip to content

Conversation

@dikshagupta1
Copy link
Contributor

Summary

This PR implements support for configuring HAB_AUTH_TOKEN and HAB_REFRESH_CHANNEL in the CLI configuration file (~/.hab/etc/cli.toml) as requested in CHEF-25540. Users can now set these values in the config file as fallbacks when environment variables are not set, while maintaining the proper precedence chain.

Changes Made

  • Added refresh_channel field to CliConfig struct with proper TOML serialization/deserialization
  • Implemented utility functions following existing auth_token patterns for configuration precedence
  • Updated hab pkg build command to use config file fallback while maintaining CLI and env var precedence
  • Added comprehensive unit tests covering CLI arg precedence, environment variable fallback, and config file integration
  • Updated error messages to mention config file as an option alongside CLI args and environment variables
  • Updated environment variables documentation to explain config file alternatives

Configuration Precedence

The implementation maintains the correct precedence chain:

  1. CLI arguments (--auth, --refresh-channel)
  2. Environment variables (HAB_AUTH_TOKEN, HAB_REFRESH_CHANNEL)
  3. Configuration file (~/.hab/etc/cli.toml)
  4. Default values

Testing

  • Unit tests added for CliConfig struct refresh_channel field
  • Unit tests added for utility functions covering all precedence scenarios
  • Integration tests verified configuration file parsing works correctly
  • All existing tests continue to pass
  • Code coverage maintained >80%

Example Configuration

Users can now add the following to ~/.hab/etc/cli.toml:

auth_token = "your_auth_token_here"
refresh_channel = "stable"

Jira Link

CHEF-25540

…H_CHANNEL

- Added refresh_channel field to CliConfig struct in cli_config.rs
- Implemented utility functions for config fallback with proper precedence
- Updated hab pkg build to use config file when env vars not set
- Added comprehensive unit tests for new functionality
- Updated error messages to mention config file options
- Updated environment variables documentation with config file info
- Maintains precedence: CLI args > env vars > config file > defaults

Signed-off-by: dikshagupta1 <[email protected]>
@dikshagupta1 dikshagupta1 requested review from a team as code owners October 13, 2025 07:13
@netlify
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for chef-habitat ready!

Name Link
🔨 Latest commit a4e2c12
🔍 Latest deploy log https://app.netlify.com/projects/chef-habitat/deploys/68eca6b0fb2f1f00081166a1
😎 Deploy Preview https://deploy-preview-9996--chef-habitat.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the Documentation Flags an issue / PR for attention by the technical documentation team label Oct 13, 2025
@dikshagupta1 dikshagupta1 removed the Documentation Flags an issue / PR for attention by the technical documentation team label Oct 13, 2025
@dikshagupta1 dikshagupta1 reopened this Oct 13, 2025
@github-actions github-actions bot added the Documentation Flags an issue / PR for attention by the technical documentation team label Oct 13, 2025
@sonarqube-for-infrastructure-prod

Copy link
Contributor

@mwrock mwrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will also want to set the refresh channel via the config for the studio commands as well just like we do with origin, token and url.

We should add a prompt to hab setup for configuring the refresh channel. This is how the other config values can be initially set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Flags an issue / PR for attention by the technical documentation team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants