Skip to content
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

Any usage of --help should not require stack configurations #825

Merged
merged 1 commit into from
Dec 7, 2024
Merged

Conversation

Listener430
Copy link
Collaborator

@Listener430 Listener430 commented Dec 7, 2024

what

Checked all commands that --help usage doesn't require stack configurations. Here is the summary

modules_issues_status

Please note - had to make func ProcessCommandLineArgs exportable for use to check for help flag earlier in terraform and helmfile, thus all the changes in the rest of exec files (changed p to capital).

Found out that terraform and helmfile modules indeed have the issue (i.e. check configs before showing help + version).

This is how it looked before for terrafrom
broken_terraaform
And the same issue is with helmfile
broken_helmfile

After the fix for terraform

terraform_fixed_1_of_2
terraform_fixed_2_of_2

And fixed for helmfile looks like this
helmfile_fixed

why

We need to show help message and version/upgrade information irrespective if configs are in place or not.

references

Linear issue - https://linear.app/cloudposse/issue/DEV-2797/any-usage-of-help-should-not-require-stack-configurations

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new function for printing upgrade messages with styled output, enhancing user experience when updates are available.
  • Improvements

    • Enhanced command-line argument processing across various commands, improving error handling and visibility of functions.
    • Added version checking logic to prompt users for upgrades when newer versions are available.
  • Bug Fixes

    • Streamlined error handling and control flow in multiple command execution functions, ensuring consistent behavior.
  • Documentation

    • Improved comments and formatting for better code readability and understanding.

@Listener430 Listener430 added the bugfix Change that restores intended behavior label Dec 7, 2024
@Listener430 Listener430 requested a review from aknysh December 7, 2024 15:20
@Listener430 Listener430 self-assigned this Dec 7, 2024
@Listener430 Listener430 requested review from a team as code owners December 7, 2024 15:20
Copy link
Contributor

coderabbitai bot commented Dec 7, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces several changes across multiple files, primarily focusing on enhancing command-line argument processing and error handling. Key modifications include the removal and replacement of specific functions related to upgrade messaging, the renaming of functions to improve visibility, and the addition of a new function for styled output. The overall structure and logic of existing commands have been preserved, ensuring that command execution and validation processes remain intact.

Changes

File Path Change Summary
cmd/cmd_utils.go Removed printMessageToUpgradeToAtmosLatestRelease. Replaced its call in customHelpMessageToUpgradeToAtmosLatestRelease with u.PrintMessageToUpgradeToAtmosLatestRelease. Removed lipgloss import.
cmd/helmfile.go Replaced e.ExecuteHelmfileCmd with e.ProcessCommandLineArgs. Added version check for Atmos release. Enhanced error handling.
cmd/terraform.go Updated command execution to call e.ExecuteTerraform(info). Added version check and error handling.
cmd/version.go Replaced local function call with u.PrintMessageToUpgradeToAtmosLatestRelease.
internal/exec/atlantis_generate_repo_config.go Changed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/describe_affected.go Renamed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/describe_config.go Changed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/describe_dependents.go Updated processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/describe_stacks.go Renamed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/describe_workflows.go Changed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/helmfile.go Updated processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/helmfile_generate_varfile.go Renamed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/pro.go Changed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/terraform.go Updated processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/terraform_generate_backend.go Changed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/terraform_generate_backends.go Renamed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/terraform_generate_varfile.go Updated processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/terraform_generate_varfiles.go Changed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/utils.go Renamed processCommandLineArgs to ProcessCommandLineArgs. Added logic for handling -h or --help flags.
internal/exec/validate_component.go Changed processCommandLineArgs to ProcessCommandLineArgs. Enhanced error handling in ExecuteValidateComponent.
internal/exec/validate_stacks.go Renamed processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/vendor_utils.go Updated processCommandLineArgs to ProcessCommandLineArgs.
internal/exec/workflow.go Changed processCommandLineArgs to ProcessCommandLineArgs.
pkg/utils/version_utils.go Added PrintMessageToUpgradeToAtmosLatestRelease function for styled upgrade messages.

Assessment against linked issues

Objective Addressed Explanation
Any usage of --help should not require stack configurations (DEV-2797)

Possibly related PRs

Suggested labels

patch

Suggested reviewers

  • osterman
  • aknysh
  • Gowiem
  • gberenice

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@osterman
Copy link
Member

osterman commented Dec 7, 2024

The double display of the atmos logos is fixed in #798.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (6)
cmd/helmfile.go (2)

38-46: Consider moving the update check after the help check.

By checking if help is needed first, you can avoid unnecessary network calls when the user just wants help.


38-46: Encapsulate release-checking logic into a utility function.

Extracting this code into a reusable function reduces duplication across commands.

pkg/utils/version_utils.go (1)

14-16: Consider naming color constants for clarity.

Using meaningful names for color styles improves readability.

cmd/terraform.go (1)

39-46: Consider deferring version check after help

While the version check is a good addition, it might be better to move it after the help check to ensure help messages are displayed without any additional output.

Consider moving the version check after line 50:

 		if info.NeedHelp {
 			return
 		}
+
+		// Check for the latest Atmos release on GitHub and print update message
+		latestReleaseTag, err := u.GetLatestGitHubRepoRelease("cloudposse", "atmos")
+		if err == nil && latestReleaseTag != "" {
+			latestRelease := strings.TrimPrefix(latestReleaseTag, "v")
+			currentRelease := strings.TrimPrefix(version.Version, "v")
+			if latestRelease != currentRelease {
+				u.PrintMessageToUpgradeToAtmosLatestRelease(latestRelease)
+			}
+		}
internal/exec/pro.go (1)

Documentation needed for command processing architectural change

The codebase currently lacks documentation about the architectural change in command processing. While there are help-related code comments in internal/exec/help.go and cmd/root.go, they don't explain the architectural shift of making command processing public to enable configuration-less help commands.

Consider documenting this change in:

  • CHANGELOG.md to record this architectural improvement
  • website/docs/troubleshoot/debugging.md to highlight that help commands now work without configurations
  • Code-level documentation in internal/exec/help.go to explain the design decision
🔗 Analysis chain

Line range hint 23-30: Consider documenting this architectural change

The consistent change of processCommandLineArgs to ProcessCommandLineArgs across multiple files represents a significant architectural shift in how command processing works. This change enables help commands to work without stack configurations, which is a good improvement in user experience.

Consider:

  1. Adding documentation about this architectural change
  2. Creating integration tests to verify help command behavior
  3. Updating user documentation to reflect that help commands now work without configurations

Let's check for existing documentation:


Let me search for documentation in different ways to make a more informed decision about the architectural change documentation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for relevant documentation
fd -e md -e txt | xargs rg -l "command.*help.*configuration" || true

Length of output: 69


Script:

#!/bin/bash
# Let's check for any documentation files first
fd -e md -e txt

# Then search for any mentions of command processing or help commands
rg -i "process.*command|help.*command" -g "*.md" -g "*.txt" -A 2 || true

# Check for any recent changes to documentation
git diff --name-only HEAD~5 HEAD | grep -E "\.(md|txt)$" || true

# Look for documentation in code comments
rg "//.*help.*command|/\*.*help.*command" || true

Length of output: 2494

internal/exec/terraform_generate_backends.go (1)

20-20: LGTM! Maintains consistency in command-line processing.

The change follows the established pattern for early --help handling. Consider adding a test case to verify help text display without stack configurations.

Would you like me to generate a test case that verifies the --help functionality works without stack configurations?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4694786 and ad822a9.

📒 Files selected for processing (24)
  • cmd/cmd_utils.go (1 hunks)
  • cmd/helmfile.go (2 hunks)
  • cmd/terraform.go (3 hunks)
  • cmd/version.go (1 hunks)
  • internal/exec/atlantis_generate_repo_config.go (1 hunks)
  • internal/exec/describe_affected.go (1 hunks)
  • internal/exec/describe_config.go (1 hunks)
  • internal/exec/describe_dependents.go (1 hunks)
  • internal/exec/describe_stacks.go (1 hunks)
  • internal/exec/describe_workflows.go (1 hunks)
  • internal/exec/helmfile.go (1 hunks)
  • internal/exec/helmfile_generate_varfile.go (2 hunks)
  • internal/exec/pro.go (1 hunks)
  • internal/exec/terraform.go (1 hunks)
  • internal/exec/terraform_generate_backend.go (2 hunks)
  • internal/exec/terraform_generate_backends.go (1 hunks)
  • internal/exec/terraform_generate_varfile.go (2 hunks)
  • internal/exec/terraform_generate_varfiles.go (1 hunks)
  • internal/exec/utils.go (2 hunks)
  • internal/exec/validate_component.go (2 hunks)
  • internal/exec/validate_stacks.go (1 hunks)
  • internal/exec/vendor_utils.go (1 hunks)
  • internal/exec/workflow.go (1 hunks)
  • pkg/utils/version_utils.go (1 hunks)
👮 Files not reviewed due to content moderation or server errors (3)
  • internal/exec/atlantis_generate_repo_config.go
  • internal/exec/vendor_utils.go
  • internal/exec/describe_stacks.go
🔇 Additional comments (21)
cmd/helmfile.go (1)

33-37: Good update to process command-line arguments.

Switching to ProcessCommandLineArgs enhances consistency in argument handling.

internal/exec/describe_config.go (1)

18-20: Confirmed export of ProcessCommandLineArgs function.

Making this function public allows for broader use within the package.

cmd/version.go (1)

38-38: Nice use of the utility function for upgrade messaging.

Utilizing PrintMessageToUpgradeToAtmosLatestRelease promotes code reuse.

internal/exec/describe_workflows.go (1)

12-14: Function ProcessCommandLineArgs is now exported.

This change enhances accessibility across packages.

internal/exec/terraform_generate_varfile.go (1)

28-31: Similar help handling issue as in helmfile_generate_varfile.go

This file has the same pattern where stack validation occurs before help check, which could prevent accessing help without stack configurations.

Please apply the same restructuring pattern suggested in the helmfile_generate_varfile.go review.

cmd/terraform.go (1)

48-52: LGTM! Proper help handling implementation

This is exactly what we need! The help check is performed before stack validation, allowing users to access help without stack configurations.

internal/exec/terraform_generate_backend.go (1)

29-29: Verify help command behavior with this change

The change to ProcessCommandLineArgs aligns with making command processing more accessible, but we should verify that help commands work without stack configurations.

Let's verify the help command behavior:

✅ Verification successful

Let me search for more information about the help command implementation.


Let me search for the help command handling implementation.


Let me check the command handling implementation more thoroughly.


Based on the findings, I can now provide a final response about the help command behavior.

Help command behavior is properly handled with the public function

The change to ProcessCommandLineArgs is safe as the function properly handles help flags by checking NeedHelp flag and processing -h or --help before any stack validation occurs. The help command will work without requiring stack configurations since help processing is done early in the execution flow.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Test help command without stack configurations
atmos terraform generate backend --help 2>&1 || true

Length of output: 144


Script:

#!/bin/bash
# Find the help command implementation and its dependencies
rg -A 5 "ProcessCommandLineArgs" --type go

# Check if there are any tests related to help command
rg -l "TestHelp|help.*Test" --type go

# Look for help command related code
ast-grep --pattern 'if $_ == "--help" || $_ == "-h" { $$$_ }'

Length of output: 74285


Script:

#!/bin/bash
# Look for help command handling in utils.go
rg -A 5 "ProcessCommandLineArgs" internal/exec/utils.go

# Check if there are any cobra command definitions related to help
rg -A 5 "RunE.*func.*cobra.Command" --type go

Length of output: 266


Script:

#!/bin/bash
# Look for help flag handling in utils.go
rg -B 5 -A 10 "SubCommand.*help" internal/exec/utils.go

# Check cobra command initialization
rg -B 5 -A 10 "NewCommand" --type go

# Look for help command handling in cobra setup
rg -B 5 -A 10 "cmd.*Run.*help" --type go

Length of output: 641

internal/exec/workflow.go (1)

23-23: Ensure workflow help commands work independently

The function visibility change should allow workflow help commands to work without configurations. This aligns with the PR objective.

Let's verify workflow help behavior:

✅ Verification successful

Help command functionality is properly handled

The change from processCommandLineArgs to ProcessCommandLineArgs is safe for workflow help commands. The codebase shows:

  • Help command handling is managed by Cobra framework (cobra.Command)
  • Root command explicitly handles help flags and commands (in cmd/root.go)
  • Workflow command inherits the help functionality from Cobra
  • ProcessCommandLineArgs is called after help command checks, so its visibility change doesn't affect help behavior
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Test workflow help command without configurations
atmos workflow --help 2>&1 || true

Length of output: 126


Script:

#!/bin/bash
# Let's check for any workflow help command handling in the codebase
rg -A 5 "workflow.*help" --type go

# Also check for any help-related functions in workflow.go
ast-grep --pattern 'func $$$Help$$$($$$) $$$'

# Check how ProcessCommandLineArgs is used in workflow context
rg "ProcessCommandLineArgs.*workflow" --type go

Length of output: 134


Script:

#!/bin/bash
# Let's examine the workflow.go file to understand the help command handling
cat internal/exec/workflow.go

# Check for any help-related code in the codebase
rg -i "help.*command" --type go -A 3

# Look for workflow command handling
rg "workflow.*command" --type go -A 3

Length of output: 8115

internal/exec/pro.go (1)

30-30: Confirm pro commands help accessibility

The change to ProcessCommandLineArgs should enable pro commands to display help without requiring stack configurations.

Let's verify pro commands help behavior:

internal/exec/validate_component.go (2)

19-19: LGTM! Command-line argument processing change looks good.

The change from a local to an exported function aligns with the PR objectives of making help functionality more accessible.


Line range hint 84-89: Robust fallback mechanism for component type determination.

The code implements a resilient approach by attempting "terraform" first and falling back to "helmfile" if that fails. This ensures compatibility with both types of components.

internal/exec/describe_affected.go (2)

38-38: LGTM! Command-line argument processing change is consistent.

The change to use the exported ProcessCommandLineArgs maintains consistency across the codebase.


Line range hint 76-83: Well-structured format validation with clear error messages.

The code properly validates the format flag with clear error messages and sets a sensible default.

internal/exec/describe_dependents.go (2)

18-18: LGTM! Command-line argument processing change maintains consistency.

The change to use the exported ProcessCommandLineArgs aligns with the codebase-wide standardization.


Line range hint 65-293: Robust and thorough dependency resolution implementation.

The ExecuteDescribeDependents function implements a comprehensive approach to dependency resolution:

  • Validates component relationships across multiple dimensions (namespace, tenant, environment, stage)
  • Handles special cases like abstract components
  • Proper error handling throughout
internal/exec/helmfile.go (1)

21-21: LGTM! Function visibility change aligns with PR objectives.

The change to make ProcessCommandLineArgs public is a solid move, allowing consistent command-line argument handling across packages, especially for --help flags.

Let's verify this function is used consistently across the codebase:

✅ Verification successful

Consistent usage of ProcessCommandLineArgs verified across the codebase

The function is being used correctly and consistently throughout the codebase. All command handlers in the internal/exec package and the main command files use the public ProcessCommandLineArgs. There's also a lower-level processCommandLineArgs in the pkg/config package that handles the core processing, which is correctly kept private as it's an implementation detail.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of ProcessCommandLineArgs
# Expect: All command handlers should use ProcessCommandLineArgs

rg -p "ProcessCommandLineArgs|processCommandLineArgs" --type go

Length of output: 2507

internal/exec/terraform_generate_varfiles.go (1)

20-20: LGTM! Consistent with the command-line processing pattern.

The change maintains consistency with other command handlers in handling --help flags early in the execution flow.

internal/exec/validate_stacks.go (1)

26-26: LGTM! Function visibility change aligns with help command requirements.

The change from processCommandLineArgs to ProcessCommandLineArgs makes the function public, which is consistent with the PR's objective of making help functionality accessible without stack configurations.

Let's verify that help commands work without stack configurations:

✅ Verification successful

Let me verify the execution flow by checking where ProcessCommandLineArgs is used and how it relates to stack validation.


Function visibility change is correctly implemented and help functionality is preserved!

The code inspection confirms that ProcessCommandLineArgs handles help flags early in its execution (lines 222-234) before any stack validation occurs. The function processes -h and --help flags, sets appropriate command info, and returns before reaching stack-related operations (line 238 onwards). This implementation ensures help commands work without requiring stack configurations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify help commands work without stack configurations
# Test: Check if help flags are processed before stack validation

# Search for help flag checks that occur before stack validation
rg -A 5 "if info.NeedHelp" internal/exec/

Length of output: 939


Script:

#!/bin/bash
# Check the implementation of ExecuteValidateStacksCmd
ast-grep --pattern 'func ExecuteValidateStacksCmd($_, $_, $_) $_ {
  $$$
}'

# Find where ProcessCommandLineArgs is defined
ast-grep --pattern 'func ProcessCommandLineArgs($_, $_, $_, $_) $_ {
  $$$
}'

Length of output: 5599

cmd/cmd_utils.go (1)

440-440: LGTM! Good refactoring of version utility function.

Moving the upgrade message functionality to a utility package improves code organization while maintaining the same functionality.

internal/exec/utils.go (2)

Line range hint 166-171: LGTM! Function visibility change enhances modularity.

The function has been correctly exported to support the PR's objective of making help functionality accessible across all commands.


224-228: LGTM! Help flag handling aligns with PR objectives.

The code properly handles both -h and --help flags, ensuring that help messages can be displayed without requiring stack configurations. This directly implements the core requirement from DEV-2797.

internal/exec/helmfile_generate_varfile.go Show resolved Hide resolved
internal/exec/terraform.go Show resolved Hide resolved
@Listener430
Copy link
Collaborator Author

The double display of the atmos logos is fixed in #798.

@osterman , thanks, but actually i was not aiming to fix that, its just got removed autmatically as i did the changes on the "Any usage of --help should not require stack configurations" so probably we are not invoking that part of code when the extra logo displays

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
cmd/terraform.go (1)

39-46: Consider making the version check non-blocking

While checking for the latest release improves user awareness, consider making this check asynchronous or adding a timeout to prevent delays if the network is slow or unreachable.

You could modify the version check to run in a separate goroutine or set a timeout on the network request to avoid blocking command execution.

cmd/helmfile.go (1)

39-46: Potential performance impact of version check

The addition of version checking is beneficial, but consider handling potential network latency by implementing timeouts or making the check optional.

You might introduce a configuration setting to allow users to disable the version check or implement a timeout to avoid blocking command execution.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ad822a9 and 3d8fb3a.

📒 Files selected for processing (24)
  • cmd/cmd_utils.go (1 hunks)
  • cmd/helmfile.go (2 hunks)
  • cmd/terraform.go (3 hunks)
  • cmd/version.go (1 hunks)
  • internal/exec/atlantis_generate_repo_config.go (1 hunks)
  • internal/exec/describe_affected.go (1 hunks)
  • internal/exec/describe_config.go (1 hunks)
  • internal/exec/describe_dependents.go (1 hunks)
  • internal/exec/describe_stacks.go (1 hunks)
  • internal/exec/describe_workflows.go (1 hunks)
  • internal/exec/helmfile.go (1 hunks)
  • internal/exec/helmfile_generate_varfile.go (2 hunks)
  • internal/exec/pro.go (1 hunks)
  • internal/exec/terraform.go (1 hunks)
  • internal/exec/terraform_generate_backend.go (2 hunks)
  • internal/exec/terraform_generate_backends.go (1 hunks)
  • internal/exec/terraform_generate_varfile.go (2 hunks)
  • internal/exec/terraform_generate_varfiles.go (1 hunks)
  • internal/exec/utils.go (2 hunks)
  • internal/exec/validate_component.go (2 hunks)
  • internal/exec/validate_stacks.go (1 hunks)
  • internal/exec/vendor_utils.go (1 hunks)
  • internal/exec/workflow.go (1 hunks)
  • pkg/utils/version_utils.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (21)
  • cmd/version.go
  • internal/exec/describe_config.go
  • internal/exec/pro.go
  • pkg/utils/version_utils.go
  • internal/exec/terraform_generate_varfile.go
  • internal/exec/terraform_generate_backend.go
  • internal/exec/helmfile_generate_varfile.go
  • internal/exec/atlantis_generate_repo_config.go
  • internal/exec/terraform.go
  • internal/exec/describe_workflows.go
  • internal/exec/vendor_utils.go
  • internal/exec/describe_dependents.go
  • internal/exec/helmfile.go
  • internal/exec/terraform_generate_backends.go
  • cmd/cmd_utils.go
  • internal/exec/describe_affected.go
  • internal/exec/validate_stacks.go
  • internal/exec/workflow.go
  • internal/exec/describe_stacks.go
  • internal/exec/terraform_generate_varfiles.go
  • internal/exec/validate_component.go
🔇 Additional comments (11)
cmd/terraform.go (5)

24-24: Reposition checkAtmosConfig() after argument parsing

Moving checkAtmosConfig() after processing command-line arguments ensures configuration checks are only executed when necessary, particularly avoiding errors when users request help.


34-37: Robust error handling after argument processing

Adding error handling after ProcessCommandLineArgs enhances stability by properly handling any issues during argument parsing.


48-50: Early return on help request is appropriate

Exiting immediately when info.NeedHelp is true avoids unnecessary processing and provides a responsive user experience.


52-52: Configuration check placement

Ensuring checkAtmosConfig() is called after processing arguments and before executing the main command maintains the correct initialization sequence.


54-56: Optimized execution with ExecuteTerraform(info)

Updating the execution call to e.ExecuteTerraform(info) simplifies the function signature and leverages the processed information effectively.

cmd/helmfile.go (4)

33-36: Improved error handling during argument processing

Including error checks after ProcessCommandLineArgs ensures that any parsing issues are caught early, enhancing reliability.


48-50: Proper handling of help requests

Exiting early when help is requested ensures that the application responds promptly to user queries.


52-52: Deferred configuration validation

Moving checkAtmosConfig() after argument parsing prevents unnecessary configuration validations when they're not needed.


54-56: Simplified Helmfile execution

Using e.ExecuteHelmfile(info) streamlines the execution flow by utilizing the processed command-line information.

internal/exec/utils.go (2)

166-166: Export ProcessCommandLineArgs for broader accessibility

Changing processCommandLineArgs to ProcessCommandLineArgs allows it to be used across different packages, promoting code reuse.


224-228: Ensure correct handling of help flags

While clearing SubCommand when help flags are present, verify that this doesn't interfere with subcommands that also require help information.

Double-check that all subcommands correctly display help when -h or --help is used.

@osterman
Copy link
Member

osterman commented Dec 7, 2024

Oh, interesting!

@Cerebrovinny I think our fix in #798 is overly complicated if we are tracking how many times we displayed the logo with a counter. It sounds like a symptomatic solution, rather than addressing the underlying reasons.

@aknysh
Copy link
Member

aknysh commented Dec 7, 2024

Oh, interesting!

@Cerebrovinny I think our fix in #798 is overly complicated if we are tracking how many times we displayed the logo with a counter. It sounds like a symptomatic solution, rather than addressing the underlying reasons.

@Listener430 @Cerebrovinny @osterman

I tested this PR and it solves all the issues including the double logo printing.
I'll mark #798 as DON'T MERGE for now (we will close it later or revisit it)

@aknysh aknysh added patch A minor, backward compatible change and removed bugfix Change that restores intended behavior labels Dec 7, 2024
Copy link
Member

@aknysh aknysh left a comment

Choose a reason for hiding this comment

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

thanks @Listener430

@aknysh aknysh added minor New features that do not break anything and removed patch A minor, backward compatible change labels Dec 7, 2024
@aknysh aknysh merged commit 4836d3b into main Dec 7, 2024
32 checks passed
@aknysh aknysh deleted the DEV-2797 branch December 7, 2024 16:56
Copy link

github-actions bot commented Dec 7, 2024

These changes were released in v1.119.0.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants