draft-classic icon indicating copy to clipboard operation
draft-classic copied to clipboard

allow draft packs to customize draft.toml

Open omnilinguist opened this issue 7 years ago • 2 comments

This could be useful if an organization / team has custom draft.toml settings it would like to standardize as default.

Here's what actually happened when I tried putting a draft.toml inside a draft pack and then draft createing it:

contents of draft.toml in pack:

[environments]
  [environments.staging]
    name = "service-template"
    registry = "CUSTOM_DOCKER_REGISTRY"
    namespace = "staging"
    wait = true
    watch = false
    watch-delay = 2
    auto-connect = false
    dockerfile = ""
    chart = ""
    set = ["environment=staging"]
  [environments.prod]
    name = "service-template"
    registry = "CUSTOM_DOCKER_REGISTRY"
    namespace = "prod"
    wait = true
    watch = false
    watch-delay = 2
    auto-connect = false
    dockerfile = ""
    chart = ""
    set = ["environment=prod"]

what came out from draft create (this is verbatim):

[environments]
  [environments.development]
    name = "my-service"
    namespace = "default"
    wait = true
    watch = false
    watch-delay = 2
    auto-connect = false
    dockerfile = ""
    chart = ""
uto-connect = false
    dockerfile = ""
    chart = ""
    set = ["environment=staging"]
  [environments.prod]
    name = "service-template"
    registry = "CUSTOM_DOCKER_REGISTRY"
    namespace = "prod"
    wait = true
    watch = false
    watch-delay = 2
    auto-connect = false
    dockerfile = ""
    chart = ""
    set = ["environment=prod"]

It looks like the order of operations is to first copy the files, and then overwrite the initial segment of draft.toml with the default contents. I think a better behaviour might be to respect the existing contents, and only overwrite all name values in draft create if the pack already has a draft.toml (since it looks like that's the main thing within draft.toml that needs to be templatized/customized to the appName). This would require introspecting the TOML file contents though...

omnilinguist avatar Jun 13 '18 15:06 omnilinguist

Thanks for bringing this up @omnilinguist. We should probably not override a draft.toml file if it is included in the draft pack.

michelleN avatar Jun 13 '18 17:06 michelleN

that could be a good first iteration. I think you do want to introspect the toml though (or have a more generic templating method similar to https://github.com/audreyr/cookiecutter); there is already some automagic functionality elsewhere that is doing replacements and injections of the appName - eg. the name value in Chart.yaml, as well as the injection of an intermediate directory charts/appName/... to work around https://github.com/kubernetes/helm/issues/1979

omnilinguist avatar Jun 13 '18 17:06 omnilinguist