pulumi/pkg/errors/binder.go
joeduffy 4cf6be0f07 Add some property binding tests
This change adds a handful of property binding tests.

It also fixes:

* AsName should assert IsName.

* Enumerate properties stably, so that it is deterministic.

* Do not issue errors about unrecognized properties for the special
  `mu/extension` type.  It's entire purpose in life is to offer an
  entirely custom set of properties, which the provider is meant to
  validate.

* Default to an empty map if properties are missing.

* Add a "/" to the end of the namespace from the workspace, if present.

And rearranges some code:

* Rename the LiteralX types to XLiteral; e.g., StringLiteral instead of
  LiteralString.  I kept typing XLiteral erroneously.

* Eliminate the Mu prefix on all of the predefined type and service
  functions and types.  It's superfluous and reads nicer this way.

* Swap the order of "expected" vs. "got" in the error message about
  incorrect property types.  It used to say "got %v, expected %v"; I
  personally find that it is more helpful if it says "expected %v,
  got %v".  YMMV.
2016-12-02 14:33:22 -08:00

85 lines
2.2 KiB
Go

// Copyright 2016 Marapongo, Inc. All rights reserved.
package errors
import (
"github.com/marapongo/mu/pkg/ast"
"github.com/marapongo/mu/pkg/diag"
)
var ErrorMissingStackName = &diag.Diag{
ID: 500,
Message: "This Stack is missing a `name` property (or it is empty)",
}
var ErrorIllegalStackVersion = &diag.Diag{
ID: 501,
Message: "This Stack's version '%v' is invalid: %v",
}
var ErrorSymbolAlreadyExists = &diag.Diag{
ID: 502,
Message: "A symbol already exists with the name '%v'",
}
var ErrorStackTypeNotFound = &diag.Diag{
ID: 503,
Message: "Stack type '%v' was not found; has it been installed?",
}
var ErrorNonAbstractStacksMustDefineServices = &diag.Diag{
ID: 504,
Message: "Non-abstract stacks must declare at least one private or public service",
}
var ErrorMalformedStackReference = &diag.Diag{
ID: 505,
Message: "The stack reference '%v' is malformed; " +
"expected format is '[[proto://]base.url/]stack/../name[@version]': %v",
}
var ErrorMissingRequiredProperty = &diag.Diag{
ID: 506,
Message: "Missing required property '%v' on '%v'",
}
var ErrorUnrecognizedProperty = &diag.Diag{
ID: 505,
Message: "Unrecognized property '%v' on '%v'",
}
var ErrorIncorrectPropertyType = &diag.Diag{
ID: 506,
Message: "Property '%v' has the wrong type; expected '%v', got '%v', on '%v'",
}
var ErrorServiceNotFound = &diag.Diag{
ID: 507,
Message: "A service named '%v' was not found",
}
var ErrorServiceHasNoPublics = &diag.Diag{
ID: 508,
Message: "The service '%v' of type '%v' has no public entrypoint; it cannot be referenced",
}
var ErrorServiceHasManyPublics = &diag.Diag{
ID: 508,
Message: "The service '%v' of type '%v' has multiple public entrypoints; please choose one using a selector",
}
var ErrorServiceSelectorNotFound = &diag.Diag{
ID: 509,
Message: "No public by the given selector '%v' was found in service '%v' of type '%v'",
}
var ErrorServiceSelectorIsPrivate = &diag.Diag{
ID: 510,
Message: "The given selector '%v' references a private service in '%v' of type '%v'; it must be public",
}
var ErrorNotAName = &diag.Diag{
ID: 511,
Message: "The string '%v' is not a valid name (expected: " + ast.NamePartRegexps + ")",
}