-
Notifications
You must be signed in to change notification settings - Fork 2
aws/az network scans #26
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7a0d512
initial work
j7m4 89463f5
Merge branch 'main' into j7m4/aws-az-network-scan
j7m4 431150c
fix bad google/networks change
j7m4 cef2738
more aws/az network sync, wip
j7m4 9f2a5d5
aws/az networks sync successfully
j7m4 88931bc
aws/az networks: fixed nil protection & race conditions, added networ…
j7m4 e2b7f19
better metadata, more nil fixes
j7m4 a9cd890
more nil fixes
j7m4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package common | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "github.com/charmbracelet/log" | ||
| "strings" | ||
| ) | ||
|
|
||
| // EnsureProviderDetails generates a provider name and region string based on the provided parameters. | ||
| // The | ||
| func EnsureProviderDetails( | ||
| ctx context.Context, prefix string, regions []string, name *string, | ||
| ) { | ||
| providerRegion := "all-regions" | ||
| // Use regions for name if none provided | ||
| if regions != nil && len(regions) > 0 { | ||
| providerRegion = strings.Join(regions, "-") | ||
| } | ||
|
|
||
| // If name is not provided, try to get account ID to include in the provider name | ||
| if name == nil { | ||
| name = new(string) | ||
| } | ||
| if *name == "" { | ||
| // Get AWS account ID for provider name using common package | ||
| cfg, err := InitAWSConfig(ctx, regions[0]) | ||
| if err != nil { | ||
| log.Warn("Failed to load AWS config for account ID retrieval", "error", err) | ||
| *name = fmt.Sprintf("%s-%s", prefix, providerRegion) | ||
| } else { | ||
| accountID, err := GetAccountID(ctx, cfg) | ||
| if err == nil { | ||
| log.Info("Retrieved AWS account ID", "account_id", accountID) | ||
| *name = fmt.Sprintf("%s-%s-%s", prefix, accountID, providerRegion) | ||
| } else { | ||
| log.Warn("Failed to get AWS account ID", "error", err) | ||
| *name = fmt.Sprintf("%s-%s", prefix, providerRegion) | ||
| } | ||
| } | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential panic with empty regions slice.
The function tries to access
regions[0]without checking if the slice has any elements, which could cause a panic if regions is empty.📝 Committable suggestion