terraform-provider-elasticstack icon indicating copy to clipboard operation
terraform-provider-elasticstack copied to clipboard

Add support for global data tags in agent policy creation and update

Open mholttech opened this issue 1 year ago • 2 comments
trafficstars

Resolves #667

mholttech avatar Aug 27 '24 04:08 mholttech

@tobio can I get a review on this?

mholttech avatar Aug 27 '24 15:08 mholttech

FWIW I have the tests working across all versions here. I'm not totally sure how I feel about these spec changes, and I think they should probably be encoded into getschema.go but at least there's a working solution here.

tobio avatar Oct 07 '24 12:10 tobio

@tobio I'm finally getting back around to this and am trying to update this PR but when trying to generate the updated fleet spec using 8.16 or 8.17, since the bundle has the fixes in it that we discussed previously, I'm getting this error

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x2 addr=0x18 pc=0x104918074]

goroutine 1 [running]: main.(*Path).GetEndpoint(0x0, {0x10491b2fe?, 0x10491f237?}) /Users/mwholt/GIT/github/mholttech/terraform-provider-elasticstack/generated/fleet/getschema.go:43 +0x54 main.transformOutputResponseType(0x140000bb030) /Users/mwholt/GIT/github/mholttech/terraform-provider-elasticstack/generated/fleet/getschema.go:188 +0xb8 main.main() /Users/mwholt/GIT/github/mholttech/terraform-provider-elasticstack/generated/fleet/getschema.go:393 +0x24c exit status 2 fleet_gen.go:3: running "go": exit status 1

mholttech avatar Jan 08 '25 01:01 mholttech

Looking at the published docs for creating a policy, I'd expect global_data_tags to be present in the generated code already. IMO it might be easiest to take the changes from internal/fleet in this PR and apply them to main and get things working from there.

tobio avatar Jan 10 '25 06:01 tobio

Closing this PR as there are too many differences since my original contribution. I'm struggling to implement this in the updated code base

mholttech avatar Feb 06 '25 23:02 mholttech

@mholttech is there something I can help with to get you unblocked on this?

The API client changes are available in the main branch, so you should 'just' have to work on the TF resource itself. That means:

  • Adding the global_data_tags to the schema
  • Adding a GlobalDataTags field to the TF model used by the resource
  • Converting data tags from the API model to the TF model. This is used when reading the current state.
  • Converting data tags from the TF model to the API model. Used in create/update flows.

tobio avatar Feb 10 '25 22:02 tobio

@tobio a coworker of mine is working on this and we'll have a fresh PR for review very soon.

mholttech avatar Feb 18 '25 18:02 mholttech