Skip to content

eval: directives not interpolated inside block scalar (multi-line) string values #59

Description

@dakusui

Summary

eval:string: (and other eval: directives) are only processed when they are the entire value of a YAML key. They are silently ignored when they appear as a substring inside a block scalar (multi-line) string value.

Reproduction

Given a .yaml++ file:

jobs:
  build:
    steps:
      - name: Build
        run: |-
          docker build -t "eval:string:mymodule::image_ref" ./

Expected: the eval:string:mymodule::image_ref expression is evaluated and its return value is spliced into the surrounding string, producing something like:

        run: |-
          docker build -t "gcr.io/my-project/my-service:abc1234" ./

Actual: the literal text eval:string:mymodule::image_ref is emitted unchanged into the output.

Contrast with working case

When eval:string: is the full value of a key, it works as expected:

      - name: Deploy
        with:
          image: "eval:string:mymodule::image_ref"

This correctly resolves to the return value of image_ref.

Context

Encountered while refactoring GitHub Actions workflow YAML files with jq++. Long image reference strings like:

${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}

appear both as standalone with.image: values (where the function workaround applies) and embedded inside run: |- shell script blocks (where it does not). The run: occurrences cannot be DRY'd up with the current behavior.

Question

Is this a known limitation (deserving documentation), a design decision, or a bug to be fixed?

One possible implementation approach: if a string value contains one or more eval:<type>:<expr> substrings, evaluate each expression and substitute the result in-place (coercing to string regardless of the declared type).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions