@@ -6,6 +6,7 @@ package internal
66import (
77 "fmt"
88 "path/filepath"
9+ "sort"
910 "strings"
1011)
1112
@@ -67,35 +68,37 @@ func printDiff(resources []Resource, schema ProviderSchema, model, tool, prompt,
6768 return nil
6869}
6970
70- func findUnusedAttributes (usedAttrs map [string ]string , possibleAttrs map [string ]interface {} ) []string {
71- validNames := make (map [string ]struct {})
71+ func findUnusedAttributes (usedAttrs map [string ]string , possibleAttrs map [string ]any ) []string {
72+ validNames := make (map [string ]struct {})
7273
73- if blockAny , ok := possibleAttrs ["block" ]; ok {
74- if block , ok := blockAny .(map [string ]interface {}); ok {
75- //Attributes at the current block level
76- if attrsAny , ok := block ["attributes" ]; ok {
77- if attrsMap , ok := attrsAny .(map [string ]interface {}); ok {
78- for name := range attrsMap {
79- validNames [name ] = struct {}{}
80- }
81- }
82- }
83- // Nested block types at this level (their names appear as top-level blocks in HCL)
84- if blockTypesAny , ok := block ["block_types" ]; ok {
85- if btMap , ok := blockTypesAny .(map [string ]interface {}); ok {
86- for name := range btMap {
87- validNames [name ] = struct {}{}
88- }
89- }
90- }
91- }
92- }
74+ if blockAny , ok := possibleAttrs ["block" ]; ok {
75+ if block , ok := blockAny .(map [string ]any ); ok {
76+ // Attributes at the current block level
77+ if attrsAny , ok := block ["attributes" ]; ok {
78+ if attrsMap , ok := attrsAny .(map [string ]any ); ok {
79+ for name := range attrsMap {
80+ validNames [name ] = struct {}{}
81+ }
82+ }
83+ }
84+ // Nested block types at this level (their names appear as top-level blocks in HCL)
85+ if blockTypesAny , ok := block ["block_types" ]; ok {
86+ if btMap , ok := blockTypesAny .(map [string ]any ); ok {
87+ for name := range btMap {
88+ validNames [name ] = struct {}{}
89+ }
90+ }
91+ }
92+ }
93+ }
94+
95+ var unused []string
96+ for name := range validNames {
97+ if _ , used := usedAttrs [name ]; ! used {
98+ unused = append (unused , name )
99+ }
100+ }
101+ sort .Strings (unused )
93102
94- var unused []string
95- for name := range validNames {
96- if _ , used := usedAttrs [name ]; ! used {
97- unused = append (unused , name )
98- }
99- }
100- return unused
103+ return unused
101104}
0 commit comments