Skip to content

simplify environment var with same format UPPERCASE and UNDERSCORE #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hungran
Copy link

@hungran hungran commented Jul 11, 2025

Closes:

This enhance that all argument can be treat as environment variable with standard format from viper https://github.com/spf13/viper/blob/master/viper.go#L1400-L1403

eg: given argument flag dynamic-toolsets can use as GITHUB_DYNAMIC_TOOLSETS

Signed-off-by: hungran <26101787+hungran@users.noreply.github.com>
@Copilot Copilot AI review requested due to automatic review settings July 11, 2025 06:39
@hungran hungran requested a review from a team as a code owner July 11, 2025 06:39
@hungran hungran changed the title simplify environment var with same format UPPERCASE and UNDERSCOR simplify environment var with same format UPPERCASE and UNDERSCORE Jul 11, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Enhance Viper configuration to allow flag names with hyphens to be consumed as environment variables by replacing hyphens with underscores.

  • Configure Viper to replace - with _ in env var keys.
  • Call viper.SetEnvKeyReplacer before viper.AutomaticEnv().
Comments suppressed due to low confidence (1)

cmd/github-mcp-server/main.go:96

  • Consider adding a unit test for initConfig to verify that environment variables with hyphens (e.g., 'dynamic-toolsets') are correctly mapped to underscore format (e.g., 'GITHUB_DYNAMIC_TOOLSETS').
	viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))

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.

1 participant