-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
I would like to request a new feature for the VS Code Docker extension that allows for automatic sorting of keywords in Docker Compose files.
Current Behavior
When copying and pasting Docker Compose configurations from various sources (e.g., GitHub repositories), the order of keywords within service definitions is often inconsistent. This inconsistency makes it challenging to quickly read and understand the configuration, especially when working with multiple services or comparing different Compose files.
Proposed Feature
Add an option to automatically sort the keywords within each service definition in a Docker Compose file. This feature would:
- Allow users to define a custom sorting order for keywords.
- Provide a default sorting order (e.g., image, container_name, environment, volumes, ports, etc.).
- Be accessible through a command in the Command Palette or a context menu option when editing Docker Compose files.
Example
Before sorting:
services:
myapp:
ports:
- "8080:80"
environment:
- NODE_ENV=production
image: myapp:latest
container_name: myapp-container
volumes:
- ./data:/app/data`
After sorting (with a predefined order):
services:
myapp:
image: myapp:latest
container_name: myapp-container
environment:
- NODE_ENV=production
volumes:
- ./data:/app/data
ports:
- "8080:80"
Benefits
- Improved readability and consistency across projects.
- Easier comparison between different Docker Compose files.
- Time-saving for developers who frequently work with Docker Compose configurations.
Implementation Suggestions
- Add a new setting to specify the desired keyword order.
- Implement the sorting logic within the extension.
- Ensure the feature respects YAML comments and maintains the overall structure of the file.
LRNZ09, gan-of-culture, WieseChristoph, Marly212, nonodev96 and 4 more
Metadata
Metadata
Assignees
Labels
No labels