Skip to content

Conversation

@scottbrown
Copy link
Owner

This pull request introduces functionality to include or exclude specific AWS accounts using new command-line flags. The changes span multiple files to implement this feature.

New feature implementation:

  • cmd/constants.go: Added new flags FlagIncludeAccounts and FlagExcludeAccounts for including and excluding accounts.
  • cmd/flags.go: Introduced new variables includeAccounts and excludeAccounts to store comma-separated lists of accounts to include or exclude.
  • cmd/init.go: Registered the new flags includeAccounts and excludeAccounts with the command-line interface.

Account filtering logic:

  • cmd/rootCmd.go: Added imports for strings to handle account filtering.
  • cmd/rootCmd.go: Implemented buildIncludedAccounts and buildExcludedAccounts functions to create filters from the provided account lists and applied these filters in the buildProfiles function to include or exclude accounts accordingly. [1] [2]

@scottbrown scottbrown requested a review from Copilot March 6, 2025 06:09
Copy link

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.

PR Overview

This pull request adds new command-line flags to filter the list of AWS accounts by including or excluding specific accounts. The key changes include:

  • Adding new flags in constants and flags files.
  • Registering the new flags in the initialization process.
  • Implementing account filtering functions and integrating them in the profile-building logic.

Reviewed Changes

File Description
cmd/rootCmd.go Added account filtering functions and integrated filtering logic
cmd/flags.go Introduced new flag variables for include/exclude accounts
cmd/constants.go Defined new constants for the include/exclude account flags
cmd/init.go Registered the new account filtering flags with the CLI

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

cmd/rootCmd.go Outdated

type AccountsFilter []string

func buildIncludedAccounts() AccountsFilter {
Copy link

Copilot AI Mar 6, 2025

Choose a reason for hiding this comment

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

When includeAccounts is an empty string, strings.Split returns a slice with one empty element, which may inadvertently filter out all accounts. Consider checking if includeAccounts is empty before splitting and return a filter that includes all accounts if no value is provided.

Suggested change
func buildIncludedAccounts() AccountsFilter {
func buildIncludedAccounts() AccountsFilter {
if includeAccounts == "" {
return AccountsFilter{}
}

Copilot uses AI. Check for mistakes.
@scottbrown scottbrown requested a review from Copilot March 6, 2025 06:17
Copy link

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@scottbrown scottbrown requested a review from Copilot March 6, 2025 06:20
Copy link

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.

PR Overview

This PR adds filtering functionality for AWS accounts by introducing new include and exclude command-line flags and updating the account filtering logic accordingly. Key changes include:

  • Adding new flags (includeAccounts & excludeAccounts) to the CLI.
  • Introducing helper functions (buildIncludedAccounts & buildExcludedAccounts) to filter account IDs.
  • Updating the README.md documentation to reflect the new flags.

Reviewed Changes

File Description
cmd/rootCmd.go Added filtering logic by including buildIncludedAccounts and buildExcludedAccounts functions.
cmd/flags.go Introduced new flag variables includeAccounts and excludeAccounts.
cmd/constants.go Defined new flag constants for account filtering.
cmd/init.go Registered the new filtering flags with the command-line interface.
README.md Updated documentation to include new filtering options.

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

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.

2 participants