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

Fix bug where empty vpc connector setting was removed. #3973

Merged
merged 3 commits into from Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -0,0 +1 @@
- Preserve empty vpc connector setting on function deploy. (#3973)
4 changes: 2 additions & 2 deletions src/deploy/functions/runtimes/node/parseTriggers.ts
Expand Up @@ -212,9 +212,9 @@ export function addResourcesToBackend(
runtime: runtime,
...triggered,
};
if (annotation.vpcConnector) {
if (annotation.vpcConnector != null) {
let maybeId = annotation.vpcConnector;
if (!maybeId.includes("/")) {
if (maybeId && !maybeId.includes("/")) {
maybeId = `projects/${projectId}/locations/${region}/connectors/${maybeId}`;
}
endpoint.vpcConnector = maybeId;
Expand Down
19 changes: 19 additions & 0 deletions src/test/deploy/functions/runtimes/node/parseTriggers.spec.ts
Expand Up @@ -289,4 +289,23 @@ describe("addResourcesToBackend", () => {

expect(result).to.deep.equal(expected);
});

it("should preserve empty vpc connector setting", () => {
const trigger: parseTriggers.TriggerAnnotation = {
...BASIC_TRIGGER,
httpsTrigger: {},
vpcConnector: "",
};

const result = backend.empty();
parseTriggers.addResourcesToBackend("project", "nodejs16", trigger, result);

const expected: backend.Backend = backend.of({
...BASIC_ENDPOINT,
httpsTrigger: {},
vpcConnector: "",
});

expect(result).to.deep.equal(expected);
});
});