diff --git a/go/plumbing/operations/upload_deploy_function_parameters.go b/go/plumbing/operations/upload_deploy_function_parameters.go index 6246974b..3cadead4 100644 --- a/go/plumbing/operations/upload_deploy_function_parameters.go +++ b/go/plumbing/operations/upload_deploy_function_parameters.go @@ -69,6 +69,8 @@ type UploadDeployFunctionParams struct { DeployID string /*FileBody*/ FileBody io.ReadCloser + /*InvocationMode*/ + InvocationMode *string /*Name*/ Name string /*Runtime*/ @@ -147,6 +149,17 @@ func (o *UploadDeployFunctionParams) SetFileBody(fileBody io.ReadCloser) { o.FileBody = fileBody } +// WithInvocationMode adds the invocationMode to the upload deploy function params +func (o *UploadDeployFunctionParams) WithInvocationMode(invocationMode *string) *UploadDeployFunctionParams { + o.SetInvocationMode(invocationMode) + return o +} + +// SetInvocationMode adds the invocationMode to the upload deploy function params +func (o *UploadDeployFunctionParams) SetInvocationMode(invocationMode *string) { + o.InvocationMode = invocationMode +} + // WithName adds the name to the upload deploy function params func (o *UploadDeployFunctionParams) WithName(name string) *UploadDeployFunctionParams { o.SetName(name) @@ -208,6 +221,22 @@ func (o *UploadDeployFunctionParams) WriteToRequest(r runtime.ClientRequest, reg } } + if o.InvocationMode != nil { + + // query param invocation_mode + var qrInvocationMode string + if o.InvocationMode != nil { + qrInvocationMode = *o.InvocationMode + } + qInvocationMode := qrInvocationMode + if qInvocationMode != "" { + if err := r.SetQueryParam("invocation_mode", qInvocationMode); err != nil { + return err + } + } + + } + // path param name if err := r.SetPathParam("name", o.Name); err != nil { return err diff --git a/go/porcelain/deploy.go b/go/porcelain/deploy.go index 4d3a44b5..9a3c724b 100644 --- a/go/porcelain/deploy.go +++ b/go/porcelain/deploy.go @@ -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 { + InvocationMode string +} + type toolchainSpec struct { Runtime string `json:"runtime"` } @@ -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) } @@ -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 } @@ -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 @@ -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, @@ -875,6 +887,8 @@ func newFunctionFile(filePath string, i os.FileInfo, runtime string, observer De } } + file.FunctionMetadata = metadata + return file, nil } diff --git a/go/porcelain/deploy_test.go b/go/porcelain/deploy_test.go index 75121cdc..1874b891 100644 --- a/go/porcelain/deploy_test.go +++ b/go/porcelain/deploy_test.go @@ -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 @@ -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) diff --git a/go/porcelain/functions_manifest.go b/go/porcelain/functions_manifest.go index e884ff9b..bedd5ee0 100644 --- a/go/porcelain/functions_manifest.go +++ b/go/porcelain/functions_manifest.go @@ -15,4 +15,5 @@ type functionsManifestEntry struct { Schedule string `json:"schedule"` DisplayName string `json:"displayName"` Generator string `json:"generator"` + InvocationMode string `json:"invocation_mode"` } diff --git a/swagger.yml b/swagger.yml index 0e15cdd8..ffbe8b21 100644 --- a/swagger.yml +++ b/swagger.yml @@ -1357,6 +1357,9 @@ paths: - name: runtime type: string in: query + - name: invocation_mode + in: query + type: string - name: size type: integer in: query