volume
The default volume provisioner provided by score-compose allows basic volume resources to be created in the resources system. The volume resource just creates an ephemeral Docker volume with a random string as the name, and source attribute that we can reference.
Creates a persistent volume that can be mounted on a workload.
type: volume
expected_outputs:
- source
- typeprovisioners.yaml
(view on GitHub)
:
- uri: template://default-provisioners/volume
# By default, match all classes and ids of volume. If you want to override this, create another provisioner definition
# with a higher priority.
type: volume
description: Creates a persistent volume that can be mounted on a workload.
init: |
randomVolumeName: {{ .Id | replace "." "-" }}-{{ randAlphaNum 6 }}
# Store the random volume name if we haven't chosen one yet, otherwise use the one that exists already
state: |
name: {{ dig "name" .Init.randomVolumeName .State }}
# Return a source value with the volume name. This can be used in volume resource references now.
outputs: |
type: volume
source: {{ .State.name }}
# Add a volume to the docker compose file. We assume our name is unique here. We also apply a label to help ensure
# that we can track the volume back to the workload and resource that created it.
volumes: |
{{ .State.name }}:
name: {{ .State.name }}
driver: local
labels:
dev.score.compose.res.uid: {{ .Uid }}
expected_outputs:
- source
- type