Skip to content

Commit e42dd73

Browse files
authored
Merge pull request #78 from cloudskiff/driftignore_field_case_insensitive
Make driftignore fields case-insensitive
2 parents 1abe965 + 97575cb commit e42dd73

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

doc/cmd/scan/filter.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ Create the .driftignore file where you launch driftctl (usually the root of your
1818

1919
Each line must be of kind
2020
- `resource_type.resource_id`, resource_id could be a wildcard to exclude all resources of a given type.
21-
- `resource_type.resource_id.path.to.field`, resource_id can be wildcard to ignore a drift on given field for a given type, path could also contain wildcards.
21+
- `resource_type.resource_id.path.to.FieldName`, resource_id can be wildcard to ignore a drift on given field for a given type, path could also contain wildcards.
22+
23+
**N.B.** Fields are not case-sensitive.
2224

2325
If your resource id or the path of a field contains dot or backslash you can escape them with backslashes:
2426
```ignore
25-
resource_type.resource\.id\.containing\.dots.path.to.dotted\.fieldname
26-
resource_type.resource_id_containing\\backslash.path.to.backslash\\fieldname
27+
resource_type.resource\.id\.containing\.dots.path.to.dotted\.FieldName
28+
resource_type.resource_id_containing\\backslash.path.to.backslash\\FieldName
2729
```
2830

2931
### Example
@@ -34,9 +36,9 @@ aws_s3_bucket.my-buckey
3436
# Will ignore every aws_instance resource
3537
aws_instance.*
3638
# Will ignore environement for all lambda functions
37-
aws_lambda_function.*.environment
39+
aws_lambda_function.*.Environment
3840
# Will ignore lastModified for my-lambda-name lambda function
39-
aws_lambda_function.my-lambda-name.lastmodified
41+
aws_lambda_function.my-lambda-name.LastModified
4042
```
4143

4244
## Filter rules

pkg/filter/driftignore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ RuleCheck:
112112
}
113113

114114
for i := range path {
115-
if path[i] != strings.ToLower(changePath[i]) && path[i] != "*" {
115+
if !strings.EqualFold(path[i], changePath[i]) && path[i] != "*" {
116116
continue RuleCheck // found a diff in path that was not a wildcard
117117
}
118118
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
res_type.full_drift_ignored.json
1+
res_type.full_drift_ignored.Json
22
res_type.full_drift_ignored.foobar
3-
res_type.partial_drift_ignored.foobar
4-
res_type.wildcard_drift_ignored.*.baz
5-
res_type.endofpath_drift_ignored.struct
6-
resource_type.id\.with\.dots.json
7-
resource_type.idwith\\.json
8-
resource_type.idwith\\backslashes.foobar
3+
res_type.partial_drift_ignored.Foobar
4+
res_type.wildcard_drift_ignored.*.Baz
5+
res_type.endofpath_drift_ignored.Struct
6+
resource_type.id\.with\.dots.Json
7+
resource_type.idwith\\.Json
8+
resource_type.idwith\\backslashes.Foobar

0 commit comments

Comments
 (0)