zavoloklom / docker-compose-linter

A command-line tool for validating and enforcing best practices in Docker Compose files.
MIT License
13 stars 1 forks source link

YAML Anchor / Fragments Support #39

Closed adaliszk closed 5 days ago

adaliszk commented 1 week ago

Version

v1.0.6

YAML file where the error occurs

name: fragment-example

x-shared-links: &shared-links
  links:
    - "foo:foo.example.svc.cluster.local"
    - "bar:bar.example.svc.cluster.local"

services:
  foo:
    image: traefik/whoami:v1.10

  bar:
    image: traefik/whoami:v1.10

  app_foo:
    image: traefik/whoami:v1.10
    <<: *shared-links

  app_bar:
    image: traefik/whoami:v1.10
    <<: *shared-links

Command used to run

npx dclint .

Additional context

Current behavior (console output)

ComposeValidationError: instancePath="/services/foo", schemaPath="#/additionalProperties", message="Validation error: must NOT have additional properties".  invalid-schema

Expected behavior

The Anchors / Fragments should be resolved before validating the schema, and thus the error would not tell that additional properties are not allowed, as there are no actual keys like << being used after parsing the YAML.

zavoloklom commented 5 days ago

:tada: This issue has been resolved in version 1.0.7 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

zavoloklom commented 5 days ago

@adaliszk Hi! I fixed it in v1.0.7, but there are some limitations - https://github.com/zavoloklom/docker-compose-linter?tab=readme-ov-file#anchor-handling

Please let me know if something goes wrong.

adaliszk commented 4 days ago

Thank you very much! It looks promising; I will try to make time next week to add the tool as a listing step in my current project!