From f9e72deacc3c0b2c3c825ffca5df9f8f73ffcce8 Mon Sep 17 00:00:00 2001 From: Damian Badura Date: Wed, 28 Jun 2023 14:53:29 +0200 Subject: [PATCH 1/2] remove nodejs14 --- function/pkg/docker/runtimes/runtimes.go | 18 +--- function/pkg/docker/runtimes/runtimes_test.go | 98 ------------------- function/pkg/resources/types/runtimes.go | 1 - function/pkg/workspace/workspace.go | 6 +- function/pkg/workspace/workspace_test.go | 18 ---- .../pkg/workspace/writer_provider_test.go | 6 +- 6 files changed, 8 insertions(+), 139 deletions(-) diff --git a/function/pkg/docker/runtimes/runtimes.go b/function/pkg/docker/runtimes/runtimes.go index e66d849f..9364ead8 100644 --- a/function/pkg/docker/runtimes/runtimes.go +++ b/function/pkg/docker/runtimes/runtimes.go @@ -43,7 +43,7 @@ func ContainerEnvs(runtime types.Runtime, hotDeploy bool) []string { func runtimeEnvs(runtime types.Runtime, hotDeploy bool) []string { switch runtime { - case types.Nodejs14, types.Nodejs16, types.Nodejs18: + case types.Nodejs16, types.Nodejs18: return []string{NodejsPath, "HOME=/home/node"} case types.Python39: envs := []string{Python39Path, Python39Unbuffered} @@ -58,7 +58,7 @@ func runtimeEnvs(runtime types.Runtime, hotDeploy bool) []string { func RuntimeDebugPort(runtime types.Runtime) string { switch runtime { - case types.Nodejs14, types.Nodejs16, types.Nodejs18: + case types.Nodejs16, types.Nodejs18: return NodejsDebugEndpoint case types.Python39: return Python39DebugEndpoint @@ -69,18 +69,6 @@ func RuntimeDebugPort(runtime types.Runtime) string { func ContainerCommands(runtime types.Runtime, debug bool, hotDeploy bool) []string { switch runtime { - case types.Nodejs14: - runCommand := "" - if hotDeploy && debug { - runCommand = "npx nodemon --watch /kubeless/*.js --inspect=0.0.0.0 --exitcrash kubeless.js " - } else if hotDeploy { - runCommand = "npx nodemon --watch /kubeless/*.js /kubeless_rt/kubeless.js" - } else if debug { - runCommand = "node --inspect=0.0.0.0 kubeless.js " - } else { - runCommand = "node kubeless.js" - } - return []string{"npm install --production --prefix=$KUBELESS_INSTALL_VOLUME", runCommand} case types.Nodejs16, types.Nodejs18: runCommand := "" if hotDeploy && debug { @@ -155,8 +143,6 @@ func MoveInlineCommand(runtime types.Runtime, sourcePath, depsPath string) []str func ContainerImage(runtime types.Runtime) string { switch runtime { - case types.Nodejs14: - return "eu.gcr.io/kyma-project/function-runtime-nodejs14:v20230224-e59c5082" case types.Nodejs16: return "eu.gcr.io/kyma-project/function-runtime-nodejs16:v20230228-b2981e80" case types.Nodejs18: diff --git a/function/pkg/docker/runtimes/runtimes_test.go b/function/pkg/docker/runtimes/runtimes_test.go index 26aad964..92ace2ab 100644 --- a/function/pkg/docker/runtimes/runtimes_test.go +++ b/function/pkg/docker/runtimes/runtimes_test.go @@ -84,40 +84,6 @@ func TestContainerEnvs(t *testing.T) { "HOME=/home/node", }, }, - { - name: "should return envs for nodejs14", - args: args{ - runtime: types.Nodejs14, - hotDeploy: false, - }, - want: []string{ - "KUBELESS_INSTALL_VOLUME=/kubeless", - "FUNC_RUNTIME=nodejs14", - "FUNC_HANDLER=main", - "MOD_NAME=handler", - "FUNC_PORT=8080", - "SERVICE_NAMESPACE=default", - NodejsPath, - "HOME=/home/node", - }, - }, - { - name: "should return envs for nodejs14 with hotDeploy", - args: args{ - runtime: types.Nodejs14, - hotDeploy: true, - }, - want: []string{ - "KUBELESS_INSTALL_VOLUME=/kubeless", - "FUNC_RUNTIME=nodejs14", - "FUNC_HANDLER=main", - "MOD_NAME=handler", - "FUNC_PORT=8080", - "SERVICE_NAMESPACE=default", - NodejsPath, - "HOME=/home/node", - }, - }, { name: "should return envs for python39", args: args{ @@ -191,11 +157,6 @@ func TestRuntimeDebugPort(t *testing.T) { runtime: "", want: "9229", }, - { - name: "should return nodejs14 debug port", - runtime: types.Nodejs14, - want: NodejsDebugEndpoint, - }, { name: "should return nodejs16 debug port", runtime: types.Nodejs16, @@ -261,25 +222,6 @@ func TestContainerCommands(t *testing.T) { "npm install --production --prefix=$KUBELESS_INSTALL_VOLUME", "npx nodemon --watch /kubeless/*.js /kubeless_rt/kubeless.js", }, }, - { - name: "should return commands for Nodejs14", - args: args{ - runtime: types.Nodejs14, - }, - want: []string{ - "npm install --production --prefix=$KUBELESS_INSTALL_VOLUME", "node kubeless.js", - }, - }, - { - name: "should return commands for Nodejs14 with hotDeploy", - args: args{ - runtime: types.Nodejs14, - hotDeploy: true, - }, - want: []string{ - "npm install --production --prefix=$KUBELESS_INSTALL_VOLUME", "npx nodemon --watch /kubeless/*.js /kubeless_rt/kubeless.js", - }, - }, { name: "should return commands for Nodejs16", args: args{ @@ -396,13 +338,6 @@ func TestContainerImage(t *testing.T) { }, want: "eu.gcr.io/kyma-project/function-runtime-nodejs18:v20230228-b2981e80", }, - { - name: "should return image for Nodejs14", - args: args{ - runtime: types.Nodejs14, - }, - want: "eu.gcr.io/kyma-project/function-runtime-nodejs14:v20230224-e59c5082", - }, { name: "should return image for Nodejs16", args: args{ @@ -445,39 +380,6 @@ func TestGetMounts(t *testing.T) { args args want []mount.Mount }{ - { - name: "should return mount for source type inline", - args: args{ - runtime: types.Nodejs14, - sourceType: workspace.SourceTypeInline, - workDir: "/your/work/dir", - }, - want: []mount.Mount{ - { - Type: mount.TypeBind, - Source: "/your/work/dir", - Target: KubelessTmpPath, - }, - { - Type: mount.TypeVolume, - Target: KubelessPath, - }, - }, - }, - { - name: "should return mount for source type git", - args: args{ - runtime: types.Nodejs14, - sourceType: workspace.SourceTypeGit, - }, - want: []mount.Mount{ - { - Type: mount.TypeBind, - Source: "", - Target: KubelessPath, - }, - }, - }, { name: "should return mount for nodejs16", args: args{ diff --git a/function/pkg/resources/types/runtimes.go b/function/pkg/resources/types/runtimes.go index 1c229e5f..916571b6 100644 --- a/function/pkg/resources/types/runtimes.go +++ b/function/pkg/resources/types/runtimes.go @@ -4,7 +4,6 @@ type Runtime = string // List of supported runtimes const ( - Nodejs14 Runtime = "nodejs14" Nodejs16 Runtime = "nodejs16" Nodejs18 Runtime = "nodejs18" Python39 Runtime = "python39" diff --git a/function/pkg/workspace/workspace.go b/function/pkg/workspace/workspace.go index a450abfd..f6127e7f 100644 --- a/function/pkg/workspace/workspace.go +++ b/function/pkg/workspace/workspace.go @@ -49,7 +49,7 @@ func initialize(cfg Cfg, dirPath string, writerProvider WriterProvider) (err err func fromSources(runtime string, source, deps string) (workspace, error) { switch runtime { - case types.Nodejs14, types.Nodejs16, types.Nodejs18: + case types.Nodejs16, types.Nodejs18: return workspace{ NewTemplatedFile(source, FileNameHandlerJs), NewTemplatedFile(deps, FileNamePackageJSON), @@ -66,7 +66,7 @@ func fromSources(runtime string, source, deps string) (workspace, error) { func fromRuntime(runtime types.Runtime) (workspace, error) { switch runtime { - case types.Nodejs14, types.Nodejs16, types.Nodejs18: + case types.Nodejs16, types.Nodejs18: return workspaceNodeJs, nil case types.Python39: return workspacePython, nil @@ -81,7 +81,7 @@ type DepsFileName = string func InlineFileNames(r types.Runtime) (SourceFileName, DepsFileName, bool) { switch r { - case types.Nodejs14, types.Nodejs16, types.Nodejs18: + case types.Nodejs16, types.Nodejs18: return string(FileNameHandlerJs), string(FileNamePackageJSON), true case types.Python39: return string(FileNameHandlerPy), string(FileNameRequirementsTxt), true diff --git a/function/pkg/workspace/workspace_test.go b/function/pkg/workspace/workspace_test.go index fd465804..8bcaab1a 100644 --- a/function/pkg/workspace/workspace_test.go +++ b/function/pkg/workspace/workspace_test.go @@ -157,14 +157,6 @@ func Test_fromRuntime(t *testing.T) { want: workspaceNodeJs, wantErr: false, }, - { - name: "nodejs14", - args: args{ - runtime: types.Nodejs14, - }, - want: workspaceNodeJs, - wantErr: false, - }, { name: "python39", args: args{ @@ -219,16 +211,6 @@ func Test_fromSources(t *testing.T) { want: workspace{}, wantErr: true, }, - { - name: "nodejs14", - args: args{ - runtime: types.Nodejs14, - source: handlerJs, - deps: packageJSON, - }, - want: workspaceNodeJs, - wantErr: false, - }, { name: "python39", args: args{ diff --git a/function/pkg/workspace/writer_provider_test.go b/function/pkg/workspace/writer_provider_test.go index 1262df2e..15096e7e 100644 --- a/function/pkg/workspace/writer_provider_test.go +++ b/function/pkg/workspace/writer_provider_test.go @@ -41,7 +41,7 @@ func TestWriterProvider_write(t *testing.T) { Labels: map[string]string{}, Namespace: "test-namespace", Resources: Resources{}, - Runtime: types.Nodejs14, + Runtime: types.Nodejs18, Subscriptions: []Subscription{}, }, }, @@ -62,7 +62,7 @@ func TestWriterProvider_write(t *testing.T) { Labels: map[string]string{}, Namespace: "test-namespace", Resources: Resources{}, - Runtime: types.Nodejs14, + Runtime: types.Nodejs18, Subscriptions: []Subscription{}, }, }, @@ -81,7 +81,7 @@ func TestWriterProvider_write(t *testing.T) { Labels: map[string]string{}, Namespace: "test-namespace", Resources: Resources{}, - Runtime: types.Nodejs14, + Runtime: types.Nodejs18, Subscriptions: []Subscription{}, }, }, From 16226c8f32e7eacc906311475adef13bb0757bfd Mon Sep 17 00:00:00 2001 From: Damian Badura Date: Wed, 28 Jun 2023 15:05:54 +0200 Subject: [PATCH 2/2] remove nodejs14 --- function/examples/cmd/workspace/sync/main.go | 2 +- function/pkg/workspace/cfg.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/function/examples/cmd/workspace/sync/main.go b/function/examples/cmd/workspace/sync/main.go index ad5ca2a4..f8b29a66 100644 --- a/function/examples/cmd/workspace/sync/main.go +++ b/function/examples/cmd/workspace/sync/main.go @@ -84,7 +84,7 @@ spec: requests: cpu: 50m memory: 64Mi - runtime: nodejs14 + runtime: nodejs18 source: |- module.exports = { main: function (event, context) { diff --git a/function/pkg/workspace/cfg.go b/function/pkg/workspace/cfg.go index b0e63488..adfdd8bc 100644 --- a/function/pkg/workspace/cfg.go +++ b/function/pkg/workspace/cfg.go @@ -132,7 +132,7 @@ type Cfg struct { Name string `yaml:"name"` Namespace string `yaml:"namespace"` Labels map[string]string `yaml:"labels,omitempty"` - Runtime types.Runtime `yaml:"runtime" jsonschema:"enum=nodejs14,enum=nodejs16,enum=nodejs18,enum=python39"` + Runtime types.Runtime `yaml:"runtime" jsonschema:"enum=nodejs16,enum=nodejs18,enum=python39"` RuntimeImageOverride string `yaml:"runtimeImageOverride,omitempty"` Source Source `yaml:"source"` Resources Resources `yaml:"resource,omitempty"`