Skip to content

Commit 5f64797

Browse files
takaaa220joehan
andauthored
Fix IngressSettings (#827)
Co-authored-by: joehan <[email protected]>
1 parent 61dc5a1 commit 5f64797

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

spec/function-builder.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,27 @@ describe('FunctionBuilder', () => {
200200
}).to.throw(Error, 'at least one region');
201201
});
202202

203+
it('should allow a ingressSettings to be set', () => {
204+
const fn = functions
205+
.runWith({ ingressSettings: 'ALLOW_INTERNAL_ONLY' })
206+
.https.onRequest(() => {});
207+
208+
expect(fn.__trigger.ingressSettings).to.equal('ALLOW_INTERNAL_ONLY');
209+
});
210+
211+
it('should throw an error if user chooses an invalid ingressSettings', () => {
212+
expect(() => {
213+
return functions.runWith({
214+
ingressSettings: 'INVALID_OPTION',
215+
} as any);
216+
}).to.throw(
217+
Error,
218+
`The only valid ingressSettings values are: ${functions.INGRESS_SETTINGS_OPTIONS.join(
219+
','
220+
)}`
221+
);
222+
});
223+
203224
it('should allow a vpcConnector to be set', () => {
204225
const fn = functions
205226
.runWith({

src/cloud-functions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ export interface TriggerAnnotated {
273273
vpcConnector?: string;
274274
vpcConnectorEgressSettings?: string;
275275
serviceAccountEmail?: string;
276+
ingressSettings?: string;
276277
};
277278
}
278279

@@ -519,6 +520,10 @@ export function optionsToTrigger(options: DeploymentOptions) {
519520
trigger.maxInstances = options.maxInstances;
520521
}
521522

523+
if (options.ingressSettings) {
524+
trigger.ingressSettings = options.ingressSettings;
525+
}
526+
522527
if (options.vpcConnector) {
523528
trigger.vpcConnector = options.vpcConnector;
524529
}

src/function-builder.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
SUPPORTED_REGIONS,
3232
VALID_MEMORY_OPTIONS,
3333
VPC_EGRESS_SETTINGS_OPTIONS,
34+
INGRESS_SETTINGS_OPTIONS,
3435
} from './function-configuration';
3536
import * as analytics from './providers/analytics';
3637
import * as auth from './providers/auth';
@@ -68,6 +69,17 @@ function assertRuntimeOptionsValid(runtimeOptions: RuntimeOptions): boolean {
6869
);
6970
}
7071

72+
if (
73+
runtimeOptions.ingressSettings &&
74+
!_.includes(INGRESS_SETTINGS_OPTIONS, runtimeOptions.ingressSettings)
75+
) {
76+
throw new Error(
77+
`The only valid ingressSettings values are: ${INGRESS_SETTINGS_OPTIONS.join(
78+
','
79+
)}`
80+
);
81+
}
82+
7183
if (
7284
runtimeOptions.vpcConnectorEgressSettings &&
7385
!_.includes(

0 commit comments

Comments
 (0)