terraform/command/views
Alisdair McDiarmid 86495f93cb views: Fix missing source in diagnostic output
The previous implementation of views was copying and embedding the base
View struct in each individual view. While this allowed for easy access
to the interface of that struct (both in the view and externally), it more
importantly completely broke the ability of the diagnostic printer to
output source code snippets.

This is because the `configSources` field on the base view is lazily set
after the config loader is initialized. In the commands ported to use
views, this happens after the base View struct is copied, so we are
updating the wrong copy of the struct.

This commit fixes this with a simple mechanical refactor: keep a pointer
to the base View struct instead, and update all of the individual views
to explicitly refer to that struct to access its fields and methods.

This is not a particularly satisfying solution, but I can't find
anything clearly better. It might be worth exploring the alternative
approach in the view for the new test command, which explicitly pulls
its dependencies out of the base view, rather than retaining a full
reference. Maybe there's a third way which is better still.
2021-02-26 16:43:03 -05:00
..
apply.go views: Fix missing source in diagnostic output 2021-02-26 16:43:03 -05:00
apply_test.go cli: Migrate apply to command views 2021-02-22 11:47:40 -05:00
hook_count.go cli: Migrate apply to command views 2021-02-22 11:47:40 -05:00
hook_count_test.go cli: Migrate apply to command views 2021-02-22 11:47:40 -05:00
hook_ui.go cli: Fix misapplied terminal colors on run logs 2021-02-16 15:05:22 -05:00
hook_ui_test.go cli: Fix misapplied terminal colors on run logs 2021-02-16 15:05:22 -05:00
operation.go views: Fix missing source in diagnostic output 2021-02-26 16:43:03 -05:00
operation_test.go backend/local: Replace CLI with view instance 2021-02-18 12:08:08 -05:00
output.go views: Fix missing source in diagnostic output 2021-02-26 16:43:03 -05:00
output_test.go views: Expand test coverage for views.Output 2021-02-16 08:48:31 -05:00
plan.go views: Fix missing source in diagnostic output 2021-02-26 16:43:03 -05:00
plan_test.go cli: Migrate plan to command views 2021-02-23 10:09:25 -05:00
refresh.go views: Fix missing source in diagnostic output 2021-02-26 16:43:03 -05:00
refresh_test.go cli: Migrate refresh to command views 2021-02-22 11:58:52 -05:00
show.go backend/local: Replace CLI with view instance 2021-02-18 12:08:08 -05:00
state_locker.go views: Fix missing source in diagnostic output 2021-02-26 16:43:03 -05:00
test.go command: Experimental "terraform test" command 2021-02-22 14:21:45 -08:00
test_test.go command: Experimental "terraform test" command 2021-02-22 14:21:45 -08:00
view.go views: Remove outdated comment 2021-02-25 09:34:32 -05:00