|
|
@ -107,6 +107,20 @@ type staticConfig struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func ParseHCL(dt []byte, fn string) (_ *Config, err error) {
|
|
|
|
func ParseHCL(dt []byte, fn string) (_ *Config, err error) {
|
|
|
|
|
|
|
|
if strings.HasSuffix(fn, ".json") || strings.HasSuffix(fn, ".hcl") {
|
|
|
|
|
|
|
|
return parseHCL(dt, fn)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg, err := parseHCL(dt, fn+".hcl")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
cfg2, err2 := parseHCL(dt, fn+".json")
|
|
|
|
|
|
|
|
if err2 == nil {
|
|
|
|
|
|
|
|
return cfg2, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return cfg, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func parseHCL(dt []byte, fn string) (_ *Config, err error) {
|
|
|
|
defer func() {
|
|
|
|
defer func() {
|
|
|
|
err = formatHCLError(dt, err)
|
|
|
|
err = formatHCLError(dt, err)
|
|
|
|
}()
|
|
|
|
}()
|
|
|
@ -192,6 +206,7 @@ func formatHCLError(dt []byte, err error) error {
|
|
|
|
if d.Severity != hcl.DiagError {
|
|
|
|
if d.Severity != hcl.DiagError {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if d.Subject != nil {
|
|
|
|
src := errdefs.Source{
|
|
|
|
src := errdefs.Source{
|
|
|
|
Info: &pb.SourceInfo{
|
|
|
|
Info: &pb.SourceInfo{
|
|
|
|
Filename: d.Subject.Filename,
|
|
|
|
Filename: d.Subject.Filename,
|
|
|
@ -202,6 +217,7 @@ func formatHCLError(dt []byte, err error) error {
|
|
|
|
err = errdefs.WithSource(err, src)
|
|
|
|
err = errdefs.WithSource(err, src)
|
|
|
|
break
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|