Skip to content

fix(yq): migrate fully to yq v4 syntax#96

Open
sbaerlocher wants to merge 1 commit intowhatwedo:masterfrom
sbaerlocher:fix/use-specific-yq-version
Open

fix(yq): migrate fully to yq v4 syntax#96
sbaerlocher wants to merge 1 commit intowhatwedo:masterfrom
sbaerlocher:fix/use-specific-yq-version

Conversation

@sbaerlocher
Copy link
Contributor

Overview

DDE internally uses two different Docker versions of yq – one being the latest (latest) and the other an older version 3. This creates unnecessary complications, especially when all images are removed locally and, upon re-downloading with DDE, two different images have to be fetched.

To resolve this issue, the method for parsing the docker-compose file has been updated to use yq v4 syntax, eliminating the dependency on a specific yq v3 Docker image.


Changes

  • Migration to yq v4:
    The complex docker run command that used the mikefarah/yq:3 image has been replaced with the _yq eval function. This change ensures compatibility with yq v4 and removes the need to download the specific yq v3 Docker image.

  • Adjustment of the yq Query:
    The query has been modified from:
    services.* | head -n1 | sed 's/.*\.//'
    to:
    .services | keys | .[0]
    This update accurately extracts the first service name from the docker-compose.yml file.

  • Shell Scripts Update:
    In the file commands/project/shell/root.sh, the query was slightly modified to:
    .services | keys | .[] | head -n1 | sed 's/.*\.//'
    This correction ensures that the intended functionality is maintained.

  • Affected Files:
    The changes were applied in the following files:

    • commands/project/exec.sh
    • commands/project/exec/root.sh
    • commands/project/fix-permissions.sh
    • commands/project/shell.sh
    • commands/project/shell/root.sh

Impact

  • Functionality:
    The extraction of the first service name from the docker-compose.yml file now relies on the updated yq v4 syntax using the _yq eval function.

  • Simplification:
    By removing the dependency on the yq v3 Docker image, the system is simplified, and the need to download multiple images is eliminated.

  • Compatibility:
    These changes ensure full compatibility with yq v4 while maintaining the expected behavior.

@sbaerlocher sbaerlocher assigned s4mpl3d and sbaerlocher and unassigned s4mpl3d Apr 7, 2025
@sbaerlocher sbaerlocher requested a review from s4mpl3d April 7, 2025 11:49
Copy link
Member

@s4mpl3d s4mpl3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbaerlocher there are some conflicts. Please also pin the yq image version

_checkProject
_loadProjectDotdde
local service=$(docker run --rm -v $(pwd):/workdir mikefarah/yq:3 yq r --printMode p docker-compose.yml 'services.*' | head -n1 | sed 's/.*\.//')
local service=$(_yq eval '.services | keys | .[]' docker-compose.yml | head -n1 | sed 's/.*\.//')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| head -n1 | sed 's/.*\.//' we can do this with yq too

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments