https://pulumi.com logo
#general
Title
# general
i

important-leather-28796

03/11/2019, 11:07 PM
Getting dreaded
Calling [toString] on an [Output<T>] is not supported
in my transformer. The transformer is shared code and may be used with a namespace instance or string. What have I messed up here:
Copy code
/**
 * May be needed to get helm to behave.
 *
 *  Usage: `transformations: [createTransformAddNamespace(namespace)]`
 *
 * @see <https://github.com/pulumi/pulumi-kubernetes/issues/217#issuecomment-459105809>
 * @see <https://github.com/pulumi/pulumi-kubernetes/issues/415#issuecomment-469118560>
 */
export function createTransformAddNamespace(
  namespaceStringOrResource: string | k8s.core.v1.Namespace,
) {
  return <T extends { metadata?: Input<meta.v1.ObjectMeta> }>(o: T) => {
    let namespace: Input<string>
    if (typeof namespaceStringOrResource === 'string') {
      namespace = namespaceStringOrResource
    } else {
      namespace = namespaceStringOrResource.metadata.name.apply(v => v)
    }

    if (o) {
      if (o.metadata !== undefined) {
        o.metadata['namespace'] = namespace
      } else {
        o.metadata = { namespace: namespace }
      }
    }
  }
}
m

microscopic-florist-22719

03/11/2019, 11:08 PM
cc @calm-apple-46440 @creamy-potato-29402
IIRC we recently fixed a similar bug in one of our examples
c

creamy-potato-29402

03/11/2019, 11:13 PM
@gorgeous-egg-16927 I believe we are in the process of fixing this, right?
g

gorgeous-egg-16927

03/11/2019, 11:15 PM
Yes, this bug was uncovered last week, and I’m in the process of fixing it. https://github.com/pulumi/pulumi-kubernetes/issues/478
b

better-rainbow-14549

03/13/2019, 11:02 AM
i think you can do `if (namespaceStringOrResource intanceof string) { }`there
10 Views