| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a0ceb45 commit 341cdcd
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,6 +147,11 @@ export function createDeploymentPlan( | |||
| 147 | 147 | if (matchingExistingFunction) { | |
| 148 | 148 | // Check if this is an invalid change of trigger type. | |
| 149 | 149 | checkForInvalidChangeOfTrigger(fn, matchingExistingFunction); | |
| 150 | + // Preserve existing environment variables. | ||
| 151 | + fn.environmentVariables = { | ||
| 152 | + ...matchingExistingFunction.environmentVariables, | ||
| 153 | + ...fn.environmentVariables, | ||
| 154 | + }; | ||
| 150 | 155 | regionalDeployment.functionsToUpdate.push(fn); | |
| 151 | 156 | existingFnsCopy = existingFnsCopy.filter((exFn: CloudFunctionTrigger) => { | |
| 152 | 157 | return exFn.name !== fn.name; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -505,6 +505,7 @@ describe("deploymentPlanner", () => { | |||
| 505 | 505 | }; | |
| 506 | 506 | expect(deploymentPlan).to.deep.equal(expected); | |
| 507 | 507 | }); | |
| 508 | + | ||
| 508 | 509 | it("should only create, update, and delete matching functions if filters are passed in.", () => { | |
| 509 | 510 | const regionMap: deploymentPlanner.RegionMap = { | |
| 510 | 511 | "us-east1": [ | |
@@ -586,5 +587,75 @@ describe("deploymentPlanner", () => { | |||
| 586 | 587 | }; | |
| 587 | 588 | expect(deploymentPlan).to.deep.equal(expected); | |
| 588 | 589 | }); | |
| 590 | + | ||
| 591 | + it("should preserve existing environment variables", () => { | ||
| 592 | + const regionMap: deploymentPlanner.RegionMap = { | ||
| 593 | + "us-east1": [ | ||
| 594 | + { | ||
| 595 | + name: "projects/a/locations/us-east1/functions/a", | ||
| 596 | + labels: {}, | ||
| 597 | + environmentVariables: {}, | ||
| 598 | + entryPoint: "", | ||
| 599 | + }, | ||
| 600 | + ], | ||
| 601 | + "us-west1": [ | ||
| 602 | + { | ||
| 603 | + name: "projects/a/locations/us-west1/functions/b", | ||
| 604 | + labels: {}, | ||
| 605 | + environmentVariables: {}, | ||
| 606 | + entryPoint: "", | ||
| 607 | + }, | ||
| 608 | + ], | ||
| 609 | + }; | ||
| 610 | + const existingFunctions: deploymentPlanner.CloudFunctionTrigger[] = [ | ||
| 611 | + { | ||
| 612 | + name: "projects/a/locations/us-west1/functions/b", | ||
| 613 | + labels: {}, | ||
| 614 | + environmentVariables: { FOO: "bar" }, | ||
| 615 | + entryPoint: "", | ||
| 616 | + }, | ||
| 617 | + ]; | ||
| 618 | + const filters: string[][] = []; | ||
| 619 | + | ||
| 620 | + const deploymentPlan = deploymentPlanner.createDeploymentPlan( | ||
| 621 | + regionMap, | ||
| 622 | + existingFunctions, | ||
| 623 | + filters | ||
| 624 | + ); | ||
| 625 | + | ||
| 626 | + const expected: deploymentPlanner.DeploymentPlan = { | ||
| 627 | + regionalDeployments: [ | ||
| 628 | + { | ||
| 629 | + region: "us-east1", | ||
| 630 | + functionsToCreate: [ | ||
| 631 | + { | ||
| 632 | + name: "projects/a/locations/us-east1/functions/a", | ||
| 633 | + labels: {}, | ||
| 634 | + environmentVariables: {}, | ||
| 635 | + entryPoint: "", | ||
| 636 | + }, | ||
| 637 | + ], | ||
| 638 | + functionsToUpdate: [], | ||
| 639 | + schedulesToUpsert: [], | ||
| 640 | + }, | ||
| 641 | + { | ||
| 642 | + region: "us-west1", | ||
| 643 | + functionsToCreate: [], | ||
| 644 | + functionsToUpdate: [ | ||
| 645 | + { | ||
| 646 | + name: "projects/a/locations/us-west1/functions/b", | ||
| 647 | + labels: {}, | ||
| 648 | + environmentVariables: { FOO: "bar" }, | ||
| 649 | + entryPoint: "", | ||
| 650 | + }, | ||
| 651 | + ], | ||
| 652 | + schedulesToUpsert: [], | ||
| 653 | + }, | ||
| 654 | + ], | ||
| 655 | + functionsToDelete: [], | ||
| 656 | + schedulesToDelete: [], | ||
| 657 | + }; | ||
| 658 | + expect(deploymentPlan).to.deep.equal(expected); | ||
| 659 | + }); | ||
| 589 | 660 | }); | |
| 590 | 661 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments