Fix generate command for read-only root filesystem setting

The readonly_root_filesystem setting was not included in the resulting
CRD when running faas-cli generate.

Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
This commit is contained in:
Han Verstraete (OpenFaaS Ltd)
2022-09-20 16:09:07 +02:00
committed by Alex Ellis
parent b88dc1905f
commit 0451db85fa
3 changed files with 41 additions and 9 deletions

View File

@@ -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{

View File

@@ -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) {

View File

@@ -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