Skip to content

Commit fe0cf65

Browse files
committed
restructure schema dependencies
1 parent be81d61 commit fe0cf65

File tree

10 files changed

+238
-207
lines changed

10 files changed

+238
-207
lines changed

.github/workflows/_helm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
uses: actions/upload-artifact@v4
5757
with:
5858
name: helm-chart-schemas
59-
path: schemas/*.schema.json
59+
path: Charts/*/*.schema.json
6060

6161
- name: Push tagged helm chart to registry
6262
# TODO - switch to using https://github.com/helm/chart-releaser-action of maybe the docker action?

.pre-commit-config.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,13 @@ repos:
2929
hooks:
3030
- id: helm-schema
3131
args:
32-
- --values
33-
- Charts/fastcs/values.yaml
34-
- --no-additional-properties
35-
- -o
36-
- schemas/fastcs-values.schema.json
32+
- --config
33+
- Charts/fastcs/.schema.config.yaml
3734

3835
- repo: https://github.com/losisin/helm-values-schema-json
3936
rev: v2.2.1
4037
hooks:
4138
- id: helm-schema
4239
args:
43-
- --values
44-
- schemas/fastcs-service-values.yaml
45-
- --no-additional-properties
46-
- -o
47-
- schemas/fastcs-service.schema.json
40+
- --config
41+
- Charts/fastcs/.schema.service.config.yaml

Charts/fastcs/.schema.config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# .schema.yaml
2+
3+
# Define input, output and source for $refs relative to repository root for pre-commit
4+
values:
5+
- Charts/fastcs/values.yaml
6+
7+
output: Charts/fastcs/values.schema.json
8+
9+
# bundle up references (don't do this as K8S refs are 500kb+)
10+
bundleRoot: Charts
11+
bundle: false
12+
13+
# Include comments for the helm-docs plugin into the schema, to allow e.g. documentation in VSCode
14+
useHelmDocs: false
15+
16+
# Allow additional properties for eg. initResources, different types of volumes/volumeMounts
17+
noAdditionalProperties: false
18+
19+
schemaRoot:
20+
title: FastCS Helm chart schema
21+
description: Schema to allow validation of values passed to FastCS Helm chart
22+
# No additional properties in schema root for tighter protection:
23+
additionalProperties: false
24+
25+
k8sSchemaVersion: v1.33.3
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# .schema.yaml
2+
3+
# Define input, output and source for $refs relative to repository root for pre-commit
4+
values:
5+
- Charts/fastcs/service.values.yaml
6+
7+
output: Charts/fastcs/service.values.schema.json
8+
9+
10+
# bundle up references (don't do this as K8S refs are 500kb+)
11+
bundleRoot: Charts
12+
bundle: false
13+
14+
# Include comments for the helm-docs plugin into the schema, to allow e.g. documentation in VSCode
15+
useHelmDocs: false
16+
17+
# Allow additional properties for eg. initResources, different types of volumes/volumeMounts
18+
noAdditionalProperties: false
19+
20+
schemaRoot:
21+
title: FastCS Helm chart schema for services using FastCS as a subchart
22+
description: Schema to allow validation FastCS IOC instances
23+
# No additional properties in schema root for tighter protection:
24+
additionalProperties: false
25+
26+
k8sSchemaVersion: v1.33.3
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "FastCS Helm chart schema for services using FastCS as a subchart",
4+
"description": "Schema to allow validation FastCS IOC instances",
5+
"type": "object",
6+
"properties": {
7+
"fastcs": {
8+
"$ref": "/workspaces/fastcs/Charts/fastcs/values.schema.json",
9+
"type": "object"
10+
}
11+
},
12+
"additionalProperties": false
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# yaml-language-server: $schema=fastcs-service.schema.json
1+
# yaml-language-server: $schema=service.values.schema.json
22

33
# This yaml file represents the values used in services projects where
44
# fastcs is a subchart.
@@ -7,5 +7,5 @@
77
# which is used to validate the values.yaml files in services projects.
88

99
# fast cs schema appears under the subchart fastcs
10-
# @schema $ref: fastcs-values.schema.json
10+
# @schema $ref: /workspaces/fastcs/Charts/fastcs/values.schema.json
1111
fastcs: {}

Charts/fastcs/values.schema.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

Charts/fastcs/values.schema.json

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "FastCS Helm chart schema",
4+
"description": "Schema to allow validation of values passed to FastCS Helm chart",
5+
"type": "object",
6+
"properties": {
7+
"affinity": {
8+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/affinity.json",
9+
"type": "object"
10+
},
11+
"args": {
12+
"description": "command args to pass to the production container",
13+
"type": "array"
14+
},
15+
"autostart": {
16+
"description": "editable and autostart are used for debugging and development in-cluster",
17+
"type": "boolean"
18+
},
19+
"baseIp": {
20+
"description": "CIDR for services addresses.",
21+
"type": "string",
22+
"pattern": "^(\\d{1,3}\\.){3}\\d{1,3}\\/\\d{1,2}$"
23+
},
24+
"ca_server_port": {
25+
"description": "service port for Channel Access",
26+
"type": "integer"
27+
},
28+
"clusterIP": {
29+
"description": "Override for the cluster IP - only needed if allocateIpFromName clashes",
30+
"type": "null",
31+
"pattern": "^(\\d{1,3}\\.){3}\\d{1,3}$"
32+
},
33+
"command": {
34+
"description": "command to run for the production container",
35+
"type": "array"
36+
},
37+
"debugCommand": {
38+
"description": "command to run for the debugging (non- autostart) container",
39+
"type": "array",
40+
"items": {
41+
"type": "string"
42+
}
43+
},
44+
"editable": {
45+
"description": "editable and autostart are used for debugging and development in-cluster",
46+
"type": "boolean"
47+
},
48+
"extraContainers": {
49+
"type": "array"
50+
},
51+
"global": {
52+
"description": "shared values for all services",
53+
"type": "object",
54+
"additionalProperties": true
55+
},
56+
"hostNetwork": {
57+
"description": "enable host networking for the pod",
58+
"type": "boolean"
59+
},
60+
"image": {
61+
"description": "container image URI",
62+
"type": "object",
63+
"properties": {
64+
"pullPolicy": {
65+
"type": "string"
66+
},
67+
"repository": {
68+
"type": "string"
69+
},
70+
"tag": {
71+
"type": "string"
72+
}
73+
}
74+
},
75+
"initCommand": {
76+
"description": "command to run in the init container for editable mode",
77+
"type": "array",
78+
"items": {
79+
"type": "string"
80+
}
81+
},
82+
"iocConfig": {
83+
"description": "path to the location of config folder (defaults to be the same as C++ IOCs)",
84+
"type": "string"
85+
},
86+
"livenessProbe": {
87+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/container.json#/properties/livenessProbe",
88+
"type": "object"
89+
},
90+
"nodeSelector": {
91+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/podspec.json#/properties/nodeSelector",
92+
"type": "object"
93+
},
94+
"podAnnotations": {
95+
"description": "Add annotations to the pod",
96+
"type": "object"
97+
},
98+
"podLabels": {
99+
"description": "Add labels to the pod",
100+
"type": "object"
101+
},
102+
"podSecurityContext": {
103+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/podspec.json#/properties/securityContext",
104+
"type": "object"
105+
},
106+
"pva_server_port": {
107+
"description": "service port for PV Access",
108+
"type": "integer"
109+
},
110+
"readinessProbe": {
111+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/container.json#/properties/readinessProbe",
112+
"type": "object"
113+
},
114+
"resources": {
115+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/container.json#/properties/resources",
116+
"type": "object"
117+
},
118+
"securityContext": {
119+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/container.json#/properties/securityContext",
120+
"type": "object"
121+
},
122+
"service": {
123+
"description": "The service will be configured for Channel Access and PVA.",
124+
"type": "object",
125+
"properties": {
126+
"ca_port": {
127+
"type": "integer"
128+
},
129+
"pva_port": {
130+
"type": "integer"
131+
},
132+
"type": {
133+
"type": "string"
134+
}
135+
}
136+
},
137+
"tolerations": {
138+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/podspec.json#/properties/tolerations",
139+
"type": "array"
140+
},
141+
"volumeMounts": {
142+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/container.json#/properties/volumeMounts",
143+
"type": "array"
144+
},
145+
"volumes": {
146+
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.33.3/podspec.json#/properties/volumes",
147+
"type": "array"
148+
}
149+
},
150+
"additionalProperties": false
151+
}

Charts/fastcs/values.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# yaml-language-server: $schema=values.schema.json
22

3+
# NOTE: the $k8s schema references come from
4+
# https://github.com/yannh/kubernetes-json-schema/tree/master/v1.33.1
5+
# with the version set in .fastcs.schema.config.yaml (k8sSchemaVersion)
6+
37
# Default values for fastcs-instance chart.
48
# With annotations for building the schema using:
59
# https://github.com/losisin/helm-values-schema-json.git
@@ -110,35 +114,32 @@ podAnnotations: {}
110114
# @schema description: Add labels to the pod
111115
podLabels: {}
112116

113-
# @schema $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.SecurityContext
117+
# @schema $ref: $k8s/podspec.json#/properties/securityContext
114118
podSecurityContext: {}
115119

116-
# @schema $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.SecurityContext
120+
# @schema $ref:$k8s/container.json#/properties/securityContext
117121
securityContext: {}
118122

119-
# @schema $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.ResourceRequirements
123+
# @schema $ref: $k8s/container.json#/properties/resources
120124
resources: {}
121125

122-
# @schema $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.Probe
126+
# @schema $ref: $k8s/container.json#/properties/livenessProbe
123127
livenessProbe: {}
124128

125-
# @schema $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.Probe
129+
# @schema $ref: $k8s/container.json#/properties/readinessProbe
126130
readinessProbe: {}
127131

128-
# @schema item: object
129-
# @schema $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.Volume
132+
# @schema $ref: $k8s/podspec.json#/properties/volumes
130133
volumes: []
131134

132-
# @schema $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.VolumeMount
135+
# @schema $ref: $k8s/container.json#/properties/volumeMounts
133136
volumeMounts: []
134137

135-
# TODO I cant find a way to allow null for nodeSelector but also pass the ref for the object
136-
# $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.NodeSelector
137-
# @schema type:[object, null]
138-
nodeSelector: {}
139-
140-
# @schema $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.Toleration
138+
# @schema $ref: $k8s/podspec.json#/properties/tolerations
141139
tolerations: []
142140

143-
# @schema $ref: https://kubernetesjsonschema.dev/v1.18.1/_definitions.json#/definitions/io.k8s.api.core.v1.Affinity
141+
# @schema $ref: $k8s/podspec.json#/properties/nodeSelector
142+
nodeSelector: {}
143+
144+
# @schema $ref: $k8s/affinity.json
144145
affinity: {}

schemas/fastcs-service.schema.json

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

0 commit comments

Comments
 (0)