openfaas / openfaas/faas-cli

Append flag doesnt add newline if not present in file

Open
#852 13 comments 0 reactions 2 assignees View on GitHub

@kylos101 is already working on this.

Since Dec 3, 2021.

help wanted
Dominant language
Go
Stars
816
Forks
230
Avg merge
6h 4m
Merged PRs (30d)
1

Description

Expected Behaviour

The append flag shuld a function correctly if the file doesn't have a newline at the end

Current Behaviour

When using faas-cli new --append stack.yml i have found that this doesnt append a newline if one is not present in the file

I therefore created a new function and it appended like this

  route53:
    lang: golang-middleware
    handler: ./route53
    image: route53:latest  route54:       # <-- appended to here without newline
    lang: golang-middleware
    handler: ./route54
    image: route54:latest

Possible Solution

check the stack file for a newline, if not present add one?

Steps to Reproduce (for bugs)

  1. faas-cli new --lang golang new -f stack.yml
  2. remove newlines from the stack.yml
  3. faas-cli new --lang golang new2 --append stack.yml
  4. check file, its not added a newline before the func so its squashed the the last line of the first definition

Context

Your Environment

  • FaaS-CLI version ( Full output from: faas-cli version ):
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

CLI:
 commit:  598336a0cad38a79d5466e6a3a9aebab4fc61ba9
 version: 0.12.21
Error with YAML file
  • Operating System and version (e.g. Linux, Windows, MacOS):
    Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.