Description
We would like to push as much validation and processing out of the cmd/builder.go as possible. The cmds 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 into builder.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
- We need to keep
creator as well as library authors in mind here a bit. Having group, plan, err := restorer.Restore(cacheStore) makes sense for platforms building on top of lifecycle, 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 by cmd/builder.go. The validation that occurs in cmd/builder.go maybe shouldn't be executed by creator, for instance.
Description
We would like to push as much validation and processing out of the
cmd/builder.goas possible. Thecmdsare 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.gois probably the smallest compared to other phases but still has a bit of validation up front and error handling.Additional context
creatoras 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.gomaybe shouldn't be executed bycreator, for instance.