Skip to content

Commit 1a5ef29

Browse files
feat: pass invocation_mode property to uploadDeployFunction endpoint (#454)
* feat: add `invocation_mode` to functions config * feat: pass `invocation_mode` field to deploy * refactor: move `invocation_mode` to function endpoint * chore: remove comment
1 parent 056ce3d commit 1a5ef29

File tree

5 files changed

+60
-10
lines changed

5 files changed

+60
-10
lines changed

go/plumbing/operations/upload_deploy_function_parameters.go

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/porcelain/deploy.go

+23-9
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,21 @@ type uploadError struct {
106106
}
107107

108108
type FileBundle struct {
109-
Name string
110-
Sum string
111-
Runtime string
112-
Size *int64 `json:"size,omitempty"`
109+
Name string
110+
Sum string
111+
Runtime string
112+
Size *int64 `json:"size,omitempty"`
113+
FunctionMetadata *FunctionMetadata
113114

114115
// Path OR Buffer should be populated
115116
Path string
116117
Buffer io.ReadSeeker
117118
}
118119

120+
type FunctionMetadata struct {
121+
InvocationMode string
122+
}
123+
119124
type toolchainSpec struct {
120125
Runtime string `json:"runtime"`
121126
}
@@ -517,6 +522,10 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl
517522
params = params.WithXNfRetryCount(&retryCount)
518523
}
519524

525+
if f.FunctionMetadata != nil {
526+
params = params.WithInvocationMode(&f.FunctionMetadata.InvocationMode)
527+
}
528+
520529
if timeout != 0 {
521530
params.SetTimeout(timeout)
522531
}
@@ -705,19 +714,19 @@ func bundle(ctx context.Context, functionDir string, observer DeployObserver) (*
705714
if err != nil {
706715
return nil, nil, nil, err
707716
}
708-
file, err := newFunctionFile(filePath, i, runtime, observer)
717+
file, err := newFunctionFile(filePath, i, runtime, nil, observer)
709718
if err != nil {
710719
return nil, nil, nil, err
711720
}
712721
functions.Add(file.Name, file)
713722
case jsFile(i):
714-
file, err := newFunctionFile(filePath, i, jsRuntime, observer)
723+
file, err := newFunctionFile(filePath, i, jsRuntime, nil, observer)
715724
if err != nil {
716725
return nil, nil, nil, err
717726
}
718727
functions.Add(file.Name, file)
719728
case goFile(filePath, i, observer):
720-
file, err := newFunctionFile(filePath, i, goRuntime, observer)
729+
file, err := newFunctionFile(filePath, i, goRuntime, nil, observer)
721730
if err != nil {
722731
return nil, nil, nil, err
723732
}
@@ -768,7 +777,10 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
768777
runtime = function.Runtime
769778
}
770779

771-
file, err := newFunctionFile(function.Path, fileInfo, runtime, observer)
780+
meta := FunctionMetadata{
781+
InvocationMode: function.InvocationMode,
782+
}
783+
file, err := newFunctionFile(function.Path, fileInfo, runtime, &meta, observer)
772784

773785
if err != nil {
774786
return nil, nil, nil, err
@@ -824,7 +836,7 @@ func readZipRuntime(filePath string) (string, error) {
824836
return jsRuntime, nil
825837
}
826838

827-
func newFunctionFile(filePath string, i os.FileInfo, runtime string, observer DeployObserver) (*FileBundle, error) {
839+
func newFunctionFile(filePath string, i os.FileInfo, runtime string, metadata *FunctionMetadata, observer DeployObserver) (*FileBundle, error) {
828840
file := &FileBundle{
829841
Name: strings.TrimSuffix(i.Name(), filepath.Ext(i.Name())),
830842
Runtime: runtime,
@@ -875,6 +887,8 @@ func newFunctionFile(filePath string, i os.FileInfo, runtime string, observer De
875887
}
876888
}
877889

890+
file.FunctionMetadata = metadata
891+
878892
return file, nil
879893
}
880894

go/porcelain/deploy_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ func TestBundleWithManifest(t *testing.T) {
448448
"path": "%s",
449449
"runtime": "some-other-runtime",
450450
"mainFile": "/some/path/hello-py-function-test",
451-
"name": "hello-py-function-test"
451+
"name": "hello-py-function-test",
452+
"invocation_mode": "stream"
452453
}
453454
],
454455
"version": 1
@@ -467,7 +468,9 @@ func TestBundleWithManifest(t *testing.T) {
467468

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

472475
assert.Equal(t, 1, len(functionsConfig))
473476
assert.Equal(t, "Hello Javascript Function", functionsConfig["hello-js-function-test"].DisplayName)

go/porcelain/functions_manifest.go

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ type functionsManifestEntry struct {
1515
Schedule string `json:"schedule"`
1616
DisplayName string `json:"displayName"`
1717
Generator string `json:"generator"`
18+
InvocationMode string `json:"invocation_mode"`
1819
}

swagger.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,9 @@ paths:
13571357
- name: runtime
13581358
type: string
13591359
in: query
1360+
- name: invocation_mode
1361+
in: query
1362+
type: string
13601363
- name: size
13611364
type: integer
13621365
in: query

0 commit comments

Comments
 (0)