Skip to content

Commit

Permalink
Skipping disabled components on atmos describe afffected (#942)
Browse files Browse the repository at this point in the history
* Skipping disabled components on atmos describe afffected

* Removing test as it is not working

---------

Co-authored-by: Andriy Knysh <aknysh@users.noreply.github.com>
  • Loading branch information
shirkevich and aknysh authored Jan 21, 2025
1 parent 15bad9a commit e645a03
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions internal/exec/describe_affected_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@ func findAffected(
continue
}
}
// Use helper function to skip disabled components
if !isComponentEnabled(metadataSection, componentName, atmosConfig) {
continue
}
// Check `metadata` section
if !isEqual(remoteStacks, stackName, "terraform", componentName, metadataSection, "metadata") {
affected := schema.Affected{
Expand Down Expand Up @@ -793,6 +797,10 @@ func findAffected(
continue
}
}
// Use helper function to skip disabled components
if !isComponentEnabled(metadataSection, componentName, atmosConfig) {
continue
}
// Check `metadata` section
if !isEqual(remoteStacks, stackName, "helmfile", componentName, metadataSection, "metadata") {
affected := schema.Affected{
Expand Down Expand Up @@ -1512,3 +1520,14 @@ func processIncludedInDependenciesForDependents(dependents *[]schema.Dependent,
}
return false
}

// isComponentEnabled checks if a component is enabled based on its metadata
func isComponentEnabled(metadataSection map[string]any, componentName string, atmosConfig schema.AtmosConfiguration) bool {
if enabled, ok := metadataSection["enabled"].(bool); ok {
if !enabled {
u.LogTrace(atmosConfig, fmt.Sprintf("Skipping disabled component %s", componentName))
return false
}
}
return true
}

0 comments on commit e645a03

Please sign in to comment.