Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions go/plumbing/operations/upload_deploy_function_parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 23 additions & 9 deletions go/porcelain/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,21 @@ type uploadError struct {
}

type FileBundle struct {
Name string
Sum string
Runtime string
Size *int64 `json:"size,omitempty"`
Name string
Sum string
Runtime string
Size *int64 `json:"size,omitempty"`
FunctionMetadata *FunctionMetadata

// Path OR Buffer should be populated
Path string
Buffer io.ReadSeeker
}

type FunctionMetadata struct {
Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a struct because I can imagine us adding more function-specific properties in the future, and since FileBundle is shared with static files, it'd be a bit odd to pollute it with a bunch of function-specific properties.

In the future, it would make sense to also move Runtime to this struct, as it's also specific to functions.

InvocationMode string
}

type toolchainSpec struct {
Runtime string `json:"runtime"`
}
Expand Down Expand Up @@ -517,6 +522,10 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl
params = params.WithXNfRetryCount(&retryCount)
}

if f.FunctionMetadata != nil {
params = params.WithInvocationMode(&f.FunctionMetadata.InvocationMode)
}

if timeout != 0 {
params.SetTimeout(timeout)
}
Expand Down Expand Up @@ -705,19 +714,19 @@ func bundle(ctx context.Context, functionDir string, observer DeployObserver) (*
if err != nil {
return nil, nil, nil, err
}
file, err := newFunctionFile(filePath, i, runtime, observer)
file, err := newFunctionFile(filePath, i, runtime, nil, observer)
if err != nil {
return nil, nil, nil, err
}
functions.Add(file.Name, file)
case jsFile(i):
file, err := newFunctionFile(filePath, i, jsRuntime, observer)
file, err := newFunctionFile(filePath, i, jsRuntime, nil, observer)
if err != nil {
return nil, nil, nil, err
}
functions.Add(file.Name, file)
case goFile(filePath, i, observer):
file, err := newFunctionFile(filePath, i, goRuntime, observer)
file, err := newFunctionFile(filePath, i, goRuntime, nil, observer)
if err != nil {
return nil, nil, nil, err
}
Expand Down Expand Up @@ -768,7 +777,10 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
runtime = function.Runtime
}

file, err := newFunctionFile(function.Path, fileInfo, runtime, observer)
meta := FunctionMetadata{
InvocationMode: function.InvocationMode,
}
file, err := newFunctionFile(function.Path, fileInfo, runtime, &meta, observer)

if err != nil {
return nil, nil, nil, err
Expand Down Expand Up @@ -824,7 +836,7 @@ func readZipRuntime(filePath string) (string, error) {
return jsRuntime, nil
}

func newFunctionFile(filePath string, i os.FileInfo, runtime string, observer DeployObserver) (*FileBundle, error) {
func newFunctionFile(filePath string, i os.FileInfo, runtime string, metadata *FunctionMetadata, observer DeployObserver) (*FileBundle, error) {
file := &FileBundle{
Name: strings.TrimSuffix(i.Name(), filepath.Ext(i.Name())),
Runtime: runtime,
Expand Down Expand Up @@ -875,6 +887,8 @@ func newFunctionFile(filePath string, i os.FileInfo, runtime string, observer De
}
}

file.FunctionMetadata = metadata

return file, nil
}

Expand Down
5 changes: 4 additions & 1 deletion go/porcelain/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ func TestBundleWithManifest(t *testing.T) {
"path": "%s",
"runtime": "some-other-runtime",
"mainFile": "/some/path/hello-py-function-test",
"name": "hello-py-function-test"
"name": "hello-py-function-test",
"invocation_mode": "stream"
}
],
"version": 1
Expand All @@ -467,7 +468,9 @@ func TestBundleWithManifest(t *testing.T) {

assert.Equal(t, 2, len(functions.Files))
assert.Equal(t, "a-runtime", functions.Files["hello-js-function-test"].Runtime)
assert.Empty(t, functions.Files["hello-js-function-test"].FunctionMetadata.InvocationMode)
assert.Equal(t, "some-other-runtime", functions.Files["hello-py-function-test"].Runtime)
assert.Equal(t, "stream", functions.Files["hello-py-function-test"].FunctionMetadata.InvocationMode)

assert.Equal(t, 1, len(functionsConfig))
assert.Equal(t, "Hello Javascript Function", functionsConfig["hello-js-function-test"].DisplayName)
Expand Down
1 change: 1 addition & 0 deletions go/porcelain/functions_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ type functionsManifestEntry struct {
Schedule string `json:"schedule"`
DisplayName string `json:"displayName"`
Generator string `json:"generator"`
InvocationMode string `json:"invocation_mode"`
}
3 changes: 3 additions & 0 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,9 @@ paths:
- name: runtime
type: string
in: query
- name: invocation_mode
in: query
type: string
- name: size
type: integer
in: query
Expand Down