Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape double-colons (::) #85

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/interop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import * as pulumi from '@pulumi/pulumi';
import { debug } from '@pulumi/pulumi/log';
import { IConstruct } from 'constructs';

export function urnEncode(str: string): string {
return str.replace(/:/g, '%3A');
}

export function firstToLower(str: string) {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toLowerCase() + txt.substr(1);
Expand Down Expand Up @@ -98,8 +102,8 @@ export function getFqn(construct: IConstruct): string | undefined {

export class CdkConstruct extends pulumi.ComponentResource {
constructor(name: string | undefined, construct: IConstruct, options?: pulumi.ComponentResourceOptions) {
const constructType = construct.constructor.name || 'Construct';
const constructName = name || construct.node.path;
const constructType = urnEncode(construct.constructor.name || 'Construct');
const constructName = urnEncode(name || construct.node.path);

super(`cdk:construct:${constructType}`, constructName, {}, options);
}
Expand Down
4 changes: 2 additions & 2 deletions src/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
ResourceMapping,
normalize,
firstToLower,
getFqn,
getFqn, urnEncode,
} from './interop';
import { OutputRepr, OutputMap } from './output-map';
import { parseSub } from './sub';
Expand Down Expand Up @@ -350,7 +350,7 @@ class AssetManifestConverter extends ArtifactConverter {
}

const s3Asset = this.app.s3Assets.get(inputPath);
const name = s3Asset?.node.path || id;
const name = urnEncode(s3Asset?.node.path || id);

const outputPath =
asset.source.packaging === cloud_assembly.FileAssetPackaging.FILE
Expand Down
Loading