command: move inspect to schedulers

This commit is contained in:
Lucas Bajolet
2023-10-11 14:28:27 -04:00
parent bc3bb07416
commit 4cb003629d
3 changed files with 8 additions and 7 deletions
+1 -7
View File
@@ -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 {
+1
View File
@@ -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.
+6
View File
@@ -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 {