ekristen / libnuke

Common Golang Packages for use by the Various Cloud Nuke Tools
MIT License
20 stars 3 forks source link

Incompatible `Filter.Invert` data type when using rebuy-de/aws-nuke config #54

Closed darkowlzz closed 2 months ago

darkowlzz commented 2 months ago

While migrating from rebuy-de/aws-nuke to libnuke in https://github.com/fluxcd/test-infra/pull/39, I encountered a panic due to the invert filter at https://github.com/ekristen/libnuke/blob/v0.15.0/pkg/filter/filter.go#L210 for a boolean value. Changing the invert value from boolean to string resolves the issue.

$ aws-nuke run -c nuke-cfg.yaml 
panic: interface conversion: interface {} is bool, not string [recovered]
    panic: interface conversion: interface {} is bool, not string [recovered]
    panic: interface conversion: interface {} is bool, not string

goroutine 1 [running]:
main.main.func1()
    /github.com/ekristen/aws-nuke/main.go:26 +0x54
panic({0x541b5e0?, 0xc00044b770?})
    /go/src/runtime/panic.go:770 +0x132
gopkg.in/yaml%2ev2.handleErr(0xc00059f118)
    /go/pkg/mod/gopkg.in/yaml.v2@v2.4.0/yaml.go:249 +0x6d
panic({0x541b5e0?, 0xc00044b770?})
    /go/src/runtime/panic.go:770 +0x132
github.com/ekristen/libnuke/pkg/filter.(*Filter).UnmarshalYAML(0xc0001144e0, 0xc000075d80)
    /go/pkg/mod/github.com/ekristen/libnuke@v0.15.0/pkg/filter/filter.go:210 +0x4d0
gopkg.in/yaml%2ev2.(*decoder).callUnmarshaler(0xc0001143c0, 0xc0005496c0, {0x7b17601f0198, 0xc0001144e0})
    /go/pkg/mod/gopkg.in/yaml.v2@v2.4.0/decode.go:270 +0x94
...

It may have been an intentional incompatibility. But since I couldn't find any mention of it, thought of reporting it. Please close the issue if this is known and intentional.

Thanks for a nice alternative tool and library :slightly_smiling_face:

ekristen commented 2 months ago

@darkowlzz thanks for taking the time to submit an issue. It is suppose to be 100% backwards compatible. It also should be handling it just fine as a string or a bool, at least it was at one point.

ekristen commented 2 months ago

@darkowlzz looks like the current code base for rebuy-de expects a string as well. Although it's not doing a cast so maybe it accepts the bool value just fine.

I do think that it should be a bool though, maybe I should change it to support both for the short term.

ekristen commented 2 months ago

:tada: This issue has been resolved in version 0.15.1 :tada:

The release is available on GitHub release :rocket:

ekristen commented 2 months ago

@darkowlzz https://github.com/ekristen/aws-nuke/releases/tag/v3.0.1