faas-cli icon indicating copy to clipboard operation
faas-cli copied to clipboard

Append flag doesnt add newline if not present in file

Open Waterdrips opened this issue 4 years ago • 13 comments

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

Waterdrips avatar Dec 17 '20 15:12 Waterdrips

@Waterdrips I'm going to assign this one to you, can you send a PR and a unit test when you have time.

alexellis avatar Jan 28 '21 14:01 alexellis

/add label: help wanted

alexellis avatar Mar 11 '21 15:03 alexellis

I'm willing to attempt to fix this one.

jantytgat avatar Mar 11 '21 16:03 jantytgat

Thanks @jantytgat

alexellis avatar Mar 11 '21 21:03 alexellis

Hi, I'll take a peek at this issue Saturday evening (11/6). I figure it may already be fixed or still need fixin'...either way I'll let you know. :+1:

kylos101 avatar Nov 06 '21 02:11 kylos101

Thank you @kylos101 :muscle:

alexellis avatar Nov 06 '21 08:11 alexellis

Hi, it's definitely still an issue, I was able to recreate using the instructions in this issue.

I started a fix last night, and will share a draft later today.

kylos101 avatar Nov 07 '21 12:11 kylos101

Evening :wave: , the :wrench: for this should be all set in #902 , let me know if any changes are needed? :+1: :+1:

kylos101 avatar Nov 21 '21 17:11 kylos101

Hey @alexellis , may I ask for you to take a peek at #902, and let me know if you'd like anything else?

I tested in Linux and Windows, wrote new unit tests (hooray, coverage!), and asserted no existing tests are broken.

kylos101 avatar Dec 01 '21 22:12 kylos101

I did take a look already and commented.

I'll add it to the project view so it doesn't keep getting bumped off my radar.

https://github.com/orgs/openfaas/projects/5

alexellis avatar Dec 03 '21 09:12 alexellis

Hey @alexellis , I might be missing something... :worried:

I thought I addressed your comments from the initial review 21 days ago in a52cd2b. Can you share any feedback that I have not addressed / you would like me to do (a link is okay too)? :+1: :+1:

kylos101 avatar Dec 04 '21 00:12 kylos101

Nvm, I get it now, we're working from a Github project - cool. I'll follow-up in #contributors.

kylos101 avatar Dec 05 '21 15:12 kylos101

Hey @alexellis :wave:

This one should be all set now :partying_face: :tada:

Lemme know if anything else is needed?

kylos101 avatar Dec 15 '21 01:12 kylos101