Skip to content

Commit

Permalink
Buildless resource tests (#1358)
Browse files Browse the repository at this point in the history
  • Loading branch information
anoipm authored Jan 7, 2025
1 parent c1857b1 commit 2547c08
Show file tree
Hide file tree
Showing 4 changed files with 896 additions and 28 deletions.
13 changes: 5 additions & 8 deletions components/buildless-serverless/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module github.com/kyma-project/serverless
go 1.22.0

require (
github.com/google/go-cmp v0.6.0
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
github.com/vrischmann/envconfig v1.3.0
go.uber.org/zap v1.26.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.31.0
k8s.io/apimachinery v0.31.0
k8s.io/client-go v0.31.0
Expand All @@ -34,14 +34,13 @@ require (
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
Expand All @@ -52,7 +51,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
Expand All @@ -78,14 +77,12 @@ require (
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.31.0 // indirect
k8s.io/apiserver v0.31.0 // indirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,16 @@ func (d *Deployment) podSpec() corev1.PodSpec {
ContainerPort: 80,
},
},
//TODO: uncomment later - now we need greater privileges for running npm command
// SecurityContext: d.restrictiveContainerSecurityContext(),
//TODO: add SecurityContext
},
},
}
}

func (d *Deployment) replicas() *int32 {
replicas := &d.function.Spec.Replicas
replicas := d.function.Spec.Replicas
if replicas != nil {
return *replicas
return replicas
}
defaultValue := DefaultDeploymentReplicas
return &defaultValue
Expand Down Expand Up @@ -290,19 +289,3 @@ func (d *Deployment) deploymentSecretVolumes() (volumes []corev1.Volume, volumeM
}
return volumes, volumeMounts
}

// security context is set to fulfill the baseline security profile
// based on https://raw.githubusercontent.com/kyma-project/community/main/concepts/psp-replacement/baseline-pod-spec.yaml
func (d *Deployment) restrictiveContainerSecurityContext() *corev1.SecurityContext {
defaultProcMount := corev1.DefaultProcMount
return &corev1.SecurityContext{
Privileged: ptr.To[bool](false),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{
"ALL",
},
},
ProcMount: &defaultProcMount,
ReadOnlyRootFilesystem: ptr.To[bool](true),
}
}
Loading

0 comments on commit 2547c08

Please sign in to comment.