This score-implementation-sample is a template repo for creating a new Score implementation following the conventions laid out in Score Compose and Score K8s.
This sample comes complete with:
- CLI skeleton including
init
andgenerate
subcommandsgenerate --overrides-file
andgenerate --override-property
for applying Score overrides before conversiongenerate --image
for overriding the workload image before conversion.- Full placeholder support for
${metadata...}
and${resource...}
expressions in the workload variables, files, and resource params.
- State directory storage in
.score-implementation-sample/
TODO
in place of resource provisioning and workload conversion
To adapt this for your target platform, you should:
- Fork the repo or use the "use as template" button in Github (this flattens the commit history)
- Rename the go module by replacing all instances of
github.com/score-spec/score-implementation-sample
with your own module name. - Replace all other instances of
score-implementation-sample
with your ownscore-xyz
name including renaming thecmd/score-implementation-sample
directory. - Run the tests with
go test -v ./...
. - Change the
TODO
in provisioning.go to provision resources and set the resource outputs. The existing implementation resolves placeholders in the resource params but does not set any resource outputs. - Change the
TODO
in convert.go to convert workloads into the target manifest form. The existing implementation resolves placeholders in the variables and files sections but just returns the workload spec as yaml content in the manifests.
Good luck, and have fun!
Write the following to score.yaml
:
apiVersion: score.dev/v1b1
metadata:
name: example
containers:
main:
image: stefanprodan/podinfo
variables:
key: value
dynamic: ${metadata.name}
files:
- target: /somefile
content: |
${metadata.name}
resources:
thing:
type: something
params:
x: ${metadata.name}
And run:
go run ./ init
go run ./ generate score.yaml
The output manifests.yaml
contains the following which indicates:
- Resources were "provisioned" and their parameters interpolated.
- Workloads were converted by copying them to the output manifests with variables or files interpolated as required.
apiVersion: score.dev/v1b1
metadata:
name: example
containers:
main:
files:
- content: |
example
noExpand: true
target: /somefile
image: stefanprodan/podinfo
variables:
dynamic: example
key: value
resources:
thing:
params:
x: example
type: something
Most code files here retain the Apache licence header since they were copied or adapted from the reference score-compose
which is Apache licensed. Any modifications to these files should retain the Apache licence and attribution.