Skip to content

Commit

Permalink
Change Eventfilters to a Record structure (#1070)
Browse files Browse the repository at this point in the history
* changing to a map

* adding channel & changelog

Co-authored-by: Daniel Lee <taeold@gmail.com>
  • Loading branch information
colerogers and taeold authored Mar 31, 2022
1 parent 73325e7 commit 47ac6b8
Show file tree
Hide file tree
Showing 22 changed files with 160 additions and 400 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Changes internal structure to be more flexible (#1070).
9 changes: 3 additions & 6 deletions spec/runtime/loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,9 @@ describe('extractStack', () => {
platform: 'gcfv1',
eventTrigger: {
eventType: 'google.pubsub.topic.publish',
eventFilters: [
{
attribute: 'resource',
value: 'projects/my-project/topics/my-topic',
},
],
eventFilters: {
resource: 'projects/my-project/topics/my-topic',
},
retry: false,
},
labels: {},
Expand Down
36 changes: 12 additions & 24 deletions spec/v1/cloud-functions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,9 @@ describe('makeCloudFunction', () => {
platform: 'gcfv1',
eventTrigger: {
eventType: 'mock.provider.mock.event',
eventFilters: [
{
attribute: 'resource',
value: 'resource',
},
],
eventFilters: {
resource: 'resource',
},
retry: false,
},
labels: {},
Expand All @@ -89,12 +86,9 @@ describe('makeCloudFunction', () => {
platform: 'gcfv1',
eventTrigger: {
eventType: 'providers/provider/eventTypes/event',
eventFilters: [
{
attribute: 'resource',
value: 'resource',
},
],
eventFilters: {
resource: 'resource',
},
retry: false,
},
labels: {},
Expand Down Expand Up @@ -125,12 +119,9 @@ describe('makeCloudFunction', () => {
serviceAccountEmail: 'foo@google.com',
eventTrigger: {
eventType: 'mock.provider.mock.event',
eventFilters: [
{
attribute: 'resource',
value: 'resource',
},
],
eventFilters: {
resource: 'resource',
},
retry: false,
},
secretEnvironmentVariables: [{ secret: 'MY_SECRET', key: 'MY_SECRET' }],
Expand All @@ -152,12 +143,9 @@ describe('makeCloudFunction', () => {
platform: 'gcfv1',
eventTrigger: {
eventType: 'mock.provider.mock.event',
eventFilters: [
{
attribute: 'resource',
value: 'resource',
},
],
eventFilters: {
resource: 'resource',
},
retry: true,
},
labels: {},
Expand Down
9 changes: 3 additions & 6 deletions spec/v1/providers/analytics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,9 @@ describe('Analytics Functions', () => {
expect(cloudFunction.__endpoint).to.deep.equal({
platform: 'gcfv1',
eventTrigger: {
eventFilters: [
{
attribute: 'resource',
value: 'projects/project1/events/first_open',
},
],
eventFilters: {
resource: 'projects/project1/events/first_open',
},
eventType:
'providers/google.firebase.analytics/eventTypes/event.log',
retry: false,
Expand Down
9 changes: 3 additions & 6 deletions spec/v1/providers/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,9 @@ describe('Auth Functions', () => {
return {
platform: 'gcfv1',
eventTrigger: {
eventFilters: [
{
attribute: 'resource',
value: `projects/${project}`,
},
],
eventFilters: {
resource: `projects/${project}`,
},
eventType: `providers/firebase.auth/eventTypes/${eventType}`,
retry: false,
},
Expand Down
9 changes: 3 additions & 6 deletions spec/v1/providers/database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ describe('Database Functions', () => {
return {
platform: 'gcfv1',
eventTrigger: {
eventFilters: [
{
attribute: 'resource',
value: resource,
},
],
eventFilters: {
resource,
},
eventType: `providers/google.firebase.database/eventTypes/${eventType}`,
retry: false,
},
Expand Down
9 changes: 3 additions & 6 deletions spec/v1/providers/firestore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,9 @@ describe('Firestore Functions', () => {
return {
platform: 'gcfv1',
eventTrigger: {
eventFilters: [
{
attribute: 'resource',
value: resource,
},
],
eventFilters: {
resource,
},
eventType: `providers/cloud.firestore/eventTypes/${eventType}`,
retry: false,
},
Expand Down
9 changes: 3 additions & 6 deletions spec/v1/providers/pubsub.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,9 @@ describe('Pubsub Functions', () => {
platform: 'gcfv1',
eventTrigger: {
eventType: 'google.pubsub.topic.publish',
eventFilters: [
{
attribute: 'resource',
value: 'projects/project1/topics/toppy',
},
],
eventFilters: {
resource: 'projects/project1/topics/toppy',
},
retry: false,
},
labels: {},
Expand Down
9 changes: 3 additions & 6 deletions spec/v1/providers/remoteConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,9 @@ describe('RemoteConfig Functions', () => {
platform: 'gcfv1',
eventTrigger: {
eventType: 'google.firebase.remoteconfig.update',
eventFilters: [
{
attribute: 'resource',
value: 'projects/project1',
},
],
eventFilters: {
resource: 'projects/project1',
},
retry: false,
},
labels: {},
Expand Down
9 changes: 3 additions & 6 deletions spec/v1/providers/storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ describe('Storage Functions', () => {
return {
platform: 'gcfv1',
eventTrigger: {
eventFilters: [
{
attribute: 'resource',
value: `projects/_/buckets/${bucket}`,
},
],
eventFilters: {
resource: `projects/_/buckets/${bucket}`,
},
eventType: `google.storage.object.${eventType}`,
retry: false,
},
Expand Down
9 changes: 3 additions & 6 deletions spec/v1/providers/testLab.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@ describe('Test Lab Functions', () => {
platform: 'gcfv1',
eventTrigger: {
eventType: 'google.testing.testMatrix.complete',
eventFilters: [
{
attribute: 'resource',
value: 'projects/project1/testMatrices/{matrix}',
},
],
eventFilters: {
resource: 'projects/project1/testMatrices/{matrix}',
},
retry: false,
},
labels: {},
Expand Down
63 changes: 15 additions & 48 deletions spec/v2/providers/alerts/alerts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import { FULL_ENDPOINT, FULL_OPTIONS } from '../helpers';
const ALERT_TYPE = 'new-alert-type';
const APPID = '123456789';

const ALERT_EVENT_FILTER = {
alerttype: ALERT_TYPE,
};

const ALERT_APP_EVENT_FILTER = {
alerttype: ALERT_TYPE,
appid: APPID,
};

describe('alerts', () => {
describe('onAlertPublished', () => {
it('should create the function without opts', () => {
Expand All @@ -16,12 +25,7 @@ describe('alerts', () => {
labels: {},
eventTrigger: {
eventType: alerts.eventType,
eventFilters: [
{
attribute: 'alerttype',
value: ALERT_TYPE,
},
],
eventFilters: ALERT_EVENT_FILTER,
retry: false,
},
});
Expand All @@ -41,16 +45,7 @@ describe('alerts', () => {
...FULL_ENDPOINT,
eventTrigger: {
eventType: alerts.eventType,
eventFilters: [
{
attribute: 'alerttype',
value: ALERT_TYPE,
},
{
attribute: 'appid',
value: APPID,
},
],
eventFilters: ALERT_APP_EVENT_FILTER,
retry: false,
},
});
Expand Down Expand Up @@ -81,12 +76,7 @@ describe('alerts', () => {
labels: {},
eventTrigger: {
eventType: alerts.eventType,
eventFilters: [
{
attribute: 'alerttype',
value: ALERT_TYPE,
},
],
eventFilters: ALERT_EVENT_FILTER,
retry: false,
},
});
Expand All @@ -99,12 +89,7 @@ describe('alerts', () => {
...FULL_ENDPOINT,
eventTrigger: {
eventType: alerts.eventType,
eventFilters: [
{
attribute: 'alerttype',
value: ALERT_TYPE,
},
],
eventFilters: ALERT_EVENT_FILTER,
retry: false,
},
});
Expand All @@ -117,16 +102,7 @@ describe('alerts', () => {
...FULL_ENDPOINT,
eventTrigger: {
eventType: alerts.eventType,
eventFilters: [
{
attribute: 'alerttype',
value: ALERT_TYPE,
},
{
attribute: 'appid',
value: APPID,
},
],
eventFilters: ALERT_APP_EVENT_FILTER,
retry: false,
},
});
Expand All @@ -153,16 +129,7 @@ describe('alerts', () => {
minInstances: 3,
eventTrigger: {
eventType: alerts.eventType,
eventFilters: [
{
attribute: 'alerttype',
value: ALERT_TYPE,
},
{
attribute: 'appid',
value: APPID,
},
],
eventFilters: ALERT_APP_EVENT_FILTER,
retry: false,
},
});
Expand Down
Loading

0 comments on commit 47ac6b8

Please sign in to comment.