kestra-io / terraform-provider-kestra

https://kestra.io/docs/terraform/
Apache License 2.0
11 stars 10 forks source link

Make namespace and flow optional when using keep_original_source = true #79

Open tchiotludo opened 1 year ago

tchiotludo commented 1 year ago

right now, we could read it from the yaml like that

resource "kestra_flow" "demo_flows" {
  for_each = fileset(path.module, "kestra/io.kestra.demo/*.yml")
  flow_id = yamldecode(templatefile(each.value, {}))["id"]
  namespace = yamldecode(templatefile(each.value, {}))["namespace"]
  content = templatefile(each.value, {})
  keep_original_source = true
}

but we are able to read it directly from the yaml since the id and namespace are mandatory

aballiet commented 1 year ago

Or make the opposite : use terraform fields and internally generate this mandatory part of the YAML. Makes sense to define these values with TF params to me.

WDYT ?

tchiotludo commented 1 year ago

I've an issue, the goal keep_original_source is to kept exact source of the flow, if the people want to add comment everywhere (at the beginning, end, between namespace and id properties), it must be able to it, when we unserialize, serialize a yaml string, most of parsers will break that (remove comment, changing quote, ...), so it appear to be not the good way

aballiet commented 1 year ago

Okey, and what about doing it in the API call : https://kestra.io/docs/api-guide/#post-/api/v1/flows.

Using values from content for everything except id and namespace if var provided using TF ressource, otherwise use all values from content.

https://github.com/kestra-io/terraform-provider-kestra/blob/e0fff3d689a90a6f98910cfd504e4b813965d41d/internal/provider/resource_flow.go#L63-L92

tldr : not having to unserialize, serialize a yaml string

aballiet commented 1 year ago

In the end it's more a question about how we see the terraform provider.

If no logic at all should be implemented within the provider then we go with only content & keep_original_source params.

Otherwise we could also have flow_id, namespace and some other future fields.

Skraye commented 1 month ago

As discuss with Ludo long times ago, this would be tricky, so we decided that the change will be done when we will fully change the API to create flows

aballiet commented 1 month ago

As discuss with Ludo long times ago, this would be tricky, so we decided that the change will be done when we will fully change the API to create flows

OK yes. Can't wait for this. Do you have an idea when it will be released?

Skraye commented 1 month ago

@aballiet We just deprecated methods using JSON to create/edit flow, so I can't really tell