Open jabrown85 opened 3 years ago
See #805 (analyzer) and #860 (detector) for how this is done for other phases.
is there anything specific you would like to move out from the cmd/lifecycle/builder.go
? It already looks rather minimal tbh
The restorer and the exporter are the real culprits here. It's likely we could add some units around builder instantiation.
Description
We would like to push as much validation and processing out of the
cmd/builder.go
as possible. Thecmds
are hard to test and keep growing because there is already validation logic present.Proposed solution
Instead of validating inside of
cmd/builder.go
, we should put as much validation as possible intobuilder.go
. This probably means introducing and using interfaces that wrap file, and env access. We should write unit tests to cover and possibly remove validation specific acceptance tests.cmd/builder.go
is probably the smallest compared to other phases but still has a bit of validation up front and error handling.Additional context
creator
as well as library authors in mind here a bit. Havinggroup, plan, err := restorer.Restore(cacheStore)
makes sense for platforms building on top oflifecycle
, like buildkit. So we may wish to introduce new methods that write the files that can optionally be executed by those platforms and always executed bycmd/builder.go
. The validation that occurs incmd/builder.go
maybe shouldn't be executed bycreator
, for instance.