serverless / serverless-google-cloudfunctions

Serverless Google Cloud Functions Plugin – Adds Google Cloud Functions support to the Serverless Framework
https://www.serverless.com
MIT License
271 stars 127 forks source link

feat: Add schema validation #252

Closed CorentinDoue closed 3 years ago

CorentinDoue commented 3 years ago

Fixes https://github.com/serverless/serverless-google-cloudfunctions/issues/232

Description

Validate the serverless configuration for google provider and the configuration of the two triggers of cloud functions (http and event)

Tests

I didn't find any test in integration with the serverless package so I tested it manually.

yarn sls package with this configuration doesn't output any warning

service: test-schema-validation
frameworkVersion: '2'
plugins:
  - serverless-google-cloudfunctions

provider:
  name: google
  stage: dev
  runtime: nodejs10
  region: us-central1
  project: my-project
  credentials: ~/.gcloud/keyfile.json
  serviceAccountEmail: 'email'
  memorySize: 512
  timeout: 90s
  environment:
    ENV_VAR_KEY: ENV_VAR_VALUE
  vpc: projects/{project_id}/locations/{region}/connectors/{connector_name}
  labels:
    test.lab_el: VALUE

package:
  exclude:
    - node_modules/**
    - .gitignore
    - .git/**

functions:
  http-function:
    handler: http
    environment:
      ENV_VAR_KEY: ENV_VAR_VALUE
    events:
      - http: path
  event-function:
    handler: http
    vpc: projects/{project_id}/locations/{region}/connectors/{connector_name}
    memorySize: 2048
    timeout: 120s
    labels:
      event_label: VALUE
    events:
      - event:
          eventType: eventType
          resource: resource

before this PR the result would have been

Serverless: Configuration warning: Unrecognized provider 'google'                                                                                                                                                  
Serverless:                                                                                                                                                                                                        
Serverless: You're relying on provider plugin which doesn't provide a validation schema for its config.                                                                                                            
Serverless: Please report the issue at its bug tracker linking: https://www.serverless.com/framework/docs/providers/aws/guide/plugins#extending-validation-schema                                                  
Serverless: You may turn off this message with "configValidationMode: off" setting    
CorentinDoue commented 3 years ago

@medikoo @pgrzesik Do you still maintain this repo? Can one of you review it?