Skip to content

Commit

Permalink
chore: Merge commit '95847dd8aa805318cb287c6d25dcddf965f50c26' into u…
Browse files Browse the repository at this point in the history
…pdate-spec

515c899 fix: make httpGet probe port required, fix volume read_only to be camelCase (#13)
2fb2c34 feat: added field restrictions and tests to the repository (#12)
1883aea fix: removed fully deprecated and unsupported resource properties field (#11)

git-subtree-dir: schemas
git-subtree-split: 515c89903bd1460a9b3e0ff7fb0b77d3cbd29cac

Signed-off-by: Ben Meier <ben.meier@humanitec.com>
  • Loading branch information
astromechza committed Feb 27, 2024
1 parent ad498b7 commit 7d8c571
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 13 deletions.
45 changes: 45 additions & 0 deletions schemas/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Disable all the default make stuff
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:

SCORE_EXAMPLES_DIR ?= ./samples/

## Display help menu
.PHONY: help
help:
@echo Documented Make targets:
@perl -e 'undef $$/; while (<>) { while ($$_ =~ /## (.*?)(?:\n# .*)*\n.PHONY:\s+(\S+).*/mg) { printf "\033[36m%-30s\033[0m %s\n", $$2, $$1 } }' $(MAKEFILE_LIST) | sort

# ------------------------------------------------------------------------------
# NON-PHONY TARGETS
# ------------------------------------------------------------------------------

${GOPATH}/bin/jv:
ifeq ($(GOPATH),)
$(error GOPATH must be set)
endif
go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest

# ------------------------------------------------------------------------------
# PHONY TARGETS
# ------------------------------------------------------------------------------

.PHONY: .ALWAYS
.ALWAYS:

## Test that the score schema matches the json-schema reference
.PHONY: test-schema
test-schema: ${GOPATH}/bin/jv
${GOPATH}/bin/jv -assertformat -assertcontent https://json-schema.org/draft/2020-12/schema ./score-v1b1.json

## Test that the given score examples in $SCORE_EXAMPLES_DIR match the schema
.PHONY: test-examples
test-examples: ${GOPATH}/bin/jv
ifeq ($(SCORE_EXAMPLES_DIR),)
$(error SCORE_EXAMPLES_DIR must be set)
endif
find ${SCORE_EXAMPLES_DIR} -name 'score*.yaml' -print -exec ${GOPATH}/bin/jv -assertformat -assertcontent ./score-v1b1.json {} \;

## Run all tests
.PHONY: test
test: test-schema test-examples
70 changes: 70 additions & 0 deletions schemas/samples/score-full.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: score.dev/v1b1
metadata:
name: example-workload-name123
extra-key: extra-value
service:
ports:
port-one:
port: 1000
protocol: TCP
targetPort: 10000
port-two2:
port: 8000
containers:
container-one1:
image: localhost:4000/repo/my-image:tag
command: ["/bin/sh", "-c"]
args: ["hello", "world"]
resources:
requests:
cpu: 1000m
memory: 10Gi
limits:
cpu: "0.24"
memory: 128M
variables:
SOME_VAR: some content here
files:
- target: /my/file
mode: "0600"
source: file.txt
- target: /my/other/file
content: |
some multiline
content
volumes:
- source: volume-name
target: /mnt/something
path: /sub/path
readOnly: false
- source: volume-two
target: /mnt/something-else
livenessProbe:
httpGet:
port: 8080
path: /livez
readinessProbe:
httpGet:
host: 127.0.0.1
port: 80
scheme: HTTP
path: /readyz
httpHeaders:
- name: SOME_HEADER
value: some-value-here
container-two2:
image: .
resources:
resource-one1:
metadata:
annotations:
Default-Annotation: this is my annotation
prefix.com/Another-Key_Annotation.2: something else
extra-key: extra-value
type: Resource-One
class: default
params:
extra:
data: here
resource-two2:
type: Resource-Two
60 changes: 47 additions & 13 deletions schemas/score-v1b1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"title": "Score schema",
"description": "Score workload specification",
"type": "object",
"required": ["apiVersion", "metadata", "containers"],
"required": [
"apiVersion",
"metadata",
"containers"
],
"additionalProperties": false,
"properties": {
"apiVersion": {
Expand All @@ -15,7 +19,9 @@
"metadata": {
"description": "The metadata description of the Workload.",
"type": "object",
"required": ["name"],
"required": [
"name"
],
"additionalProperties": true,
"properties": {
"name": {
Expand Down Expand Up @@ -76,7 +82,9 @@
"servicePort": {
"description": "The network port description.",
"type": "object",
"required": ["port"],
"required": [
"port"
],
"additionalProperties": false,
"properties": {
"port": {
Expand All @@ -88,7 +96,10 @@
"protocol": {
"description": "The transport level protocol. Defaults to TCP.",
"type": "string",
"enum": ["TCP", "UDP"]
"enum": [
"TCP",
"UDP"
]
},
"targetPort": {
"description": "The internal service port. This will default to 'port' if not provided.",
Expand All @@ -102,7 +113,9 @@
"description": "The set of Resources associated with this Workload.",
"type": "object",
"additionalProperties": false,
"required": ["type"],
"required": [
"type"
],
"properties": {
"type": {
"description": "The Resource type. This should be a type supported by the Score implementations being used.",
Expand Down Expand Up @@ -164,7 +177,9 @@
"container": {
"description": "The specification of a Container within the Workload.",
"type": "object",
"required": ["image"],
"required": [
"image"
],
"additionalProperties": false,
"properties": {
"image": {
Expand Down Expand Up @@ -202,7 +217,9 @@
"type": "array",
"items": {
"type": "object",
"required": ["target"],
"required": [
"target"
],
"additionalProperties": false,
"properties": {
"target": {
Expand Down Expand Up @@ -231,10 +248,16 @@
},
"oneOf": [
{
"required": ["target", "content"]
"required": [
"target",
"content"
]
},
{
"required": ["target", "source"]
"required": [
"target",
"source"
]
}
]
}
Expand All @@ -245,7 +268,10 @@
"items": {
"type": "object",
"additionalProperties": false,
"required": ["source", "target"],
"required": [
"source",
"target"
],
"properties": {
"source": {
"description": "The external volume reference.",
Expand Down Expand Up @@ -293,7 +319,9 @@
},
"containerProbe": {
"type": "object",
"required": ["httpGet"],
"required": [
"httpGet"
],
"additionalProperties": false,
"properties": {
"httpGet": {
Expand All @@ -305,7 +333,10 @@
"description": "An HTTP probe details.",
"type": "object",
"additionalProperties": false,
"required": ["port", "path"],
"required": [
"port",
"path"
],
"properties": {
"host": {
"description": "Host name to connect to. Defaults to the workload IP. The is equivalent to a Host HTTP header.",
Expand All @@ -314,7 +345,10 @@
"scheme": {
"description": "Scheme to use for connecting to the host (HTTP or HTTPS). Defaults to HTTP.",
"type": "string",
"enum": ["HTTP", "HTTPS"]
"enum": [
"HTTP",
"HTTPS"
]
},
"path": {
"description": "The path to access on the HTTP server.",
Expand Down

0 comments on commit 7d8c571

Please sign in to comment.