From 4cb003629d311154dd41fe734dbffed02ed56c7e Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Tue, 19 Sep 2023 14:33:35 -0400 Subject: [PATCH] command: move inspect to schedulers --- command/inspect.go | 8 +------- command/scheduler.go | 1 + command/sequential_scheduler.go | 6 ++++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/command/inspect.go b/command/inspect.go index 7a77ab76b..682892fad 100644 --- a/command/inspect.go +++ b/command/inspect.go @@ -7,7 +7,6 @@ import ( "context" "strings" - "github.com/hashicorp/packer/packer" "github.com/posener/complete" ) @@ -48,12 +47,7 @@ func (c *InspectCommand) RunContext(ctx context.Context, cla *InspectArgs) int { return ret } - // here we ignore init diags to allow unknown variables to be used - _ = packerStarter.Initialize(packer.InitializeOptions{}) - - return packerStarter.InspectConfig(packer.InspectConfigOptions{ - Ui: c.Ui, - }) + return NewScheduler(packerStarter, c.Ui, ctx).Inspect(cla) } func (*InspectCommand) Help() string { diff --git a/command/scheduler.go b/command/scheduler.go index 4c7c59cf9..d3400a114 100644 --- a/command/scheduler.go +++ b/command/scheduler.go @@ -10,6 +10,7 @@ import ( type Scheduler interface { Build(*BuildArgs) int Validate(*ValidateArgs) int + Inspect(*InspectArgs) int } // NewScheduler returns a new scheduler for running commands with. diff --git a/command/sequential_scheduler.go b/command/sequential_scheduler.go index dd091c250..c45ffaf3f 100644 --- a/command/sequential_scheduler.go +++ b/command/sequential_scheduler.go @@ -77,7 +77,13 @@ func (s *SequentialScheduler) prepare(skipDatasourcesExecution bool) hcl.Diagnos diags = diags.Extend(s.scheduler.PrepareBuilds()) return diags +} +func (s *SequentialScheduler) Inspect(args *InspectArgs) int { + s.prepare(false) + return s.handler.InspectConfig(packer.InspectConfigOptions{ + Ui: s.ui, + }) } func (s *SequentialScheduler) Validate(args *ValidateArgs) int {