diff --git a/commands/generate.go b/commands/generate.go index be985330..a29435f8 100644 --- a/commands/generate.go +++ b/commands/generate.go @@ -203,15 +203,16 @@ func generateCRDYAML(services stack.Services, format schema.BuildFormat, apiVers imageName := schema.BuildImageName(format, function.Image, version, branch) spec := openfaasv1.Spec{ - Name: name, - Image: imageName, - Environment: allEnvironment, - Labels: function.Labels, - Annotations: function.Annotations, - Limits: function.Limits, - Requests: function.Requests, - Constraints: function.Constraints, - Secrets: function.Secrets, + Name: name, + Image: imageName, + Environment: allEnvironment, + Labels: function.Labels, + Annotations: function.Annotations, + Limits: function.Limits, + Requests: function.Requests, + Constraints: function.Constraints, + Secrets: function.Secrets, + ReadOnlyRootFilesystem: function.ReadOnlyRootFilesystem, } crd := openfaasv1.CRD{ diff --git a/commands/generate_test.go b/commands/generate_test.go index 1edc619a..8bb9e67d 100644 --- a/commands/generate_test.go +++ b/commands/generate_test.go @@ -202,6 +202,35 @@ spec: Branch: "", Version: "", }, + { + Name: "Read-only root filesystem", + Input: ` +provider: + name: openfaas + gateway: http://127.0.0.1:8080 +functions: + url-ping: + lang: python + handler: ./sample/url-ping + image: alexellis/faas-url-ping:0.2 + readonly_root_filesystem: true`, + Output: []string{`--- +apiVersion: openfaas.com/v1 +kind: Function +metadata: + name: url-ping + namespace: openfaas-fn +spec: + name: url-ping + image: alexellis/faas-url-ping:0.2 + readOnlyRootFilesystem: true +`}, + Format: schema.DefaultFormat, + APIVersion: "openfaas.com/v1", + Namespace: "openfaas-fn", + Branch: "", + Version: "", + }, } func Test_generateCRDYAML(t *testing.T) { diff --git a/schema/openfaas/v1/crd.go b/schema/openfaas/v1/crd.go index 5f0cc11b..5f45bd0a 100644 --- a/schema/openfaas/v1/crd.go +++ b/schema/openfaas/v1/crd.go @@ -34,6 +34,8 @@ type Spec struct { //Secrets list of secrets to be made available to function Secrets []string `yaml:"secrets,omitempty"` + + ReadOnlyRootFilesystem bool `yaml:"readOnlyRootFilesystem,omitempty"` } //CRD root level YAML definition for the object