cli icon indicating copy to clipboard operation
cli copied to clipboard

Support for Complex Types in Bundle Variables

Open stevenayers opened this issue 1 year ago • 1 comments
trafficstars

Changes

Adding Support for Complex Types in Bundle Variables.

https://github.com/databricks/cli/issues/1298

Tests

Using existing testing pattern with dummy databricks.yml files

stevenayers avatar Apr 06 '24 22:04 stevenayers

@pietern I optimistically and naively started this PR but realised it's a pretty huge refactor.

I've mentioned you because it looks like dyn.Value is your brain child.

The issue I'm having is that when normalising the config tree, the logic expects a solid Native type. I explored adding a type field to the variable definition, but because normalize walks the config tree, it's unaware of the elements under the same parent struct. Putting logic into normalizeStruct to look for a type field could maybe help, but it doesn't feel like the right solution.

I wanted to explore:

  1. Using https://github.com/icza/dyno to load the yaml config and convert it to JSON.
  2. Then use https://github.com/zclconf/go-cty which terraform uses for variable resolution to convert the JSON and unmashal it against the tree using cty Types.

But I'd be completely changing the design of how bundle configuration is parsed, so maybe there's a better way by extending dyn.Value with something similar to cty.DynamicPseudoType?

Ps. Haven't used Golang since 2019 so I might be overlooking a cleaner solution using Generics etc.

stevenayers avatar Apr 08 '24 06:04 stevenayers

Thanks for the contribution! We picked up the work on our side so I'm closing this one if favour of https://github.com/databricks/cli/pull/1467

andrewnester avatar Jun 04 '24 10:06 andrewnester

Thanks for the contribution! We picked up the work on our side so I'm closing this one if favour of #1467

Brilliant thank you :)

stevenayers avatar Jun 15 '24 11:06 stevenayers