diff --git a/hcl2template/types.build.go b/hcl2template/types.build.go index 2c7170918..6f3485b95 100644 --- a/hcl2template/types.build.go +++ b/hcl2template/types.build.go @@ -48,23 +48,14 @@ func (p *Parser) decodeBuildConfig(block *hcl.Block) (*BuildBlock, hcl.Diagnosti for _, buildFrom := range b.FromSources { ref := sourceRefFromString(buildFrom) - if ref == NoSource { - diags = append(diags, &hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: "Invalid " + sourceLabel + " reference: " + buildFrom, - Detail: "A " + sourceLabel + " type must start with a letter and " + - "may contain only letters, digits, underscores, and dashes." + - "A valid source reference looks like: `source.type.name`", - Subject: block.DefRange.Ptr(), - }) - continue - } - if !hclsyntax.ValidIdentifier(ref.Type) || + if ref == NoSource || + !hclsyntax.ValidIdentifier(ref.Type) || !hclsyntax.ValidIdentifier(ref.Name) { diags = append(diags, &hcl.Diagnostic{ Severity: hcl.DiagError, Summary: "Invalid " + sourceLabel + " reference", - Detail: "A " + sourceLabel + " type must start with a letter and " + + Detail: "A " + sourceLabel + " type is made of three parts that are" + + "split by a dot `.`; each part must start with a letter and " + "may contain only letters, digits, underscores, and dashes." + "A valid source reference looks like: `source.type.name`", Subject: block.DefRange.Ptr(),