openfaas / faas-cli

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

Design review: custom files for handlers #321

Open alexellis opened 6 years ago

alexellis commented 6 years ago

What would it take for us to be able to support a different project file name for a C# template for instance?

Frank P @fpommerening from Germany reported that two templates in a Visual Studio project you end up with Function.csproj twice in the UI and that this is confusing - even more so when you have 4-5 functions.

Solution:
  + Function
      - Handler.cs
  + Function
      - Handler.cs

What do we think?

How could we allow a custom project name without breaking the simplicity of our templating system in the faas-cli?

This would also apply for things like an interpreted language where there is no project file - just a raw handler. If you're editing 10x Node functions in Atom for instance you'll see:

fn1/handler.js
fn2/handler.js
fn3/handler.js

Lastly - this is just to promote discussion and look at the options. I want us to look at it since we've had user feedback, but it doesn't mean that the CLI is broken or that it's not possible to be productive.

fpommerening commented 6 years ago

I have adapted the template for C # to support any project name. https://github.com/fpommerening/faas-cli/blob/master/template/csharp/Dockerfile The dotnet CLI creates the reference between the main project "root" and the function.

My problem is, that the build command always copy the template in the build folder.

As a result I have my renamed project file and additionally the project file from the template. It would be nice if there is build argument to prevent the copy of the template.

itscaro commented 6 years ago

I think the function directory inside a template should not be copied during build, since the function directory is only useful for new function command.

    // Drop in directory tree from template
    CopyFiles("./template/"+language, tempPath)
    os.RemoveAll("./template/"+language+"/function") #<== new line

    // Overlay in user-function
    CopyFiles(handler, tempPath+"function/")