compose-go
compose-go copied to clipboard
Allow empty (null) lists
This happens when some users are not very familiar with the Compose file syntax: during testing they'd comment out the environment variables, but not the actual environment: key, and the Compose file would fail to load:
services:
service1:
build: .
environment:
#NODE_ENV: production
This change adds "null" as a valid type for many of the lists in the JSON schema:
- [x]
include - [x]
service.blkio_config.device_read_bps - [x]
service.blkio_config.device_read_iops - [x]
service.blkio_config.device_write_bps - [x]
service.blkio_config.device_write_iops - [x]
service.blkio_config.weight_device - [ ]
service.expose - [ ]
service.group_add - [ ]
service.ports - [ ]
service.volumes - [ ]
development.watch - [ ]
deployment.placement.preferences - [ ]
generic_resources - [ ]
devices - [ ]
network.ipam.config - [x]
command - [x]
env_file - [x]
list_of_unique_strings(was:list_of_strings) - [x]
list_of_strings - [x]
list_or_dict - [x]
service_config_or_secret
If this is the right approach I can add "oneOf": [{"type": "null"}, {"type": "array": …}] to the remaining ones.
they should get a warning from the IDE (if an extension is installed) or they get an error when running up for instance. The current behaviour is expected if environment or any other compose key is empty.
they should get a warning from the IDE (if an extension is installed) or they get an error when running
upfor instance. The current behaviour is expected ifenvironmentor any other compose key is empty.
That's right, you do get an error when you do up, but IMHO handling null is a better dev experience. Because arrays can be nil (and a nil array has length 0), the code already handles this.
I agree there's no reason we consider an null list as invalid while an empty one if fine