go-vela / community

Community Information for Vela (Target's official Pipeline Automation Framework)
https://go-vela.github.io/docs/
Apache License 2.0
22 stars 3 forks source link

/expand endpoint returns template with additional character when there's a newline #925

Open timhuynh94 opened 6 months ago

timhuynh94 commented 6 months ago

Description

POST /api/v1/pipelines/{org}/{repo}/{pipeline}/expand returns an additional character such as 4 for newline in template Example vela file:

# instructs Vela which syntax version we're using
version: "1"

# instructs Vela that we're going to create a steps pipeline
steps:
  # instructs Vela what the name of the step should be
  - name: build
    # instructs Vela what Docker image to use for this step
    image: golang:1.21
    # instructs Vela which environment variables to inject for this step
    environment:
      CGO_ENABLED: 0
    # instructs Vela which commands to run inside the step
    commands: |

      git config --global user.email "${VELA_BUILD_SENDER}@git.com"
      git config --global user.name "${VELA_BUILD_SENDER}"

Result:

version: "1"
metadata:
    environment:
        - steps
        - services
        - secrets
steps:
    - commands:
        - |4-
          git config --global user.email "${VELA_BUILD_SENDER}@git.com"
          git config --global user.name "${VELA_BUILD_SENDER}"
      image: golang:1.21
      name: build
      pull: not_present
      environment:
        CGO_ENABLED: "0"

Value

Even though it works, any integration relies on this particular endpoint would fail due to additional character inserted for newline

Useful Information

  1. What is the output of vela --version?

v0.23.1

  1. What operating system is being used?
  1. Any other important details?