pulumi/pkg/codegen/hcl2/diagnostics.go
CyrusNajmabadi 66bd3f4aa8
Breaking changes due to Feature 2.0 work
* Make `async:true` the default for `invoke` calls (#3750)

* Switch away from native grpc impl. (#3728)

* Remove usage of the 'deasync' library from @pulumi/pulumi. (#3752)

* Only retry as long as we get unavailable back.  Anything else continues. (#3769)

* Handle all errors for now. (#3781)


* Do not assume --yes was present when using pulumi in non-interactive mode (#3793)

* Upgrade all paths for sdk and pkg to v2

* Backport C# invoke classes and other recent gen changes (#4288)

Adjust C# generation

* Replace IDeployment with a sealed class (#4318)

Replace IDeployment with a sealed class

* .NET: default to args subtype rather than Args.Empty (#4320)

* Adding system namespace for Dotnet code gen

This is required for using Obsolute attributes for deprecations

```
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
```

* Fix the nullability of config type properties in C# codegen (#4379)
2020-04-14 09:30:25 +01:00

71 lines
2.2 KiB
Go

package hcl2
import (
"fmt"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclsyntax"
"github.com/pulumi/pulumi/pkg/v2/codegen/hcl2/model"
)
func errorf(subject hcl.Range, f string, args ...interface{}) *hcl.Diagnostic {
return diagf(hcl.DiagError, subject, f, args...)
}
func diagf(severity hcl.DiagnosticSeverity, subject hcl.Range, f string, args ...interface{}) *hcl.Diagnostic {
message := fmt.Sprintf(f, args...)
return &hcl.Diagnostic{
Severity: severity,
Summary: message,
Detail: message,
Subject: &subject,
}
}
func labelsErrorf(block *hclsyntax.Block, f string, args ...interface{}) *hcl.Diagnostic {
startRange := block.LabelRanges[0]
diagRange := hcl.Range{
Filename: startRange.Filename,
Start: startRange.Start,
End: block.LabelRanges[len(block.LabelRanges)-1].End,
}
return errorf(diagRange, f, args...)
}
func malformedToken(token string, sourceRange hcl.Range) *hcl.Diagnostic {
return errorf(sourceRange, "malformed token '%v': expected 'pkg:module:member'", token)
}
func unknownPackage(pkg string, tokenRange hcl.Range) *hcl.Diagnostic {
return errorf(tokenRange, "unknown package '%s'", pkg)
}
func unknownResourceType(token string, tokenRange hcl.Range) *hcl.Diagnostic {
return errorf(tokenRange, "unknown resource type '%s'", token)
}
func unknownFunction(token string, tokenRange hcl.Range) *hcl.Diagnostic {
return errorf(tokenRange, "unknown function '%s'", token)
}
func unsupportedBlock(blockType string, typeRange hcl.Range) *hcl.Diagnostic {
return errorf(typeRange, "unsupported block of type '%v'", blockType)
}
func unsupportedAttribute(attrName string, nameRange hcl.Range) *hcl.Diagnostic {
return errorf(nameRange, "unsupported attribute '%v'", attrName)
}
func missingRequiredAttribute(attrName string, missingRange hcl.Range) *hcl.Diagnostic {
return errorf(missingRange, "missing required attribute '%v'", attrName)
}
func tokenMustBeStringLiteral(tokenExpr model.Expression) *hcl.Diagnostic {
return errorf(tokenExpr.SyntaxNode().Range(), "invoke token must be a string literal")
}
func duplicateBlock(blockType string, typeRange hcl.Range) *hcl.Diagnostic {
return errorf(typeRange, "duplicate block of type '%v'", blockType)
}