Code Monkey home page Code Monkey logo

compose_format's People

Contributors

anthraxn8b avatar igueler avatar lindt avatar thinkbotbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

compose_format's Issues

ImportError: cannot import name 'RoundTripDumper' with image

I tried the image but it doesn't work. See following history (shell from host-system):

root@localhost: cat docker-compose.yml | docker run -i funkwerk/compose_format
Traceback (most recent call last):
  File "/bin/compose_format", line 2, in <module>
    from compose_format import ComposeFormat
  File "/usr/lib/python3.5/site-packages/compose_format/__init__.py", line 1, in <module>
    from ruamel.yaml import RoundTripDumper, RoundTripLoader, dump, load
ImportError: cannot import name 'RoundTripDumper'
root@localhost:/var/docker/source/main# docker --version
Docker version 19.03.2, build 6a30dfc

TypeError: unorderable types: CommentedMap() < CommentedMap()

version: '3.3'

services:
  nifi:
    container_name: nifi
    image: apache/nifi:1.7.1
    environment:
      NIFI_WEB_HTTP_PORT: '8443'
      NIFI_WEB_PROXY_HOST: '0.0.0.0'
    volumes:
      - type: bind
        source: ./certs
        target: /opt/certs
      - type: volume
        target: /opt/nifi/nifi-1.7.1/conf
      - type: volume
        target: /opt/nifi/nifi-1.7.1/content_repository
      - type: volume
        target: /opt/nifi/nifi-1.7.1/database_repository
      - type: volume
        target: /opt/nifi/nifi-1.7.1/flowfile_repository
      - type: volume
        target: /opt/nifi/nifi-1.7.1/provenance_repository
      - type: volume
        target: /opt/nifi/nifi-1.7.1/logs
      - type: volume
        target: /opt/nifi/nifi-1.7.1/data
    restart: always
    network_mode: "host"
    ports:
      - 8443:8443

Give following error with the docker command:

Traceback (most recent call last):
  File "/bin/compose_format", line 28, in <module>
    formatted = formatter.format_string(data, strict=not args.non_strict)
  File "/usr/lib/python3.5/site-packages/compose_format/__init__.py", line 77, in format_string
    data = self.reorder(load(data, RoundTripLoader), strict=strict)
  File "/usr/lib/python3.5/site-packages/compose_format/__init__.py", line 98, in reorder
    ComposeFormat.reorder(item, strict)
  File "/usr/lib/python3.5/site-packages/compose_format/__init__.py", line 98, in reorder
    ComposeFormat.reorder(item, strict)
  File "/usr/lib/python3.5/site-packages/compose_format/__init__.py", line 98, in reorder
    ComposeFormat.reorder(item, strict)
  File "/usr/lib/python3.5/site-packages/compose_format/__init__.py", line 101, in reorder
    data.sort()
TypeError: unorderable types: CommentedMap() < CommentedMap()

Quoted values unquoating

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?

TypeError: expected string or bytes-like object

When I try do use it on my docker-compose.yaml file, which is perfectly valid for the docker-compose command, I get:

Traceback (most recent call last):
  File "/home/ser/.local/bin/compose_format", line 35, in <module>
    if not formatter.format(path, replace=args.replace, strict=not args.non_strict):
  File "/home/ser/.local/lib/python3.10/site-packages/compose_format/__init__.py", line 68, in format
    formatted = self.format_string(data, replace=replace, strict=strict)
  File "/home/ser/.local/lib/python3.10/site-packages/compose_format/__init__.py", line 78, in format_string
    data = self.reorder(load(data, RoundTripLoader), strict=strict)
  File "/home/ser/.local/lib/python3.10/site-packages/compose_format/__init__.py", line 99, in reorder
    ComposeFormat.reorder(item, strict)
  File "/home/ser/.local/lib/python3.10/site-packages/compose_format/__init__.py", line 99, in reorder
    ComposeFormat.reorder(item, strict)
  File "/home/ser/.local/lib/python3.10/site-packages/compose_format/__init__.py", line 99, in reorder
    ComposeFormat.reorder(item, strict)
  [Previous line repeated 1 more time]
  File "/home/ser/.local/lib/python3.10/site-packages/compose_format/__init__.py", line 103, in reorder
    data[i] = ComposeFormat.fix_sexadecimal_numbers(value)
  File "/home/ser/.local/lib/python3.10/site-packages/compose_format/__init__.py", line 113, in fix_sexadecimal_numbers
    match = re.match(SEXADECIMAL_NUMBER, value)
  File "/usr/lib/python3.10/re.py", line 190, in match
    return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object

Place single quotes around system ports

place single quotes around system ports like '21:21'

docker-compose reference:
Note: When mapping ports in the HOST:CONTAINER format, you may experience erroneous results when using a container port lower than 60, because YAML will parse numbers in the format xx:yy as sexagesimal (base 60). For this reason, we recommend always explicitly specifying your port mappings as strings.

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.