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

"faas-cli new" should accept option to use default stack.yml name

Open alexellis opened this issue 6 years ago • 6 comments

When typing in faas-cli new --lang node html-project for instance you get a YAML file named html-project.

We introduced "stack.yml" as a default file-name, but have no way of generating a new function with the stack name of stack.yml. You have to rename it afterwards.

What ideas do you have for allowing this without getting to verbose in the CLI?

faas new --lang python tester --stack=stack.yml

We do have an append flag - perhaps we could look at collapsing the --stack and --append flag into one option?

alexellis avatar Apr 07 '18 08:04 alexellis

with introduction of: --stack, the <function_name>.yml can be default otherwise it will pick file name provided by the --stack one point to think when combined --stack and --append is: in case user wants to create a fresh stack.yml file rather than appending to the existing one. We can have append as a default behaviour considering that file already exists, but what if user wants to override ?

Option 1:

We can have --override as a flag, to replace the stack.yml in case it exists. And completely remove the --append, as its the default behaviour example:

faas-cli new text-reader --lang python --stack  /myawesomenewfunc/stack.yml --override

Option 2:

One other way is to have --append as a flag. It its not provided and the stack file already exists, by default it will fail saying:

$ faas-cli new text-reader --lang python --stack  /myawesomenewfunc/stack.yml
   error: file <filename>.yml already exists
   use --append to append to existing YAML file
   use --force to replace the existing YAML file

Here --force flag can be used to replace the existing stack file

I personally prefer the Option 1

s8sg avatar Apr 07 '18 23:04 s8sg

I like --stack to perform the functionality of:

  • create your function in a new stack.yml if the file does not exist in your current directory
  • append the function definition to stack.yml if it exists

I would then vote to remove --append. I think there is no need for --override here.

ericstoekl avatar Apr 07 '18 23:04 ericstoekl

I like the idea where ‘—stack’ performs both functions with the functions appended if the target file already exists. @s8sg do you want to go ahead and work on this?

alexellis avatar Apr 08 '18 22:04 alexellis

@alexellis Sure I'm on it

s8sg avatar Apr 09 '18 00:04 s8sg

What's the status of this issue? I can see the PR closed.

ivanayov avatar Nov 08 '18 17:11 ivanayov

Should we be closing this? I saw Swarvanu and Eric both worked on this issue but both PRs got closed, does this mean the Issue is obsolete?

martindekov avatar Dec 28 '18 20:12 martindekov