Repository: klothoplatform/klotho (go)

Issue:
Determine whether net/http needs to be removed in go lambdas
If the only usage of this import in code is the listener then we get 

```
#11 134.4 ./main.go:9:2: "net/http" imported and not used
```
during the dockerbuild


also remove the / route on our go mega app when this is complete

Pull request:
remove http import if not used
• Does any part of it require special attention?
• Does it relate to or fix any issue? closes #332 

will find any identifier or package identifier for the net/http import and see if its used in that file. Are there any other node types im missing?

### Standard checks

- **Unit tests**: Any special considerations?
- **Docs**: Do we need to update any docs, internal or public?
- **Backwards compatibility**: Will this break existing apps? If so, what would be the extra work required to keep them working?


Patch:
diff --git a/pkg/core/topology.go b/pkg/core/topology.go
index e9a3bc11..e8e7287c 100644
--- a/pkg/core/topology.go
+++ b/pkg/core/topology.go
@@ -61,11 +61,13 @@ var DiagramEntityToImgPath = TopoMap{
 	{Kind: string(PersistRedisClusterKind)}: "generic/storage/storage.png",
 	{Kind: PubSubKind}:                      "generic/blank/blank.png",
 	{Kind: ConfigKind}:                      "generic/storage/storage.png",
+	{Kind: StaticUnitKind}:                  "generic/storage/storage.png",
 
 	// Use AWS as the ultimate fallback for the Kind, so don't specify Provider.
 	{Kind: GatewayKind, Provider: ProviderAWS, Type: "apigateway"}:      "aws/network/api-gateway.png",
 	{Kind: GatewayKind, Provider: ProviderAWS, Type: "alb"}:             "aws/network/elb-application-load-balancer.png",
 	{Kind: ExecutionUnitKind, Provider: ProviderAWS}:                    "aws/compute/lambda.png",
+	{Kind: StaticUnitKind, Provider: ProviderAWS}:                       "aws/compute/simple-storage-service-s3.png",
 	{Kind: string(PersistKVKind), Provider: ProviderAWS}:                "aws/database/dynamodb.png",
 	{Kind: string(PersistFileKind), Provider: ProviderAWS}:              "aws/compute/simple-storage-service-s3.png",
 	{Kind: string(PersistSecretKind), Provider: ProviderAWS}:            "aws/security/secrets-manager.png",
@@ -104,6 +106,7 @@ var DiagramEntityToCode = TopoMap{
 
 	{Kind: GatewayKind}:                     `generic_network.Subnet("%s")`,
 	{Kind: ExecutionUnitKind}:               `generic_compute.Rack("%s")`,
+	{Kind: StaticUnitKind}:                  `generic_storage.Storage("%s")`,
 	{Kind: string(PersistKVKind)}:           `generic_storage.Storage("%s")`,
 	{Kind: string(PersistFileKind)}:         `generic_storage.Storage("%s")`,
 	{Kind: string(PersistSecretKind)}:       `generic_storage.Storage("%s")`,
@@ -117,6 +120,7 @@ var DiagramEntityToCode = TopoMap{
 	{Kind: GatewayKind, Provider: ProviderAWS, Type: "alb"}:        `aws_network.ElbNetworkLoadBalancer("%s")`,
 
 	{Kind: ExecutionUnitKind, Provider: ProviderAWS}:                    `aws_compute.Lambda("%s")`,
+	{Kind: StaticUnitKind, Provider: ProviderAWS}:                       `aws_storage.S3("%s")`,
 	{Kind: string(PersistKVKind), Provider: ProviderAWS}:                `aws_database.Dynamodb("%s")`,
 	{Kind: string(PersistFileKind), Provider: ProviderAWS}:              `aws_storage.S3("%s")`,
 	{Kind: string(PersistSecretKind), Provider: ProviderAWS}:            `aws_security.SecretsManager("%s")`,
diff --git a/pkg/infra/kubernetes/exec_unit.go b/pkg/infra/kubernetes/exec_unit.go
index db492881..3eb74404 100644
--- a/pkg/infra/kubernetes/exec_unit.go
+++ b/pkg/infra/kubernetes/exec_unit.go
@@ -326,6 +326,24 @@ func (unit *HelmExecUnit) getServiceName() string {
 	return unit.Name
 }
 
+func (unit *HelmExecUnit) AddUnitsEnvironmentVariables(eu *core.ExecutionUnit) (values []Value, err error) {
+	if unit.Deployment != nil {
+		v, err := unit.addEnvsVarToDeployment(eu.EnvironmentVariables)
+		if err != nil {
+			return nil, err
+		}
+
+		values = append(values, v...)
+	} else if unit.Pod != nil {
+		v, err := unit.addEnvVarToPod(eu.EnvironmentVariables)
+		if err != nil {
+			return nil, err
+		}
+
+		values = append(values, v...)
+	}
+	return
+}
 func (unit *HelmExecUnit) addEnvsVarToDeployment(envVars core.EnvironmentVariables) ([]Value, error) {
 	values := []Value{}
 
diff --git a/pkg/infra/kubernetes/helm_chart.go b/pkg/infra/kubernetes/helm_chart.go
index b9538308..f511f1af 100644
--- a/pkg/infra/kubernetes/helm_chart.go
+++ b/pkg/infra/kubernetes/helm_chart.go
@@ -194,11 +194,11 @@ func (chart *KlothoHelmChart) handleExecutionUnit(unit *HelmExecUnit, eu *core.E
 	}
 	values = append(values, upstreamValues...)
 
-	persistValues, err := unit.handlePersistForExecUnit(deps)
+	unitEnvValues, err := unit.AddUnitsEnvironmentVariables(eu)
 	if err != nil {
 		return nil, err
 	}
-	values = append(values, persistValues...)
+	values = append(values, unitEnvValues...)
 
 	return values, nil
 }
diff --git a/pkg/infra/kubernetes/persist.go b/pkg/infra/kubernetes/persist.go
deleted file mode 100644
index 2834f10d..00000000
--- a/pkg/infra/kubernetes/persist.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package kubernetes
-
-import (
-	"github.com/klothoplatform/klotho/pkg/core"
-)
-
-type PersistEnvVars string
-
-func (unit *HelmExecUnit) handlePersistForExecUnit(deps *core.Dependencies) ([]Value, error) {
-	var values []Value
-	envVars := generateEnvVars(deps, unit.Name)
-
-	if len(envVars) == 0 {
-		return values, nil
-	}
-
-	if unit.Deployment != nil {
-		v, err := unit.addEnvsVarToDeployment(envVars)
-		if err != nil {
-			return nil, err
-		}
-
-		values = append(values, v...)
-	} else if unit.Pod != nil {
-		v, err := unit.addEnvVarToPod(envVars)
-		if err != nil {
-			return nil, err
-		}
-
-		values = append(values, v...)
-	}
-
-	return values, nil
-}
-
-func generateEnvVars(deps *core.Dependencies, name string) core.EnvironmentVariables {
-	envVars := core.EnvironmentVariables{}
-	for _, target := range deps.Downstream(core.ResourceKey{Name: name, Kind: core.ExecutionUnitKind}) {
-		switch target.Kind {
-		case string(core.PersistORMKind):
-			envVars = append(envVars, core.GenerateOrmConnStringEnvVar(target.Name))
-		case string(core.PersistRedisNodeKind):
-			envVars = append(
-				envVars,
-				core.GenerateRedisHostEnvVar(target.Name, target.Kind),
-				core.GenerateRedisPortEnvVar(target.Name, target.Kind),
-			)
-		case string(core.PersistRedisClusterKind):
-			envVars = append(
-				envVars,
-				core.GenerateRedisHostEnvVar(target.Name, target.Kind),
-				core.GenerateRedisPortEnvVar(target.Name, target.Kind),
-			)
-		}
-	}
-	return envVars
-}
diff --git a/pkg/infra/pulumi_aws/index.ts.tmpl b/pkg/infra/pulumi_aws/index.ts.tmpl
index d5059f74..a8a74988 100755
--- a/pkg/infra/pulumi_aws/index.ts.tmpl
+++ b/pkg/infra/pulumi_aws/index.ts.tmpl
@@ -16,7 +16,7 @@ import {CloudCCLib, kloConfig} from './deploylib'
 import {EksExecUnitArgs, EksExecUnit} from './iac/eks'
 import {CockroachDB} from './iac/cockroachdb'
 {{- if .APIGateways}}
-import {ApiGateway, Gateway, Route } from './iac/api_gateway'
+import {ApiGateway } from './iac/api_gateway'
 {{end}}
 import { LoadBalancerPlugin } from './iac/load_balancing'
 
diff --git a/pkg/input/readdir.go b/pkg/input/readdir.go
index a32b44d2..60656771 100644
--- a/pkg/input/readdir.go
+++ b/pkg/input/readdir.go
@@ -3,8 +3,6 @@ package input
 import (
 	"encoding/json"
 	"fmt"
-	"github.com/klothoplatform/klotho/pkg/filter/predicate"
-	"github.com/klothoplatform/klotho/pkg/lang/csharp/csproj"
 	"io"
 	"io/fs"
 	"os"
@@ -12,6 +10,9 @@ import (
 	"path/filepath"
 	"strings"
 
+	"github.com/klothoplatform/klotho/pkg/filter/predicate"
+	"github.com/klothoplatform/klotho/pkg/lang/csharp/csproj"
+
 	"github.com/klothoplatform/klotho/pkg/config"
 	"github.com/klothoplatform/klotho/pkg/core"
 	"github.com/klothoplatform/klotho/pkg/lang/csharp"
@@ -226,10 +227,10 @@ func ReadDir(fsys fs.FS, cfg config.Application, cfgFilePath string) (*core.Inpu
 				if tsConfig.CompilerOptions.OutDir != "" {
 					tsPrefix := tsConfig.CompilerOptions.OutDir + string(os.PathSeparator)
 					newPath := strings.TrimPrefix(path, tsPrefix) // tsPrefix is already joined to cfg.Path, so use `path` not `relPath`
-					if relPath != newPath {
+					if relPath != newPath && newPath != path {
 						zap.S().Debugf("Removing TS outdir from %s -> %s", relPath, newPath)
+						relPath = newPath
 					}
-					relPath = newPath
 				}
 				f, err = addFile(fsys, path, relPath, javascript.NewFile)
 				jsLang.foundSources = true
diff --git a/pkg/lang/golang/plugin_expose.go b/pkg/lang/golang/plugin_expose.go
index c15f90ac..56133b16 100644
--- a/pkg/lang/golang/plugin_expose.go
+++ b/pkg/lang/golang/plugin_expose.go
@@ -1,6 +1,7 @@
 package golang
 
 import (
+	"fmt"
 	"path"
 	"strings"
 
@@ -183,6 +184,11 @@ func (h *restAPIHandler) handleFile(f *core.SourceFile) (*core.SourceFile, error
 			return nil, core.NewCompilerError(f, capNode, err)
 		}
 
+		err = h.removeNetHttpImport(f)
+		if err != nil {
+			return nil, core.NewCompilerError(f, capNode, err)
+		}
+
 		router, err := h.findChiRouterDefinition(f, routerName)
 		if err != nil {
 			return nil, core.NewCompilerError(f, capNode, err)
@@ -239,6 +245,37 @@ func (h *restAPIHandler) handleFile(f *core.SourceFile) (*core.SourceFile, error
 	return f, nil
 }
 
+func (h *restAPIHandler) removeNetHttpImport(f *core.SourceFile) error {
+	h.log.Info(fmt.Sprintf("searching for http imports in %s", f.Path()))
+	netHttpImportName := "http"
+	netHttpImport := GetNamedImportInFile(f, netHttpImportName)
+	if netHttpImport.Alias != "" {
+		netHttpImportName = netHttpImport.Alias
+	}
+
+	nextMatch := doQuery(f.Tree().RootNode(), fmt.Sprintf("[((package_identifier)@id (#match? @id \"%s\")) ((identifier)@id (#match? @id \"%s\"))]", netHttpImportName, netHttpImportName))
+
+	httpUsed := false
+	for {
+		_, found := nextMatch()
+		if !found {
+			break
+		}
+		if found {
+			httpUsed = true
+			break
+		}
+	}
+
+	if !httpUsed {
+		err := UpdateImportsInFile(f, []Import{}, []Import{{Package: "net/http"}})
+		if err != nil {
+			return errors.Wrap(err, "error updating imports")
+		}
+	}
+	return nil
+}
+
 func (h *restAPIHandler) findChiRouterDefinition(f *core.SourceFile, appName string) (chiRouterDefResult, error) {
 	nextMatch := doQuery(f.Tree().RootNode(), findRouterAssignment)
 	for {


Test patch:
diff --git a/.github/workflows/run-integ-tests.yaml b/.github/workflows/run-integ-tests.yaml
index 98787e1d..d8b10530 100644
--- a/.github/workflows/run-integ-tests.yaml
+++ b/.github/workflows/run-integ-tests.yaml
@@ -131,7 +131,7 @@ jobs:
           set -x
           cd _test_resources
           npm i
-          pulumi -s integ-test-shared stack select --create
+          pulumi -s integ-test-shared-${{ env.AWS_REGION }} stack select --create
           pulumi stack tag set usage integ-test
           pulumi config refresh || true
           pulumi up -y --refresh
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index ba7ca5ad..531c1475 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -27,19 +27,4 @@ jobs:
             ${{ runner.os }}-go-
 
       - name: Run test
-        run: go test -race -v -coverprofile=coverage.out ./...
-
-      - name: Convert to Cobertura
-        run: |
-          go get github.com/t-yuki/gocover-cobertura
-          go install github.com/t-yuki/gocover-cobertura
-          gocover-cobertura < coverage.out > coverage.xml
-
-      - name: Code Coverage Summary Report
-        uses: irongut/CodeCoverageSummary@v1.2.0
-        with:
-          filename: coverage.xml
-          format: markdown
-          output: both
-          hide_complexity: true
-          hide_branch_rate: true
+        run: go test -race -v ./...
diff --git a/pkg/infra/kubernetes/exec_unit_test.go b/pkg/infra/kubernetes/exec_unit_test.go
index fd77bb68..859ce57e 100644
--- a/pkg/infra/kubernetes/exec_unit_test.go
+++ b/pkg/infra/kubernetes/exec_unit_test.go
@@ -6,6 +6,7 @@ import (
 
 	"github.com/klothoplatform/klotho/pkg/core"
 	"github.com/klothoplatform/klotho/pkg/lang/dockerfile"
+	"github.com/klothoplatform/klotho/pkg/lang/yaml"
 	yamlLang "github.com/klothoplatform/klotho/pkg/lang/yaml"
 	"github.com/stretchr/testify/assert"
 )
@@ -627,6 +628,244 @@ spec:
 	}
 }
 
+func Test_addUnitsEnvironmentVariables(t *testing.T) {
+	type testResult struct {
+		values []Value
+		file   string
+	}
+	tests := []struct {
+		name           string
+		unit           HelmExecUnit
+		deploymentYaml string
+		podYaml        string
+		deps           []core.Dependency
+		want           testResult
+		wantErr        bool
+	}{
+		{
+			name: "unit with deployment",
+			unit: HelmExecUnit{
+				Name:      "unit",
+				Namespace: "default",
+			},
+			deploymentYaml: `apiVersion: apps/v1
+kind: Deployment
+metadata:
+  creationTimestamp: null
+  labels:
+    execUnit: testUnit
+  name: nginx-deployment
+spec:
+  replicas: 3
+  selector:
+    matchLabels:
+      app: nginx
+      execUnit: testUnit
+  strategy: {}
+  template:
+    metadata:
+      creationTimestamp: null
+      labels:
+        app: nginx
+        execUnit: testUnit
+    spec:
+      containers:
+      - image: '{{ .Values.testUnitImage }}'
+        name: nginx
+        resources: {}
+      serviceAccountName: testUnit
+status: {}
+`,
+			want: testResult{
+				file: `apiVersion: apps/v1
+kind: Deployment
+metadata:
+  creationTimestamp: null
+  labels:
+    execUnit: testUnit
+  name: nginx-deployment
+spec:
+  replicas: 3
+  selector:
+    matchLabels:
+      app: nginx
+      execUnit: testUnit
+  strategy: {}
+  template:
+    metadata:
+      creationTimestamp: null
+      labels:
+        app: nginx
+        execUnit: testUnit
+    spec:
+      containers:
+      - env:
+        - name: TESTBUCKET_BUCKET_NAME
+          value: '{{ .Values.TESTBUCKETBUCKETNAME }}'
+        - name: TESTREDIS_PERSIST_REDIS_HOST
+          value: '{{ .Values.TESTREDISPERSISTREDISHOST }}'
+        - name: TESTSECRET_CONFIG_SECRET
+          value: '{{ .Values.TESTSECRETCONFIGSECRET }}'
+        - name: TESTORM_PERSIST_ORM_CONNECTION
+          value: '{{ .Values.TESTORMPERSISTORMCONNECTION }}'
+        image: '{{ .Values.testUnitImage }}'
+        name: nginx
+        resources: {}
+      serviceAccountName: testUnit
+status: {}
+`,
+				values: []Value{
+					{
+						ExecUnitName:        "unit",
+						Kind:                "Deployment",
+						Type:                string(EnvironmentVariableTransformation),
+						Key:                 "TESTREDISPERSISTREDISHOST",
+						EnvironmentVariable: core.GenerateRedisHostEnvVar("testRedis", string(core.PersistRedisClusterKind)),
+					},
+					{
+						ExecUnitName:        "unit",
+						Kind:                "Deployment",
+						Type:                string(EnvironmentVariableTransformation),
+						Key:                 "TESTBUCKETBUCKETNAME",
+						EnvironmentVariable: core.GenerateBucketEnvVar("testBucket"),
+					},
+					{
+						ExecUnitName:        "unit",
+						Kind:                "Deployment",
+						Type:                string(EnvironmentVariableTransformation),
+						Key:                 "TESTORMPERSISTORMCONNECTION",
+						EnvironmentVariable: core.GenerateOrmConnStringEnvVar("testOrm"),
+					},
+					{
+						ExecUnitName:        "unit",
+						Kind:                "Deployment",
+						Type:                string(EnvironmentVariableTransformation),
+						Key:                 "TESTSECRETCONFIGSECRET",
+						EnvironmentVariable: core.GenerateSecretEnvVar("testSecret", core.ConfigKind),
+					},
+				},
+			},
+		},
+		{
+			name: "unit with pod",
+			unit: HelmExecUnit{
+				Name:      "unit",
+				Namespace: "default",
+			},
+			podYaml: `apiVersion: v1
+kind: Pod
+metadata:
+  name: test
+spec:
+  containers:
+  - name: web
+    image: nginx`,
+			want: testResult{
+				file: `apiVersion: v1
+kind: Pod
+metadata:
+  creationTimestamp: null
+  name: test
+spec:
+  containers:
+  - env:
+    - name: TESTBUCKET_BUCKET_NAME
+      value: '{{ .Values.TESTBUCKETBUCKETNAME }}'
+    - name: TESTREDIS_PERSIST_REDIS_HOST
+      value: '{{ .Values.TESTREDISPERSISTREDISHOST }}'
+    - name: TESTSECRET_CONFIG_SECRET
+      value: '{{ .Values.TESTSECRETCONFIGSECRET }}'
+    - name: TESTORM_PERSIST_ORM_CONNECTION
+      value: '{{ .Values.TESTORMPERSISTORMCONNECTION }}'
+    image: nginx
+    name: web
+    resources: {}
+status: {}
+`,
+				values: []Value{
+					{
+						ExecUnitName:        "unit",
+						Kind:                "Pod",
+						Type:                string(EnvironmentVariableTransformation),
+						Key:                 "TESTREDISPERSISTREDISHOST",
+						EnvironmentVariable: core.GenerateRedisHostEnvVar("testRedis", string(core.PersistRedisClusterKind)),
+					},
+					{
+						ExecUnitName:        "unit",
+						Kind:                "Pod",
+						Type:                string(EnvironmentVariableTransformation),
+						Key:                 "TESTBUCKETBUCKETNAME",
+						EnvironmentVariable: core.GenerateBucketEnvVar("testBucket"),
+					},
+					{
+						ExecUnitName:        "unit",
+						Kind:                "Pod",
+						Type:                string(EnvironmentVariableTransformation),
+						Key:                 "TESTORMPERSISTORMCONNECTION",
+						EnvironmentVariable: core.GenerateOrmConnStringEnvVar("testOrm"),
+					},
+					{
+						ExecUnitName:        "unit",
+						Kind:                "Pod",
+						Type:                string(EnvironmentVariableTransformation),
+						Key:                 "TESTSECRETCONFIGSECRET",
+						EnvironmentVariable: core.GenerateSecretEnvVar("testSecret", core.ConfigKind),
+					},
+				},
+			},
+		},
+		{
+			name: "has dependency but no pod or deployment file",
+			unit: HelmExecUnit{
+				Name:      "unit",
+				Namespace: "default",
+			},
+			want: testResult{
+				values: []Value{},
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			assert := assert.New(t)
+
+			eunit := core.ExecutionUnit{}
+			eunit.EnvironmentVariables.Add(core.GenerateBucketEnvVar("testBucket"))
+			eunit.EnvironmentVariables.Add(core.GenerateRedisHostEnvVar("testRedis", string(core.PersistRedisClusterKind)))
+			eunit.EnvironmentVariables.Add(core.GenerateSecretEnvVar("testSecret", core.ConfigKind))
+			eunit.EnvironmentVariables.Add(core.GenerateOrmConnStringEnvVar("testOrm"))
+
+			if tt.deploymentYaml != "" {
+				f, err := yaml.NewFile("deployment.yaml", strings.NewReader(tt.deploymentYaml))
+				assert.NoError(err)
+				tt.unit.Deployment = f
+			}
+			if tt.podYaml != "" {
+				f, err := yaml.NewFile("pod.yaml", strings.NewReader(tt.podYaml))
+				assert.NoError(err)
+				tt.unit.Pod = f
+			}
+
+			values, err := tt.unit.AddUnitsEnvironmentVariables(&eunit)
+			if tt.wantErr {
+				assert.Error(err)
+				return
+			} else if !assert.NoError(err) {
+				return
+
+			}
+			assert.ElementsMatch(tt.want.values, values)
+
+			if tt.deploymentYaml != "" {
+				assert.Equal(tt.want.file, string(tt.unit.Deployment.Program()))
+			}
+			if tt.podYaml != "" {
+				assert.Equal(tt.want.file, string(tt.unit.Pod.Program()))
+			}
+		})
+	}
+}
+
 func Test_transformServiceAccount(t *testing.T) {
 	type result struct {
 		values  []Value
diff --git a/pkg/infra/kubernetes/persist_test.go b/pkg/infra/kubernetes/persist_test.go
deleted file mode 100644
index 45e8eaf5..00000000
--- a/pkg/infra/kubernetes/persist_test.go
+++ /dev/null
@@ -1,335 +0,0 @@
-package kubernetes
-
-import (
-	"strings"
-	"testing"
-
-	"github.com/klothoplatform/klotho/pkg/core"
-	"github.com/klothoplatform/klotho/pkg/lang/yaml"
-	"github.com/stretchr/testify/assert"
-)
-
-func Test_handlePersistForExecUnit(t *testing.T) {
-	type testResult struct {
-		values []Value
-		file   string
-	}
-	tests := []struct {
-		name           string
-		unit           HelmExecUnit
-		deploymentYaml string
-		podYaml        string
-		deps           []core.Dependency
-		want           testResult
-		wantErr        bool
-	}{
-		{
-			name: "orm dependency and deployment",
-			unit: HelmExecUnit{
-				Name:      "unit",
-				Namespace: "default",
-			},
-			deploymentYaml: `apiVersion: apps/v1
-kind: Deployment
-metadata:
-  creationTimestamp: null
-  labels:
-    execUnit: testUnit
-  name: nginx-deployment
-spec:
-  replicas: 3
-  selector:
-    matchLabels:
-      app: nginx
-      execUnit: testUnit
-  strategy: {}
-  template:
-    metadata:
-      creationTimestamp: null
-      labels:
-        app: nginx
-        execUnit: testUnit
-    spec:
-      containers:
-      - image: '{{ .Values.testUnitImage }}'
-        name: nginx
-        resources: {}
-      serviceAccountName: testUnit
-status: {}
-`,
-			deps: []core.Dependency{
-				{
-					Source: core.ResourceKey{Kind: core.ExecutionUnitKind, Name: "unit"},
-					Target: core.ResourceKey{Kind: string(core.PersistORMKind), Name: "unit"},
-				},
-			},
-			want: testResult{
-				file: `apiVersion: apps/v1
-kind: Deployment
-metadata:
-  creationTimestamp: null
-  labels:
-    execUnit: testUnit
-  name: nginx-deployment
-spec:
-  replicas: 3
-  selector:
-    matchLabels:
-      app: nginx
-      execUnit: testUnit
-  strategy: {}
-  template:
-    metadata:
-      creationTimestamp: null
-      labels:
-        app: nginx
-        execUnit: testUnit
-    spec:
-      containers:
-      - env:
-        - name: UNIT_PERSIST_ORM_CONNECTION
-          value: '{{ .Values.UNITPERSISTORMCONNECTION }}'
-        image: '{{ .Values.testUnitImage }}'
-        name: nginx
-        resources: {}
-      serviceAccountName: testUnit
-status: {}
-`,
-				values: []Value{
-					{
-						ExecUnitName:        "unit",
-						Kind:                "Deployment",
-						Type:                string(EnvironmentVariableTransformation),
-						Key:                 "UNITPERSISTORMCONNECTION",
-						EnvironmentVariable: core.NewEnvironmentVariable("UNIT_PERSIST_ORM_CONNECTION", "persist_orm", "unit", "connection_string"),
-					},
-				},
-			},
-		},
-		{
-			name: "redis node dependency and pod",
-			unit: HelmExecUnit{
-				Name:      "unit",
-				Namespace: "default",
-			},
-			podYaml: `apiVersion: v1
-kind: Pod
-metadata:
-  name: test
-spec:
-  containers:
-  - name: web
-    image: nginx`,
-			deps: []core.Dependency{
-				{
-					Source: core.ResourceKey{Kind: core.ExecutionUnitKind, Name: "unit"},
-					Target: core.ResourceKey{Kind: string(core.PersistRedisNodeKind), Name: "unit"},
-				},
-			},
-			want: testResult{
-				file: `apiVersion: v1
-kind: Pod
-metadata:
-  creationTimestamp: null
-  name: test
-spec:
-  containers:
-  - env:
-    - name: UNIT_PERSIST_REDIS_HOST
-      value: '{{ .Values.UNITPERSISTREDISHOST }}'
-    - name: UNIT_PERSIST_REDIS_PORT
-      value: '{{ .Values.UNITPERSISTREDISPORT }}'
-    image: nginx
-    name: web
-    resources: {}
-status: {}
-`,
-				values: []Value{
-					{
-						ExecUnitName:        "unit",
-						Kind:                "Pod",
-						Type:                string(EnvironmentVariableTransformation),
-						Key:                 "UNITPERSISTREDISHOST",
-						EnvironmentVariable: core.NewEnvironmentVariable("UNIT_PERSIST_REDIS_HOST", "persist_redis_node", "unit", "host"),
-					},
-					{
-						ExecUnitName:        "unit",
-						Kind:                "Pod",
-						Type:                string(EnvironmentVariableTransformation),
-						Key:                 "UNITPERSISTREDISPORT",
-						EnvironmentVariable: core.NewEnvironmentVariable("UNIT_PERSIST_REDIS_PORT", "persist_redis_node", "unit", "port"),
-					},
-				},
-			},
-		},
-		{
-			name: "redis cluster dependency and pod",
-			unit: HelmExecUnit{
-				Name:      "unit",
-				Namespace: "default",
-			},
-			podYaml: `apiVersion: v1
-kind: Pod
-metadata:
-  name: test
-spec:
-  containers:
-  - name: web
-    image: nginx`,
-			deps: []core.Dependency{
-				{
-					Source: core.ResourceKey{Kind: core.ExecutionUnitKind, Name: "unit"},
-					Target: core.ResourceKey{Kind: string(core.PersistRedisClusterKind), Name: "unit"},
-				},
-			},
-			want: testResult{
-				file: `apiVersion: v1
-kind: Pod
-metadata:
-  creationTimestamp: null
-  name: test
-spec:
-  containers:
-  - env:
-    - name: UNIT_PERSIST_REDIS_HOST
-      value: '{{ .Values.UNITPERSISTREDISHOST }}'
-    - name: UNIT_PERSIST_REDIS_PORT
-      value: '{{ .Values.UNITPERSISTREDISPORT }}'
-    image: nginx
-    name: web
-    resources: {}
-status: {}
-`,
-				values: []Value{
-					{
-						ExecUnitName:        "unit",
-						Kind:                "Pod",
-						Type:                string(EnvironmentVariableTransformation),
-						Key:                 "UNITPERSISTREDISHOST",
-						EnvironmentVariable: core.NewEnvironmentVariable("UNIT_PERSIST_REDIS_HOST", "persist_redis_cluster", "unit", "host"),
-					},
-					{
-						ExecUnitName:        "unit",
-						Kind:                "Pod",
-						Type:                string(EnvironmentVariableTransformation),
-						Key:                 "UNITPERSISTREDISPORT",
-						EnvironmentVariable: core.NewEnvironmentVariable("UNIT_PERSIST_REDIS_PORT", "persist_redis_cluster", "unit", "port"),
-					},
-				},
-			},
-		},
-		{
-			name: "has dependency but no pod or deployment file",
-			unit: HelmExecUnit{
-				Name:      "unit",
-				Namespace: "default",
-			},
-			deps: []core.Dependency{
-				{
-					Source: core.ResourceKey{Kind: core.ExecutionUnitKind, Name: "unit"},
-					Target: core.ResourceKey{Kind: string(core.PersistRedisClusterKind), Name: "unit"},
-				},
-			},
-		},
-		{
-			name: "no deps",
-			unit: HelmExecUnit{
-				Name:      "unit",
-				Namespace: "default",
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			assert := assert.New(t)
-
-			deps := &core.Dependencies{}
-			for _, dep := range tt.deps {
-				deps.Add(dep.Source, dep.Target)
-			}
-
-			if tt.deploymentYaml != "" {
-				f, err := yaml.NewFile("deployment.yaml", strings.NewReader(tt.deploymentYaml))
-				assert.NoError(err)
-				tt.unit.Deployment = f
-			}
-			if tt.podYaml != "" {
-				f, err := yaml.NewFile("pod.yaml", strings.NewReader(tt.podYaml))
-				assert.NoError(err)
-				tt.unit.Pod = f
-			}
-
-			values, err := tt.unit.handlePersistForExecUnit(deps)
-			if tt.wantErr {
-				assert.Error(err)
-				return
-			} else if !assert.NoError(err) {
-				return
-
-			}
-			assert.Equal(tt.want.values, values)
-
-			if tt.deploymentYaml != "" {
-				assert.Equal(tt.want.file, string(tt.unit.Deployment.Program()))
-			}
-			if tt.podYaml != "" {
-				assert.Equal(tt.want.file, string(tt.unit.Pod.Program()))
-			}
-		})
-	}
-}
-
-func Test_generateEnvVarsForPersist(t *testing.T) {
-	tests := []struct {
-		name     string
-		unit     *core.ExecutionUnit
-		resource core.CloudResource
-		values   core.EnvironmentVariables
-	}{
-		{
-			name:     "Wrong dependencies",
-			unit:     &core.ExecutionUnit{Name: "main"},
-			resource: &core.Persist{Name: "file", Kind: core.PersistFileKind},
-			values:   core.EnvironmentVariables{},
-		},
-		{
-			name:     "orm dependency",
-			unit:     &core.ExecutionUnit{Name: "main"},
-			resource: &core.Persist{Name: "orm", Kind: core.PersistORMKind},
-			values:   core.EnvironmentVariables{{Name: "ORM_PERSIST_ORM_CONNECTION", Kind: "persist_orm", ResourceID: "orm", Value: string(core.CONNECTION_STRING)}},
-		},
-		{
-			name:     "redis node dependency",
-			unit:     &core.ExecutionUnit{Name: "main"},
-			resource: &core.Persist{Name: "redisNode", Kind: core.PersistRedisNodeKind},
-			values: core.EnvironmentVariables{
-				{Name: "REDISNODE_PERSIST_REDIS_HOST", Kind: "persist_redis_node", ResourceID: "redisNode", Value: string(core.HOST)},
-				{Name: "REDISNODE_PERSIST_REDIS_PORT", Kind: "persist_redis_node", ResourceID: "redisNode", Value: string(core.PORT)},
-			},
-		},
-		{
-			name:     "redis cluster dependency",
-			unit:     &core.ExecutionUnit{Name: "main"},
-			resource: &core.Persist{Name: "redisCluster", Kind: core.PersistRedisClusterKind},
-			values: core.EnvironmentVariables{
-				{Name: "REDISCLUSTER_PERSIST_REDIS_HOST", Kind: "persist_redis_cluster", ResourceID: "redisCluster", Value: string(core.HOST)},
-				{Name: "REDISCLUSTER_PERSIST_REDIS_PORT", Kind: "persist_redis_cluster", ResourceID: "redisCluster", Value: string(core.PORT)},
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-
-			assert := assert.New(t)
-
-			results := &core.CompilationResult{}
-			results.Add(tt.resource)
-
-			deps := &core.Dependencies{}
-			deps.Add(tt.unit.Key(), tt.resource.Key())
-			envVars := generateEnvVars(deps, tt.unit.Name)
-
-			assert.Equal(tt.values, envVars)
-		})
-	}
-}
diff --git a/pkg/lang/golang/plugin_expose_test.go b/pkg/lang/golang/plugin_expose_test.go
index 8661dde2..1bda7500 100644
--- a/pkg/lang/golang/plugin_expose_test.go
+++ b/pkg/lang/golang/plugin_expose_test.go
@@ -115,6 +115,91 @@ func Test_findChiRouterDefinition(t *testing.T) {
 	}
 }
 
+func Test_removeNetHttpImport(t *testing.T) {
+	tests := []struct {
+		name   string
+		source string
+		want   string
+	}{
+		{
+			name: "simple identifier",
+			source: `package test
+import (
+	"fmt"
+	"net/http"
+)
+
+http.ListenAndServe(":3000", r)
+			`,
+			want: `package test
+import (
+	"fmt"
+	"net/http"
+)
+
+http.ListenAndServe(":3000", r)
+			`,
+		},
+		{
+			name: "simple package identifier",
+			source: `package test
+import (
+	"fmt"
+	"net/http"
+)
+
+r.Get("/", func(w http.ResponseWriter, r *http.Request) {
+	w.Write([]byte("Hello!"))
+})
+			`,
+			want: `package test
+import (
+	"fmt"
+	"net/http"
+)
+
+r.Get("/", func(w http.ResponseWriter, r *http.Request) {
+	w.Write([]byte("Hello!"))
+})
+			`,
+		},
+		{
+			name: "should remove import",
+			source: `package test
+import (
+	"fmt"
+	"net/http"
+)
+
+random.ListenAndServe(":3000", r)
+			`,
+			want: `package test
+
+import (
+	"fmt"
+)
+
+
+random.ListenAndServe(":3000", r)
+			`,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			assert := assert.New(t)
+
+			f, err := core.NewSourceFile("", strings.NewReader(tt.source), Language)
+			if !assert.NoError(err) {
+				return
+			}
+			err = testRestAPIHandler.removeNetHttpImport(f)
+
+			assert.NoError(err)
+			assert.Equal(tt.want, string(f.Program()))
+		})
+	}
+}
+
 func Test_findImports(t *testing.T) {
 	tests := []struct {
 		name   string