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

Allow for use of > to perform string Folding #702

Open
FilBot3 opened this issue Apr 14, 2022 · 3 comments
Open

Allow for use of > to perform string Folding #702

FilBot3 opened this issue Apr 14, 2022 · 3 comments
Labels
area: dependencies Changes related to dependency files. type: bug Something not working as intended.

Comments

@FilBot3
Copy link

FilBot3 commented Apr 14, 2022

Feature Request

Please allow the use of YAML > folding for strings. Example:

---
# https://taskfile.dev
version: '3'

vars:
  DOCKER: podman

tasks:
  default:
    cmds:
      - echo "Hello, World!"

  build-dev:
    desc: Use Podman/Docker to build the React App.
    cmds:
      - "{{.DOCKER}} run \
          --rm \
          --userns=keep-id \
          --volume=\"$(pwd):/home/node/user:Z\" \
          --workdir=\"/home/node/user\" \
          --entrypoint=\"npm\" \
          docker.io/library/node:16 \
            run build:dev"

  build-prod:
    desc: Use Podman/Docker to build the React App.
    cmds:
      - "{{.DOCKER}} run \
          --rm \
          --userns=keep-id \
          --volume=\"$(pwd):/home/node/user:Z\" \
          --workdir=\"/home/node/user\" \
          --entrypoint=\"npm\" \
          docker.io/library/node:16 \
            run build:prod"

  podman-build:
    desc: Build the Application Container.
    cmds:
      - "{{.DOCKER}} build \
           --file=containers/Dockerfile \
           --tag=localhost/fhirmemberrecordapp:latest \
           ."

  podman-run:
    desc: Run the container for testing.
    cmds:
      - podman run --rm --read-only --env="CONTAINER_DEBUG=true" --env="inject_arg_MRA_API_BASE=philrockssocks" --mount="type=tmpfs,destination=/var/cache/nginx" --mount="type=tmpfs,destination=/usr/share/nginx/html" --entrypoint="/bin/bash" -it localhost/fhirmemberrecordapp:latest

  podman-run2:
    desc: Run the container for testing.
    cmds:
      - >
        podman run 
          --rm 
          --read-only 
          --env="CONTAINER_DEBUG=true" 
          --env="inject_arg_MRA_API_BASE=philrockssocks" 
          --mount="type=tmpfs,destination=/var/cache/nginx" 
          --mount="type=tmpfs,destination=/usr/share/nginx/html" 
          --entrypoint="/bin/bash" 
          -it 
          localhost/fhirmemberrecordapp:latest
...

The second podman-run2 is the desired format. When I've used this, Task doesn't seem to follow that then see's only the first line.

@ghostsquad
Copy link
Contributor

Which cmd block above is problematic?

@FilBot3
Copy link
Author

FilBot3 commented Apr 15, 2022

Which cmd block above is problematic?

The last command: podman-run2 is the one that doesn't run. I get this error:

➜ task podman-run2
task: [podman-run2] podman run
  --rm
  --read-only
  --env="CONTAINER_DEBUG=true"
  --env="inject_arg_MRA_API_BASE=philrockssocks"
  --mount="type=tmpfs,destination=/var/cache/nginx"
  --mount="type=tmpfs,destination=/usr/share/nginx/html"
  --entrypoint="/bin/bash"
  -it
  localhost/fhirmemberrecordapp:latest

Error: requires at least 1 arg(s), only received 0
task: Failed to run task "podman-run2": exit status 125

The expected behavior is that the > "thingy" is supposed to remove all whitespace and replace it with a single space to form a single line.

@ghostsquad
Copy link
Contributor

ghostsquad commented Apr 16, 2022

I'm getting some inconsistent behavior. And I found several bugs in the upstream yaml package that's used in task:

go-yaml/yaml#827
go-yaml/yaml#804
go-yaml/yaml#789
go-yaml/yaml#387

The fix would be to identify a different yaml package to use that doesn't have this bug (but may also have others), OR wait for a fix upstream.

We should keep this issue open as a reminder to update the dependency when a fix is released, but otherwise, there's nothing much I can do.

Test Case 1

version: '3'
tasks:
  yo:
    cmds:
    - >
      GREETING=hello
      SUBJECT=human
      echo "${GREETING}, ${SUBJECT}"
at 21:42:01 ❯ t yo
task: [yo] GREETING=hello SUBJECT=human echo "${GREETING}, ${SUBJECT}"

Test Case 2

version: '3'
tasks:
  yo:
    cmds:
    - >
      GREETING=hello
      SUBJECT=human

      echo "${GREETING}, ${SUBJECT}"
at 21:41:57 ❯ t yo
task: [yo] GREETING=hello SUBJECT=human
echo "${GREETING}, ${SUBJECT}"

hello, human

Test Case 3

version: '3'
tasks:
  yo:
    cmds:
    - >
      GREETING=hello
      SUBJECT=human
        echo "${GREETING}, ${SUBJECT}"
at 21:41:57 ❯ t yo
task: [yo] GREETING=hello SUBJECT=human
echo "${GREETING}, ${SUBJECT}"

hello, human

Test Case 4

version: '3'
tasks:
  yo:
    cmds:
    - >
      GREETING=hello
      SUBJECT=human
        echo
        "${GREETING}, ${SUBJECT}"
at 21:44:29 ❯ t yo
task: [yo] GREETING=hello SUBJECT=human
  echo
  "${GREETING}, ${SUBJECT}"


"hello, human": executable file not found in $PATH
task: Failed to run task "yo": exit status 127

Test Case 5

version: '3'
tasks:
  yo:
    cmds:
    - >
      GREETING=hello
      SUBJECT=human
        echo \
        "${GREETING}, ${SUBJECT}"
at 21:45:41 ❯ t yo
task: [yo] GREETING=hello SUBJECT=human
  echo \
  "${GREETING}, ${SUBJECT}"

hello, human

@ghostsquad ghostsquad added type: bug Something not working as intended. status: on hold Work is paused temporarily. area: dependencies Changes related to dependency files. and removed status: on hold Work is paused temporarily. labels Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dependencies Changes related to dependency files. type: bug Something not working as intended.
Projects
None yet
Development

No branches or pull requests

2 participants