Skip to content

Commit 43f64cf

Browse files
committed
Handle null env vars
There was an error related to the following issue in openfaas-cloud, which will also occur in faas-cli, where null env-vars were serialized and passed into the spec. This change has been tested and fixes the problem. openfaas/openfaas-cloud#707 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent f799387 commit 43f64cf

30 files changed

+521
-666
lines changed

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ require (
66
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
77
github.com/google/go-cmp v0.3.0
88
github.com/googleapis/gnostic v0.2.0 // indirect
9-
github.com/gorilla/context v1.1.1 // indirect
10-
github.com/gorilla/mux v1.6.2
9+
github.com/gorilla/mux v1.8.0
1110
github.com/imdario/mergo v0.3.7 // indirect
1211
github.com/onsi/gomega v1.8.1 // indirect
1312
github.com/openfaas/faas v0.0.0-20191125105239-365f459b3f3a
14-
github.com/openfaas/faas-provider v0.15.1
13+
github.com/openfaas/faas-provider v0.15.4
1514
github.com/pkg/errors v0.8.1
1615
github.com/prometheus/client_golang v1.0.0
1716
github.com/prometheus/client_model v0.2.0 // indirect
18-
go.uber.org/goleak v1.0.0 // indirect
1917
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect
2018
google.golang.org/appengine v1.6.2 // indirect
2119
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect

go.sum

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,8 @@ github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhp
8484
github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
8585
github.com/gophercloud/gophercloud v0.1.0 h1:P/nh25+rzXouhytV2pUHBb65fnds26Ghl8/391+sT5o=
8686
github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8=
87-
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
88-
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
89-
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
90-
github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk=
91-
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
87+
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
88+
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
9289
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
9390
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
9491
github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
@@ -138,8 +135,8 @@ github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34=
138135
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
139136
github.com/openfaas/faas v0.0.0-20191125105239-365f459b3f3a h1:pJFILEGlYV+FvEKquNw2gkvVC2WUfXm2ffSKDFG5168=
140137
github.com/openfaas/faas v0.0.0-20191125105239-365f459b3f3a/go.mod h1:E0m2rLup0Vvxg53BKxGgaYAGcZa3Xl+vvL7vSi5yQ14=
141-
github.com/openfaas/faas-provider v0.15.1 h1:5M+DrGbuKlZxhN3/otFgLgBUnPQcYm6XosQDSbKXh30=
142-
github.com/openfaas/faas-provider v0.15.1/go.mod h1:ChVioeB3snmfYxBTu7SrWGYLoYN9fZkQlnuEQ86a6l0=
138+
github.com/openfaas/faas-provider v0.15.4 h1:0i6xIOWOJHoKEzYhpj7RqQZcgtOgkqlf0s7DRADKS3E=
139+
github.com/openfaas/faas-provider v0.15.4/go.mod h1:fq1JL0mX4rNvVVvRLaLRJ3H6o667sHuyP5p/7SZEe98=
143140
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
144141
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
145142
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
@@ -172,9 +169,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
172169
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
173170
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
174171
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
175-
go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI=
176-
go.uber.org/goleak v1.0.0 h1:qsup4IcBdlmsnGfqyLl4Ntn3C2XCCuKAE7DwHpScyUo=
177-
go.uber.org/goleak v1.0.0/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
172+
go.uber.org/goleak v1.1.0 h1:MJDxhkyAAWXEJf/y4NSOPYD/bBx7JAzIjUbv12/4FFs=
173+
go.uber.org/goleak v1.1.0/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
178174
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
179175
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
180176
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

pkg/server/apply.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,24 @@ func makeApplyHandler(defaultNamespace string, client clientset.Interface) http.
8787
}
8888

8989
func toFunctionSpec(req types.FunctionDeployment) faasv1.FunctionSpec {
90-
return faasv1.FunctionSpec{
91-
90+
spec := faasv1.FunctionSpec{
9291
Name: req.Service,
9392
Image: req.Image,
9493
Handler: req.EnvProcess,
9594
Labels: req.Labels,
9695
Annotations: req.Annotations,
97-
Environment: &req.EnvVars,
9896
Constraints: req.Constraints,
9997
Secrets: req.Secrets,
10098
Limits: getResources(req.Limits),
10199
Requests: getResources(req.Requests),
102100
ReadOnlyRootFilesystem: req.ReadOnlyRootFilesystem,
103101
}
102+
103+
if req.EnvVars != nil {
104+
spec.Environment = &req.EnvVars
105+
}
106+
107+
return spec
104108
}
105109

106110
func getResources(limits *types.FunctionResources) *faasv1.FunctionResources {

vendor/github.com/gorilla/context/.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

vendor/github.com/gorilla/context/LICENSE

Lines changed: 0 additions & 27 deletions
This file was deleted.

vendor/github.com/gorilla/context/README.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

vendor/github.com/gorilla/context/context.go

Lines changed: 0 additions & 143 deletions
This file was deleted.

vendor/github.com/gorilla/context/doc.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

vendor/github.com/gorilla/mux/.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)