8000 Revert "feat: add iac source to drift in console output" by functionstackx · Pull Request #962 · snyk/driftctl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Revert "feat: add iac source to drift in console output" #962

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions pkg/cmd/scan/output/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,13 @@ func NewConsole() *Console {

func (c *Console) Write(analysis *analyser.Analysis) error {
if analysis.Summary().TotalDeleted > 0 {
groupedBySource := make(map[string][]*resource.Resource)

for _, deletedResource := range analysis.Deleted() {
key := deletedResource.Source.Source()

if _, exist := groupedBySource[key]; !exist {
groupedBySource[key] = []*resource.Resource{deletedResource}
continue
}

groupedBySource[key] = append(groupedBySource[key], deletedResource)
}

fmt.Println("Found missing resources:")

for source, deletedResources := range groupedBySource {
fmt.Print(color.BlueString(" From %s\n", source))
for _, deletedResource := range deletedResources {
humanString := fmt.Sprintf(" - %s (%s)", deletedResource.ResourceId(), deletedResource.SourceString())

if humanAttrs := formatResourceAttributes(deletedResource); humanAttrs != "" {
deletedByType, keys := groupByType(analysis.Deleted())
for _, ty := range keys {
fmt.Printf(" %s:\n", ty)
for _, res := range deletedByType[ty] {
humanString := fmt.Sprintf(" - %s", res.ResourceId())
if humanAttrs := formatResourceAttributes(res); humanAttrs != "" {
humanString += fmt.Sprintf("\n %s", humanAttrs)
}
fmt.Println(humanString)
Expand Down
10 changes: 0 additions & 10 deletions pkg/cmd/scan/output/console_test.go
10000
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,10 @@ func TestConsole_Write(t *testing.T) {
&resource.Resource{
Id: "test-id-1",
Type: "aws_test_resource",
Source: &resource.TerraformStateSource{
State: "tfstate://test_state.tfstate",
Module: "module",
Name: "name",
},
},
&resource.Resource{
Id: "test-id-2",
Type: "aws_test_resource",
Source: &resource.TerraformStateSource{
State: "tfstate://test_state.tfstate",
Module: "module",
Name: "name",
},
},
)
a.AddUnmanaged(
Expand Down
20 changes: 0 additions & 20 deletions pkg/cmd/scan/output/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,9 @@ func fakeAnalysis() *analyser.Analysis {
&resource.Resource{
Id: "deleted-id-1",
Type: "aws_deleted_resource",
Source: &resource.TerraformStateSource{
State: "tfstate://delete_state.tfstate",
Module: "module",
Name: "name",
},
}, &resource.Resource{
Id: "deleted-id-2",
Type: "aws_deleted_resource",
Source: &resource.TerraformStateSource{
State: "tfstate://delete_state.tfstate",
Module: "module",
Name: "name",
},
},
)
a.AddManaged(
Expand Down Expand Up @@ -189,11 +179,6 @@ func fakeAnalysisWithoutAttrs() *analyser.Analysis {
Id: "dfjkgnbsgj",
Type: "FakeResourceStringer",
Attrs: &resource.Attributes{},
Source: &resource.TerraformStateSource{
State: "tfstate://state.tfstate",
Module: "module",
Name: "name",
},
},
)
a.AddManaged(
Expand Down Expand Up @@ -230,11 +215,6 @@ func fakeAnalysisWithStringerResources() *analyser.Analysis {
Attrs: &resource.Attributes{
"name": "deleted resource",
},
Source: &resource.TerraformStateSource{
State: "tfstate://state.tfstate",
Module: "module",
Name: "name",
},
},
)
a.AddManaged(
Expand Down
14 changes: 2 additions & 12 deletions pkg/cmd/scan/output/testdata/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,11 @@
"missing": [
{
"id": "deleted-id-1",
"type": "aws_deleted_resource",
"source": {
"source": "tfstate://delete_state.tfstate",
"namespace": "module",
"internal_name": "name"
}
"type": "aws_deleted_resource"
},
{
"id": "deleted-id-2",
"type": "aws_deleted_resource",
"source": {
"source": "tfstate://delete_state.tfstate",
"namespace": "module",
"internal_name": "name"
}
"type": "aws_deleted_resource"
}
],
"differences": [
Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/scan/output/testdata/output.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Found missing resources:
From tfstate://delete_state.tfstate
- deleted-id-1 (module.aws_deleted_resource.name)
- deleted-id-2 (module.aws_deleted_resource.name)
From tfstate://test_state.tfstate
- test-id-1 (module.aws_test_resource.name)
- test-id-2 (module.aws_test_resource.name)
aws_deleted_resource:
- deleted-id-1
- deleted-id-2
aws_test_resource:
- test-id-1
- test-id-2
Found resources not covered by IaC:
aws_resource:
- test-id-2
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/scan/output/testdata/output_empty_attributes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Found missing resources:
From tfstate://state.tfstate
- dfjkgnbsgj (module.FakeResourceStringer.name)
FakeResourceStringer:
- dfjkgnbsgj
Found resources not covered by IaC:
FakeResourceStringer:
- duysgkfdjfdgfhd
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/scan/output/testdata/output_stringer_resources.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Found missing resources:
From tfstate://state.tfstate
- dfjkgnbsgj (module.FakeResourceStringer.name)
FakeResourceStringer:
- dfjkgnbsgj
Name: deleted resource
Found resources not covered by IaC:
FakeResourceStringer:
Expand Down
0