Hi again, we have an ongoing discussion regarding ...
# contribute
q
Hi again, we have an ongoing discussion regarding the correctness of resource types. Docs here: https://www.pulumi.com/docs/concepts/resources/names/#types suggest that valid syntaxes are:
<package>:<module>:<typename>
(we implement this and fail validation at compile time if string doesn't match this pattern) and
<package>:<typename>
where this implies
<package>:index:<typename>
(we don't support this yet, hence the discussion). Introspection into your code and into codegen integration tests suggests that actually supported shorthand pattern is not
<package>:<typename>
but
<package>::<typename>
with empty module segment. This is further corroborated by metaschema here: https://github.com/pulumi/pulumi/blob/master/developer-docs/providers/metaschema.md#token which suggests this regex:
^[a-zA-Z][-a-zA-Z0-9_]*:([^0-9][a-zA-Z0-9._/-]*)?:[^0-9][a-zA-Z0-9._/]*$
which also allows
x:y:z
and
x::z
but not
x:z
. Is documentation misguided here?
e
<package>::<typename>
will cause inconsistencies in other parts of the system so that definitely can't be the right answer here! Having said that, it wouldn't surprise me if parts of the system were trying to do that and just resulting in slightly incorrect answers that hadn't been picked up on. The metaschema and token validation are broken if they're accepting "pkg::typ" but not "pkg:typ". I'll dig in and see if we can straighten this out. I've been looking into this area this week anyway (e.g. https://github.com/pulumi/pulumi/pull/14441 to check that "::" isn't used in component type names)
q
Well,
<package>::<typename>
is exactly what works and is implemented in the core 😱
e
yup, but will break URNs because they split at "::" markers
q
Ok, so the proper way will be
<package>:<module>:<typename>
or
<package>:<typename>
where this implies
<package>:index:<typename>
, right? I think if you introduce this change now a lot of stuff will break on your side. For instance, we have just ported integration tests for codegen to failproof it and check what's missing and I think most of those tests use this format:
"mypkg::Resource"
.
We found about this when these exact tests failed to compile due to:
Copy code
[error] A component resource must register a unique type name with the base constructor, for example: `pkg:index:MyComponent`.
[error]   To reduce the potential of other type name conflicts, this name contains the package and module name, in addition to the type: <package>:<module>:<type>.
[error]   These names are namespaced alongside non-component resources, such as `aws:lambda:Function`.
[error]     ctx.registerResource[Resource, ResourceArgs]("mypkg::Resource", name, args, opts)
[error]                                                  ^^^^^^^^^^^^^^^^^
That's a compilation error, resource type strings are validated in compile time on our side and the error message is oriented towards end users because we assumed it's impossible for schemas to contain invalid resource types (and even if they did, we will get this error and understand what it means anyhow).
e
Yeh it's a mess, yeh I think it's going to break stuff, but also it's currently breaking URNs and names so were going to have to figure it out