feat(app-service): add regex validation to env CRD (#2049)

This commit is contained in:
dkeven 2025-11-10 22:38:55 +08:00 committed by GitHub
parent ec6ce88e08
commit b24ba06794
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 69 additions and 6 deletions

View file

@ -5,7 +5,7 @@ go 1.24.2
toolchain go1.24.6
replace (
bytetrade.io/web3os/app-service => github.com/beclab/app-service v0.4.37
bytetrade.io/web3os/app-service => github.com/beclab/app-service v0.4.41
bytetrade.io/web3os/backups-sdk => github.com/Above-Os/backups-sdk v0.1.17
github.com/containers/image/v5 => github.com/containers/image/v5 v5.21.1
github.com/containers/storage => github.com/containers/storage v1.40.0

View file

@ -45,8 +45,8 @@ github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3d
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/beclab/api v0.0.2 h1:aD5RcMie2uqa/FZI7aQBa1F4yVEib8/x3IIZSLiHkBM=
github.com/beclab/api v0.0.2/go.mod h1:ESZLe8cf4934QFkU6cqbskKfiTyNk67i1qbv/ctS6js=
github.com/beclab/app-service v0.4.37 h1:gt60wQxgPWMc3oN94TNSdiQAvzqTyCv/OUP93jNSQTY=
github.com/beclab/app-service v0.4.37/go.mod h1:0vEg3rv/DbR7dYznvTlXNXyYNn+TXNMaxz03GQYRWUQ=
github.com/beclab/app-service v0.4.41 h1:WSIXEqHSAepHweBooPkc+pedVaGGn335RugNwixkciY=
github.com/beclab/app-service v0.4.41/go.mod h1:0vEg3rv/DbR7dYznvTlXNXyYNn+TXNMaxz03GQYRWUQ=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=

View file

@ -366,11 +366,11 @@ func (a *ApplySystemEnv) Execute(runtime connector.Runtime) error {
envItem.Default = procVal
}
err = apputils.CheckEnvValueByType(envItem.Value, envItem.Type)
err = envItem.ValidateValue(envItem.Value)
if err != nil {
return fmt.Errorf("invalid system env value: %s", envItem.Value)
}
err = apputils.CheckEnvValueByType(envItem.Default, envItem.Type)
err = envItem.ValidateValue(envItem.Default)
if err != nil {
return fmt.Errorf("invalid system env default value: %s", envItem.Value)
}

View file

@ -58,6 +58,27 @@ spec:
type: boolean
envName:
type: string
options:
description: Options defines a finite set of allowed values for
this env var
items:
properties:
title:
type: string
value:
type: string
required:
- title
- value
type: object
type: array
regex:
type: string
remoteOptions:
description: RemoteOptions provides a URL (http/https) returning
a JSON-encoded string array of allowed values
pattern: ^https?://
type: string
required:
type: boolean
title:

View file

@ -65,6 +65,27 @@ spec:
type: string
metadata:
type: object
options:
description: Options defines a finite set of allowed values for this env
var
items:
properties:
title:
type: string
value:
type: string
required:
- title
- value
type: object
type: array
regex:
type: string
remoteOptions:
description: RemoteOptions provides a URL (http/https) returning a JSON-encoded
string array of allowed values
pattern: ^https?://
type: string
required:
type: boolean
title:

View file

@ -64,6 +64,27 @@ spec:
type: string
metadata:
type: object
options:
description: Options defines a finite set of allowed values for this env
var
items:
properties:
title:
type: string
value:
type: string
required:
- title
- value
type: object
type: array
regex:
type: string
remoteOptions:
description: RemoteOptions provides a URL (http/https) returning a JSON-encoded
string array of allowed values
pattern: ^https?://
type: string
required:
type: boolean
title:

View file

@ -170,7 +170,7 @@ spec:
priorityClassName: "system-cluster-critical"
containers:
- name: app-service
image: beclab/app-service:0.4.40
image: beclab/app-service:0.4.41
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 0