-
Notifications
You must be signed in to change notification settings - Fork 560
feat/drift filter block name #1997
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
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant GitHubCI
participant Env
participant ProjectList
GitHubCI->>Env: Read INPUT_DIGGER_BLOCK_FILTERS
Env-->>GitHubCI: Return comma-separated block filters
GitHubCI->>ProjectList: For each project in drift detection mode
alt Filters specified
GitHubCI->>ProjectList: Check if project's BlockName in filters
alt BlockName not in filters
GitHubCI-->>ProjectList: Skip project
else BlockName in filters
GitHubCI->>ProjectList: Process project for drift detection
end
else No filters
GitHubCI->>ProjectList: Process all projects for drift detection
end
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
PR Summary
Implements block name filtering functionality for Terragrunt projects, allowing more granular control over drift detection and project configuration.
- Added
BlockName
field toProject
andProjectYaml
structs inlibs/digger_config/config.go
andyaml.go
for block-level identification - Introduced
INPUT_DIGGER_BLOCK_FILTERS
environment variable incli/pkg/github/github.go
for filtering drift detection by specific block names - Enhanced
hydrateDiggerConfigYamlWithTerragrunt
function inlibs/digger_config/digger_config.go
to support block name propagation - Potential issue: Duplicate 'workspace' field assignment in
libs/digger_config/converters.go
needs review
5 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile
blockFiltersStr := os.Getenv("INPUT_DIGGER_BLOCK_FILTERS") | ||
blockFilters := strings.Split(blockFiltersStr, ",") |
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.
style: Consider validating blockFiltersStr is not empty before splitting. Empty string will result in a slice with one empty string element.
if len(blockFilters) > 0 { | ||
projectInBlock := false | ||
if lo.Contains(blockFilters, projectConfig.BlockName) { | ||
projectInBlock = true | ||
} | ||
if !projectInBlock { | ||
continue | ||
} | ||
} |
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.
style: This block can be simplified using lo.Contains(blockFilters, projectConfig.BlockName). No need for extra boolean variable.
if len(blockFilters) > 0 { | |
projectInBlock := false | |
if lo.Contains(blockFilters, projectConfig.BlockName) { | |
projectInBlock = true | |
} | |
if !projectInBlock { | |
continue | |
} | |
} | |
if len(blockFilters) > 0 && !lo.Contains(blockFilters, projectConfig.BlockName) { | |
continue | |
} |
✅ No security or compliance issues detected. Reviewed everything up to 6e37c91. Security Overview
Detected Code Changes
Reply to this PR with |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
cli/pkg/github/github.go (1)
185-199
: Consider handling empty filter case more explicitly.The filtering logic is well-implemented, but there's a potential edge case: when
INPUT_DIGGER_BLOCK_FILTERS
is empty,strings.Split
will return[""]
instead of an empty slice, which could cause unintended filtering behavior.Consider this improvement:
blockFiltersStr := os.Getenv("INPUT_DIGGER_BLOCK_FILTERS") -blockFilters := strings.Split(blockFiltersStr, ",") +var blockFilters []string +if blockFiltersStr != "" { + blockFilters = strings.Split(blockFiltersStr, ",") +} for _, projectConfig := range diggerConfig.Projects { if !projectConfig.DriftDetection { continue } - if len(blockFilters) > 0 { + if len(blockFilters) > 0 && blockFiltersStr != "" { projectInBlock := false if lo.Contains(blockFilters, projectConfig.BlockName) { projectInBlock = true } if !projectInBlock { continue } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
cli/pkg/github/github.go
(2 hunks)libs/digger_config/config.go
(1 hunks)libs/digger_config/converters.go
(1 hunks)libs/digger_config/digger_config.go
(5 hunks)libs/digger_config/yaml.go
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (78)
- GitHub Check: binary (386, freebsd)
- GitHub Check: binary (386, windows)
- GitHub Check: binary (386, linux)
- GitHub Check: binary (amd64, linux)
- GitHub Check: binary (arm64, linux)
- GitHub Check: binary (amd64, windows)
- GitHub Check: binary (arm64, freebsd)
- GitHub Check: binary (amd64, darwin)
- GitHub Check: binary (amd64, freebsd)
- GitHub Check: binary (arm64, darwin)
- GitHub Check: binary (arm64, windows)
- GitHub Check: binary (arm, freebsd)
- GitHub Check: binary (arm, windows)
- GitHub Check: binary (arm, linux)
- GitHub Check: build-and-push-image
- GitHub Check: binary (386, freebsd)
- GitHub Check: binary (arm, windows)
- GitHub Check: binary (386, linux)
- GitHub Check: binary (386, linux)
- GitHub Check: binary (amd64, windows)
- GitHub Check: binary (386, windows)
- GitHub Check: binary (amd64, darwin)
- GitHub Check: binary (arm64, freebsd)
- GitHub Check: binary (amd64, linux)
- GitHub Check: binary (amd64, darwin)
- GitHub Check: binary (arm64, windows)
- GitHub Check: binary (arm64, darwin)
- GitHub Check: binary (386, windows)
- GitHub Check: binary (amd64, linux)
- GitHub Check: binary (amd64, freebsd)
- GitHub Check: binary (amd64, freebsd)
- GitHub Check: binary (arm, linux)
- GitHub Check: binary (arm64, freebsd)
- GitHub Check: binary (amd64, windows)
- GitHub Check: binary (arm, windows)
- GitHub Check: binary (386, windows)
- GitHub Check: binary (arm, freebsd)
- GitHub Check: binary (386, freebsd)
- GitHub Check: binary (arm64, darwin)
- GitHub Check: binary (arm64, windows)
- GitHub Check: binary (arm64, linux)
- GitHub Check: binary (arm, freebsd)
- GitHub Check: binary (arm64, linux)
- GitHub Check: binary (arm, linux)
- GitHub Check: binary (386, freebsd)
- GitHub Check: binary (386, linux)
- GitHub Check: binary (amd64, windows)
- GitHub Check: binary (amd64, darwin)
- GitHub Check: binary (arm64, windows)
- GitHub Check: binary (amd64, linux)
- GitHub Check: binary (amd64, freebsd)
- GitHub Check: binary (arm64, linux)
- GitHub Check: binary (arm, windows)
- GitHub Check: binary (arm64, darwin)
- GitHub Check: binary (arm, linux)
- GitHub Check: binary (arm64, freebsd)
- GitHub Check: binary (arm, freebsd)
- GitHub Check: Build
- GitHub Check: binary
- GitHub Check: build-and-push-image
- GitHub Check: Build
- GitHub Check: build-and-push-image
- GitHub Check: binary
- GitHub Check: Build
- GitHub Check: build-and-push-image
- GitHub Check: binary
- GitHub Check: build-and-push-image
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Security Check
- GitHub Check: Build
- GitHub Check: Build
- GitHub Check: Build
🔇 Additional comments (10)
libs/digger_config/config.go (1)
45-45
: LGTM! Clean addition of BlockName field.The addition of the
BlockName
field to theProject
struct is well-documented and appropriately placed. The comment clearly indicates its purpose for generated projects.libs/digger_config/converters.go (1)
72-90
: LGTM! Proper struct field initialization.The Project struct initialization correctly includes the new
BlockName
field in the proper position, maintaining consistency with the struct definition and properly copying the value from the sourceProjectYaml
.cli/pkg/github/github.go (1)
22-22
: LGTM! Appropriate library import.The addition of the
lo
import is appropriate for the filtering functionality being implemented.libs/digger_config/yaml.go (2)
38-38
: LGTM! Proper YAML field addition.The
BlockName
field is correctly added to theProjectYaml
struct with the appropriate YAML tagblock_name
.
112-114
: LGTM! Clean struct field additions and formatting.The formatting improvements and addition of the
TerragruntParsingConfig
field are well-implemented and consistent with the overall changes.libs/digger_config/digger_config.go (5)
702-702
: LGTM! Function signature enhancement.The addition of the
blockName
parameter tohydrateDiggerConfigYamlWithTerragrunt
is well-designed and enables proper block name propagation during project generation.
332-332
: LGTM! Consistent function call update.The function call correctly passes an empty string for the blockName parameter when using deprecated top-level terragrunt configuration.
341-341
: LGTM! Consistent function call update.The function call correctly passes an empty string for the blockName parameter for the deprecated terragrunt configuration path.
412-423
: LGTM! Proper terragrunt parsing configuration.The terragrunt parsing configuration initialization and override logic is well-implemented. The code properly handles the case where no parsing config exists and appropriately sets the necessary fields for project generation.
809-809
: LGTM! Correct BlockName assignment.The
BlockName
field is properly assigned during project creation, ensuring the block name is propagated to generated projects for later filtering.
Summary by CodeRabbit