Files
Lucas Bajolet 8df9ff3ab1 command: introduce schedulers and centralise logic
As we move on to introduce a DAG into Packer, we are introducing a
Scheduler interface, as well as a first implementation of it which
replicates the current scheduling algorithm, but centralises all the
code related to evaluation and execution of components.

This won't pass tests in the current state as only the logic has
changed, and tests haven't been updated yet. This will come later in the
refactoring process.
2023-08-11 16:01:51 -04:00

22 lines
639 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package hcl2template
import (
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hcldec"
"github.com/zclconf/go-cty/cty"
)
// Decodable structs are structs that can tell their hcl2 ObjectSpec; this
// config spec will be passed to hcldec.Decode and the result will be a
// cty.Value. This Value can then be applied on the said struct.
type Decodable interface {
ConfigSpec() hcldec.ObjectSpec
}
func DecodeHCL2Spec(body hcl.Body, ectx *hcl.EvalContext, dec Decodable) (cty.Value, hcl.Diagnostics) {
return hcldec.Decode(body, dec.ConfigSpec(), ectx)
}