Skip to content

Config Core library #1174

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 106 commits into
base: main
Choose a base branch
from

Conversation

samtholiya
Copy link
Collaborator

@samtholiya samtholiya commented Mar 28, 2025

Draft

  • Checking the reason for test failures.

what

  • We created a config core library that automatically handles env variables and flags.

why

  • Having to manually handle flags and env and config has led to a lot of bugs and old removed flags.
  • We now want to streamline it so that we can easily know which command uses what env variables and flags to understand the mapping.

references

Summary by CodeRabbit

  • New Features

    • Added new CLI flags and environment variable options for Helmfile, Terraform, workflows, validation, and vendor commands to enhance configuration flexibility.
    • Introduced options for specifying base paths and executable commands, including deprecated flags replaced by unified alternatives.
    • Enhanced CLI help output with expanded descriptions and additional flags for improved user guidance.
  • Refactor

    • Centralized configuration management by unifying flag, environment variable, and config file handling under a new configuration handler.
    • Deprecated legacy flags and streamlined flag registration across commands.
    • Updated tests to invoke CLI commands directly for full end-to-end validation.
    • Moved test files to new packages and improved test setup consistency.
  • Bug Fixes

    • Improved CLI help formatting and error output clarity.
    • Fixed test environment setup and output verification to increase reliability.
  • Tests

    • Added extensive unit and integration tests covering configuration loading, CLI commands, and file existence checks.
    • Removed obsolete tests and replaced them with updated versions aligned with new configuration handling.
    • Added tests for stack config discovery, vendor command, and CLI terraform generate planfile command.
    • Enhanced test logging and environment isolation.
  • Chores

    • Updated Makefile to measure test coverage across all packages.
    • Removed unused code, deprecated functions, and redundant environment variable processing.
    • Simplified error logging by removing stack trace printing.

Copy link

mergify bot commented Mar 28, 2025

💥 This pull request now has conflicts. Could you fix it @samtholiya? 🙏

@mergify mergify bot removed the conflict This PR has conflicts label Mar 31, 2025
@samtholiya samtholiya added the minor New features that do not break anything label Mar 31, 2025
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

golangci-lint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@samtholiya samtholiya force-pushed the feature/dev-3093-create-a-cli-command-core-library branch from 115a9de to 247ab4c Compare April 1, 2025 21:54
@samtholiya samtholiya force-pushed the feature/dev-3093-create-a-cli-command-core-library branch from ade57f1 to 92b4c4e Compare April 1, 2025 22:16
@github-actions github-actions bot added size/xl and removed size/l labels Apr 4, 2025
Copy link

mergify bot commented May 1, 2025

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify bot added the needs-cloudposse Needs Cloud Posse assistance label May 1, 2025
@samtholiya samtholiya force-pushed the feature/dev-3093-create-a-cli-command-core-library branch 2 times, most recently from 05c94c6 to fa08e0b Compare May 3, 2025 23:16
coderabbitai[bot]
coderabbitai bot previously approved these changes May 4, 2025
Copy link

mergify bot commented May 7, 2025

💥 This pull request now has conflicts. Could you fix it @samtholiya? 🙏

@mergify mergify bot added the conflict This PR has conflicts label May 7, 2025
@aknysh
Copy link
Member

aknysh commented May 7, 2025

@samtholiya please resolve the conflicts

…ibrary

# Conflicts:
#	internal/exec/vendor_utils_test.go
#	tests/terraform_test.go
coderabbitai[bot]
coderabbitai bot previously approved these changes May 7, 2025
@mergify mergify bot removed the conflict This PR has conflicts label May 7, 2025
@github-actions github-actions bot added the conflict This PR has conflicts label May 7, 2025
@mergify mergify bot removed the conflict This PR has conflicts label May 7, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes May 7, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes May 7, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes May 8, 2025
@Benbentwo Benbentwo force-pushed the feature/dev-3093-create-a-cli-command-core-library branch from c8f109d to 037fb3e Compare May 8, 2025 20:04
@Benbentwo
Copy link
Member

Benbentwo commented May 8, 2025

Hey @samtholiya whats the purpose of the var DefaultConfigHandler = New()? Seems like having a global config variable is problematic for our tests since we'd have to reset it every time. I think for the CLI it works fine as it's re-instantiated every time. Couldn't we instead have the DefaultConfigHandler live on the command (or similar), alternatively just have the config refreshed on init?

IIRC Viper + Cobra had a way to play nicely together. This still feels pretty complex to me.

(Also I force pushed to reset to the merge and created a branch from there to test some changes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor New features that do not break anything needs-cloudposse Needs Cloud Posse assistance size/xl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants