708abb8c97
This is a super-invasive update since the "zcl" package in particular is referenced all over. There are probably still a few zcl references hanging around in comments, etc but this takes care of most of it.
30 lines
745 B
Go
30 lines
745 B
Go
package include
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/hcl2/hcl"
|
|
)
|
|
|
|
// MapResolver returns a Resolver that consults the given map for preloaded
|
|
// bodies (the values) associated with static include paths (the keys).
|
|
//
|
|
// An error diagnostic is returned if a path is requested that does not appear
|
|
// as a key in the given map.
|
|
func MapResolver(m map[string]hcl.Body) Resolver {
|
|
return ResolverFunc(func(path string, refRange hcl.Range) (hcl.Body, hcl.Diagnostics) {
|
|
if body, ok := m[path]; ok {
|
|
return body, nil
|
|
}
|
|
|
|
return nil, hcl.Diagnostics{
|
|
{
|
|
Severity: hcl.DiagError,
|
|
Summary: "Invalid include path",
|
|
Detail: fmt.Sprintf("The include path %q is not recognized.", path),
|
|
Subject: &refRange,
|
|
},
|
|
}
|
|
})
|
|
}
|