Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .yaml #91

Open
tsujp opened this issue Aug 11, 2020 · 5 comments
Open

Support .yaml #91

tsujp opened this issue Aug 11, 2020 · 5 comments

Comments

@tsujp
Copy link

tsujp commented Aug 11, 2020

Describe the bug
Currently only .yml is supported, e.g. dip.yml and not dip.yaml.

To Reproduce

  1. Install Dip
  2. Use any dip.yaml configuration, including the default but renamed to dip.yml.
For completeness here is the configuration explicitly
$ dip ls
ERROR: Could not find dip.yml config

With the following

file: dip.yaml

version: '6.0.0'

environment:
  RAILS_ENV: development

compose:
  files:
    - docker-compose.yml
  project_name: higher

interaction:
  sh:
    description: Open a Bash shell within a Rails container (with dependencies up)
    service: runner
    command: /bin/bash

  bash:
    description: Run an arbitrary script within a container (or open a shell without deps)
    service: runner
    command: /bin/bash
    compose_run_options: [no-deps]

  bundle:
    description: Run Bundler commands
    service: runner
    command: bundle
    compose_run_options: [no-deps]

  rake:
    description: Run Rake commands
    service: runner
    command: bundle exec rake

  rails:
    description: Run Rails commands
    service: runner
    command: bundle exec rails
    subcommands:
      s:
        description: Run Rails server available at http://localhost:3030
        service: rails
        compose:
          run_options: [service-ports, use-aliases]

  yarn:
    description: Run Yarn commands
    service: runner
    command: yarn
    compose_run_options: [no-deps]

  rspec:
    description: Run Rails tests
    service: runner
    environment:
      RAILS_ENV: test
    command: bundle exec rspec

  rubocop:
    description: Run Rubocop
    service: runner
    command: bundle exec rubocop
    compose_run_options: [no-deps]

  psql:
    description: Run psql console
    service: postgres
    command: psql -h postgres -U postgres -d example_app_dev

  'redis-cli':
    description: Run Redis console
    service: redis
    command: redis-cli -h redis

provision:
  - dip compose down --volumes
  - dip compose up -d postgres redis
  - dip bundle install
  - dip yarn install
  - dip rails db:setup

The exact same file as dip.yaml

$ dip ls
sh         # Open a Bash shell within a Rails container (with dependencies up)
bash       # Run an arbitrary script within a container (or open a shell without deps)
bundle     # Run Bundler commands
rake       # Run Rake commands
rails      # Run Rails commands
rails s    # Run Rails server available at http://localhost:3030
yarn       # Run Yarn commands
rspec      # Run Rails tests
rubocop    # Run Rubocop
psql       # Run psql console
redis-cli  # Run Redis console

Expected behavior
Works as it would if said config file was named dip.yml.

Context (please complete the following information):

  • OS: 5.7.12-arch1-1
  • Version: 6.0.0

Additional context
Add any other context about the problem here.

@bibendi
Copy link
Owner

bibendi commented Aug 11, 2020

Hi Jordan!

I don't want to support both file extensions because of the impact on start up time. Every project decided which file extension to use. Rails and Docker chose .yml. Kubernetes chose .yaml. And so on.

@tsujp
Copy link
Author

tsujp commented Aug 11, 2020

Docker now supports .yaml: https://docs.docker.com/compose/compose-file/#service-configuration-reference

Would it not be a simple check for either file here:

file = path.join(prepared_name(DEFAULT_PATH))

@bibendi
Copy link
Owner

bibendi commented Aug 11, 2020

It's not a simple check. A DIP's config is searched recursively in every parent folder among with an override config. The code will be complicated, and two "excess" checks for every folder. I don't see any benefits, sorry.

@tsujp
Copy link
Author

tsujp commented Aug 11, 2020

Not to be rather terse but the YAML maintainers do state that .yaml is the extension to use and breaking spec does lead to problems which is why various projects that did, e.g. Docker eventually added back the option for .yaml as opposed to only .yml.

I do think holding to the YAML spec of using .yaml for the file extension is important, the only real reason .yml became a thing is because of Windows' developers fear of breaking the 8+3 file naming convention due to that systems limitations.

Perhaps an alternate approach with these recursive checks could be to either:

  1. Change .yml to .yaml entirely, as per the YAML spec.
  2. Use inline C to recursively check for dip.* configuration files if Ruby is slowing down that much. I plan tol bench that later to get actual performance numbers here.

@bibendi
Copy link
Owner

bibendi commented Aug 11, 2020

Please use ".yaml" when possible.

Above is the advice, not the specification.

the only real reason

I don't think this is the only reason.

Change .yml to .yaml entirely, as per the YAML spec.

This is an unnecessary big breaking change. It's not possible.

If someone wants to implement supporting of both extensions, they should make sure below:

  • throw an exception if both file extensions present in a folder at once
  • benchmark performance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants