Skip to content

Commit

Permalink
fix: update embedded score specification and fix reference docs (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
astromechza authored Feb 27, 2024
2 parents adbbcd2 + 7d8c571 commit 286d142
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 87 deletions.
36 changes: 21 additions & 15 deletions content/en/docs/reference/score-spec-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ service:
`protocol`: describes the transportation layer protocol.

- Defaults: `TCP`
- Valid values: `SCTP` | `TCP` | `UDP`
- Valid values: `TCP` | `UDP`

`targetPort`: describes the port to expose on the host. If the `targetPort` isn't specified, then it defaults to the required `port` property in the container.

Expand Down Expand Up @@ -202,29 +202,34 @@ command: []string
args: []string
variables: map[string]string
files:
target: string
mode: string
content: string
source: string
noExpand: boolean
- target: string
mode: string
content: string
source: string
noExpand: boolean
volumes:
source: string
path: string
target: string
read_only: [true | false]
- target: string
source: string
path: string
readOnly: [true | false]
resources:
limits: map[string]interface{}
requests: map[string]interface{}
limits:
cpu: string
memory: string
requests:
cpu: string
memory: string
livenessProbe: ContainerProbeSpec
httpGet:
scheme: [HTTP or HTTPS]
path: string
port: int
httpHeaders:
name: string
value: string
readinessProbe:
httpGet:
scheme: string
scheme: [HTTP or HTTPS]
path: string
port: int
httpHeaders:
Expand Down Expand Up @@ -257,7 +262,7 @@ readinessProbe:
- `source`: specifies external volume reference.
- `path` specifies a sub path in the volume.
- `target`: specifies a target mount on the container.
- `read_only`: if true, mounts as read only.
- `readOnly`: if true, mounts as read only.

<!-- Optional CPU and memory resources needed -->

Expand All @@ -277,6 +282,7 @@ readinessProbe:
- `scheme`: specifies the identifier used for connecting to the host.
- Defaults: `HTTP`
- Valid values: `HTTP` | `HTTPS`
- `host`: specifies the Hostname in the HTTP request. Defaults to the target IP address.
- `path`: specifies a path for the HTTP `Get` method.
- `port`: specifies a port for the HTTP `Get` method.
- `httpHeaders`: headers to set in the request. Allows repeated headers.
Expand Down Expand Up @@ -313,7 +319,7 @@ containers:
- source: ${resources.data} # - External volume reference
path: sub/path # - (Optional) Sub path in the volume
target: /mnt/data # - Target mount path on the container
read_only: true # - (Optional) Mount as read-only
readOnly: true # - (Optional) Mount as read-only
resources: # (Optional) CPU and memory resources needed
limits: # - (Optional) Maximum allowed
Expand Down
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
Loading

0 comments on commit 286d142

Please sign in to comment.