faas-cli
faas-cli copied to clipboard
Default Function (Stack) File Name
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:
- Should we by default use
stack.ymlwhen creating new functions instead of the function name - Should we standardize and enforce the file name to become a
package.json-esque project file - 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 newwill combine all function files into a singlestack.ymlincluding the new desired function - If the third point is agreed upon, the function will continue along the current usage, while introducing the
faas stackcommand to manage the function files - Otherwise, files will remain untouched, and
faas newwill create / append tostack.ymlor included file name flag
- If the second point is agreed upon,
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.
Derek add label: design/review
Derek add label: proposal
Derek edit title: Default Function (Stack) File Name
Similar to #371
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:
- Initializing a new workspace
- Adding to an existing workspace without
stack.yml - 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?
Probably worth catching up with some of the discussion on #373 too.
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 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.