funkwerk / compose_format

format docker compose files using recipes from best practices
MIT License
45 stars 19 forks source link

Quoted values unquoating #13

Open malefici opened 4 years ago

malefici commented 4 years ago

Some configuration values should be quoted. Pls, take a look at this snippet:

version: '3'
services:
    mysql:
        image: mysql:latest
        environment:
            MYSQL_DATABASE: test
            MYSQL_PASSWORD: test
            # See: https://hub.docker.com/_/mysql
            MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
            MYSQL_USER: test

Linter removes quoting (MYSQL_RANDOM_ROOT_PASSWORD: yes), so using this config will trigger an error services.mysql.environment.MYSQL_RANDOM_ROOT_PASSWORD contains true, which is an invalid type, it should be a string, number, or a null. This means that it is not possible to leave value type specification after this linter usage.

Also, it breaks type specification like this !!str yes.

Sorry, I am not familiar with ruamel.yaml and can not create a proper pull request. Maybe do you know how to fix it?