koki / short

Manageable Kubernetes manifests through a composable, reusable syntax
https://docs.koki.io/short
Apache License 2.0
122 stars 14 forks source link

multiple exported resources per module #84

Closed ublubu closed 6 years ago

ublubu commented 6 years ago

78

@wlan0

Syntax for exporting multiple resources from a "module" and selecting a specific resource from an imported module.

Design notes:

imports:
- pods_list: some/pod/pods-list-template.yaml
  params:
    param0: ...#some value
params:
- name: name of the application
- web_port: the port to use for the web app
  default: 80

# exported resources at the top level of the file?
# if there's only one resource, do we still need to give it a name?
# what about documentation for each exported value?
#   this syntax doesn't really support descriptions (see "app_pod" below)
custom_pod:
  pod:
    etc...
app_pod: ${pods_list.pod0}

# use a separate "exports" group. one entry per exported resource.
# terraform uses a "value" key like the one below.
exports:
- custom_pod: a pod we defined here
  value:
    pod:
      etc...
- app_pod: a pod we imported
  value: ${pods_list.pod0}

# if a module exports only one resource, we want to be able to use it like ${import_name}
# instead of always having to ${import_name.exported_name}

# if we allow "exports" to contain a single unnamed export,
#   how do we distinguish this from a single named export? how do we add a description?
exports: ${pods_list.pod0}
exports:
  pod:
    etc...

# we can use the name "default", which is how javascript solved this problem.
exports:
- default: a pod we imported
  value: ${pods_list.pod0}

exports:
- default: a pod we defined here
  value:
    pod:
      etc...

# if a yaml document contains no imports/params/exports
#   (i.e. a plain resource file, not a real module),
#   then it's equivalent to "exports: default: ${document contents}"