Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Use sourceDir and handler to build functions #470

Merged
merged 2 commits into from
May 23, 2018

Conversation

imikushin
Copy link
Contributor

@imikushin imikushin commented May 22, 2018

Implement #416

Get rid of Exec when creating functions and building function images.
Build function images before calling faasDriver.Create().
Write the source dir.
rm function.Code field.
Move TarDir and Untar to tar.go
Add TarGzBytes() to utils/tar.go
CLI: create function.
Function.sourcePath for seed.yaml
TarDir to correctly normalize paths.
Migrate e2e tests.

@@ -13,7 +13,7 @@
dispatch create image python3 python3

Create a function:
dispatch create function python3 hello-python examples/python3/hello.py
dispatch create function --image=python3 hello-python examples/python3 --handler=hello.handle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really, really want to also preserve the existing support for simply specifying a filename as a function (without handler). If I specify a single file (i.e. examples/python3/hello.py) it should be implicit that we are going to use --handler hello.handle. We don't even need to do anything fancy to support this, it could all be hidden in the CLI.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I still haven't had my coffee :). But the CLI could take care of simply tar'ing up a single file in the "current" usage pattern, but the base image would likely have to call the "default handler" as it's very language specific. Anyway, I'd like to gauge the effort required to support this.

tenczar
tenczar previously approved these changes May 23, 2018
@@ -149,7 +149,7 @@ In order to create the *image*, **Dispatch image manager** does the following:

A **user** creates a *function* from a source file using the specified *image*:

$ dispatch create function js-deps hello1 ./hello.js
$ dispatch create function --image=js-deps hello1 . --handler=./hello.js

Here, the *function* named `hello1` is created from the source file `./hello.js` using the image `js-deps` containing library packages that can be used by the *function*.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably mention that you are using the current directory as source files for the function.

Run: func(cmd *cobra.Command, args []string) {
err := createFunction(out, errOut, cmd, args)
CheckErr(err)
},
}
cmd.Flags().StringVar(&depsImage, "image", "", "REQUIRED: image to build function on")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to add:

cmd.MarkFlagRequired("image")
cmd.MarkFlagRequired("handler")

Ivan Mikushin added 2 commits May 23, 2018 11:02
Get rid of Exec when creating functions and building function images.
Build function images *before* calling faasDriver.Create().
Write the source dir.
rm function.Code field.
Move TarDir and Untar to tar.go
Add TarGzBytes() to utils/tar.go
CLI: create function.
Function.sourcePath for seed.yaml
TarDir to correctly normalize paths.
Migrate e2e tests.
@imikushin imikushin merged commit a37e57b into vmware-archive:master May 23, 2018
@imikushin imikushin deleted the source-dir branch May 23, 2018 19:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants