openfaas / faas-cli

Official CLI for OpenFaaS
https://www.openfaas.com/
Other
794 stars 227 forks source link

Feature: New priority order for YAML files #635

Open alexellis opened 5 years ago

alexellis commented 5 years ago

Feature: New priority order for YAML files

Expected Behaviour

In addition to the current behaviour this feature would allow a function YAML file to be picked up by all the commands if a -f or stack.yml file is not in the current working directory.

Current Behaviour

If a stack.yml file is not found in the current working directory then a -f flag is required and the name of a YAML file. i.e. faas-cli up -f fn1.yml

Create a function

faas-cli new --lang go tester

Specify its YAML file

faas-cli up -f tester.yml

Rename to stack.yml and omit -f

mv tester.yml stack.yml
faas-cli up

Possible Solution

After the feature is implemented the following would be possible:

Create a function

faas-cli new --lang go tester

Specify no YAML file (as per stack.yml)

faas-cli up

If more than one .yml or .yaml file is found then this feature would default to the current behaviour to avoid ambiguity.

If the YAML file in the current directory is not a valid stack file then we will see some sort of parsing error.

The final priority order is:

As with our other work, unit tests should be added to cover the priority-checking.

matipan commented 5 years ago

Will this affect the faas-cli new command? If I already have a stack.yaml file in my directory and I do faas-cli new --lang go tester, will tester be added to that file?

alexellis commented 5 years ago

It will affect the --append flag

viveksyngh commented 5 years ago

I think, adding more background logic for priorities can be difficult or confusing for a new user.

alexellis commented 5 years ago

How do you know that?

What if it gets added and we see what people think to it?

Personally I'd love to not have to put long -f commands into every tutorial, workshop and blog post I write, so I can imagine that users would appreciate that too.

rajibmitra commented 5 years ago

I will be working on it.