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

Default Function (Stack) File Name

Open jameschensmith opened this issue 7 years ago • 9 comments
trafficstars

There are multiple points in our documentation where we either ask the user to change the function file name to stack.yml or just basically reference the function file as stack.yml despite it not always being called that. It seems that we are heading in the direction while OpenFaaS is growing to begin enforcing a standard file name. This brings up the following discussion points to consider:

  1. Should we by default use stack.yml when creating new functions instead of the function name
  2. Should we standardize and enforce the file name to become a package.json-esque project file
  3. Should we introduce an additional command to deal with function stacks

With regards to the first point, by doing this we also bring up the potential to eliminate the --append flag. By eliminating this flag and continuing to disallow duplicate function names, a more efficient flow is allowed by reducing the verbosity of the commands and eliminating user interference of file renaming. In addition, -f/ --yaml flag will be used to choose the file name for creating / appending to.

For the second point, the benefit of this would be more control over build consistency as the project grows. An alternative to this could be allowing the user to provide the file name other than stack.yml.

The third point references a suggestion brought up by @burtonr. His suggestion was to include a command (ex. faas stack) that would work with the multiple function files, and be able to combine / split them as needed. This is more of a tool expansion than the reduction that I was suggesting, but offers additional flexibility for the user such as the following: renaming the function file as suggested in the documentation, and handling multiple stack files in the same directory.

Impact Considerations

  • If my current directory contains multiple function files, how will the following change(s) handle it?
    • If the second point is agreed upon, faas new will combine all function files into a single stack.yml including the new desired function
    • If the third point is agreed upon, the function will continue along the current usage, while introducing the faas stack command to manage the function files
    • Otherwise, files will remain untouched, and faas new will create / append to stack.yml or included file name flag

jameschensmith avatar Aug 07 '18 06:08 jameschensmith

Thanks for opening this issue @james-r-smith

"Should we by default use stack.yml when creating new functions instead of the function name" - it's a good proposal. The problem here is what happens if we overwrite an alredy existing file, should we merge them or print a warning advising to create the function in a folder without stack.yml, etc. The current default behaviour with function-name.yml is a good solution of this problem, but there can be better.

faas stack would eliminate the manual efforts for moving to or editing the stack.yml. F.e. faas stack --merge [FILE1 FILE2] can merge all or just the listed files in stack.yml, an --overwrite flag can replace the existing stack, etc.

ivanayov avatar Aug 07 '18 09:08 ivanayov

Derek add label: design/review

ivanayov avatar Aug 07 '18 09:08 ivanayov

Derek add label: proposal

ivanayov avatar Aug 07 '18 09:08 ivanayov

Derek edit title: Default Function (Stack) File Name

ivanayov avatar Aug 07 '18 09:08 ivanayov

Similar to #371

ivanayov avatar Aug 07 '18 12:08 ivanayov

Hey @ivanayov, thanks for the input. 😊 In the concern you mentioned, my suggestion is to merge the file into stack.yml. I can think of three scenarios to handle currently:

  1. Initializing a new workspace
  2. Adding to an existing workspace without stack.yml
  3. Adding to an existing workspace with stack.yml

In all scenarios, when I first call faas new <FN_NAME> --lang=<LANG> the result is a stack.yml file with the new function, and any other functions from any other existing file appended to the stack.yml. I suggest when merging files, a message will be logged for each unique file other than stack.yml. When I call faas new <FN_NAME> --lang=<LANG> a second time with no interference in between, only stack.yml will need to be updated.

@alexellis, regarding the second point that I mentioned, what is the end goal for the function file? Are we wanting to standardize stack.yml?

jameschensmith avatar Aug 07 '18 15:08 jameschensmith

Probably worth catching up with some of the discussion on #373 too.

rgee0 avatar Aug 07 '18 20:08 rgee0

As an outsider evaluating OpenFaaS. The default filename ‘stack.yaml’ would be unfortunate for any Haskeller since it clashes with the Stack toolchain. https://github.com/commercialhaskell/stack

colbyn avatar Sep 09 '18 00:09 colbyn

@colbyn our file won't clash since it's named stack.yml.

Let's not get confused in the issue - the default is already stack.yml.

alexellis avatar Oct 14 '18 08:10 alexellis