sonatype-nexus-community / nancy

A tool to check for vulnerabilities in your Golang dependencies, powered by Sonatype OSS Index
Apache License 2.0
564 stars 74 forks source link

Refactor config to use `config *interface{}` #111

Closed bhamail closed 4 years ago

bhamail commented 4 years ago

We've been sneaking up on changing the design of the OSSI / IQ config classes to support better reuse/reduced duplication/DRYness.

This Issue exists to track that, and collect ideas on how to git 'er done.

see: loadConfigFromFile(configLocation string, config *Configuration)

see: https://github.com/sonatype-nexus-community/nancy/pull/108/files

Another idea: refactor the configuration/parse.go -> loadConfigFromFile() and loadIQConfigFromFile() methods to take io.Reader - instead of a path configLocation. The tests could then easily pass in bytes representing the various file contents. This would also allow the test avoid pesky disk access.

And in the other direction, similarly use io.Writer instead of ConfigLocation inside configuration/set.go -> marshallAndWriteToDisk.

cc @bhamail / @DarthHater

DarthHater commented 4 years ago

I THINK I got a portion of simplifying things in #114 , where I avoided going super nuclear and using an interface as a param. Take a gander, bud!

bhamail commented 4 years ago

Also fixed by Cobra/Viper conversion. see #161