Giter Club home page Giter Club logo

serverlessvalidator's Introduction

Serverless Validator

A command line utility to validate Serverless YML files.

Usage

If haskell, stack are installed on you system simply clone this repo and type: ./src/Serverlessvalidator.hs path/to/serverless.yml. The script leverages stack's scripting capabilities that is Stack will take care of downloading all the necessary dependencies and run the validator, just sit back and wait for it to be finished (it might take a bit the first time). For example, if the runtime string in serverless.yml is not valid, the ouput will be something like:

$ ./src/Serverlessvalidator.hs path/to/serverless-wrong-runtime.yml
'serverless-wrong-runtime.yml' is not valid
AesonException "Error in $.provider.runtime: failed to parse field provider: failed to parse field runtime: Unsupported runtime 'nodejs'. Choose one among: 'nodejs4.3', 'java8', 'python2.8'"

Usage with Docker

A Docker executable image is available on Docker Hub, just download it and run it against you serverless.yml file:

docker pull futtetennista/serverless-validator
docker run --rm -v=$(pwd):/tmp -w=/tmp serveless-validator path/to/serverless.yml

Licence

MIT License

Copyright (c) 2017 Futtetennista

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

serverlessvalidator's People

Contributors

futtetennista avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mathieudevos

serverlessvalidator's Issues

Environment variables are not handled properly

Currently the provider.environment setting only takes in [environment] which is defined on line 259 as (text, text).

This is impossible to satisfy with yaml.

It should take in just a dictionary. The issue starts on line 307 [Environment] which already requires a list. And finally the issue completes on line 259 with (Text, Text) which cannot be satisfied by yaml.

Example of perfectly valid test file that breaks this:

service: MyService

frameworkVersion: ">=1.0.0 <2.0.0"

provider:
  name: foobar
  runtime: nodejs4.3
  environment:
    - SOME_VARIABLE: foo

functions:
# HTTP Events
  foo1:
    handler: handler.foo1
    events:
      - http: GET foo
      - http: POST foo

other setup which breaks it (even though serverless would accept this just fine)

service: MyService

frameworkVersion: ">=1.0.0 <2.0.0"

provider:
  name: foobar
  runtime: nodejs4.3
  environment:
    SOME_VARIABLE: foo

functions:
# HTTP Events
  foo1:
    handler: handler.foo1
    events:
      - http: GET foo
      - http: POST foo

Note the difference between environment being a list or an object here, serverless will unpack these as environment variables anyway. The code should reflect this.

Hack to work around this: replace line 259 with Object (but still requires a list input, even though an object is perfectly fine as well)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.