gessnerfl / terraform-provider-instana

Terraform provider implementation for Instana REST API
Apache License 2.0
29 stars 16 forks source link

Add Support for Dynamic Custom Payload Values #222

Closed scottcurtis2605 closed 7 months ago

scottcurtis2605 commented 7 months ago

My application's custom payload config contains the following dynamic value data, which infers the Kubernetes Cluster name.

An example of the same API request to api/events/settings/custom-payload-configurations, returns the following data:

{
    "fields": [
        {
            "type": "dynamic",
            "key": "cluster_name",
            "value": {
                "tagName": "kubernetes.cluster.name",
                "key": null
            }
        },
                {
                ...etc
                }
    ]
}

When parsing custom payload data using dynamic variables, the provider crashes with the following error:

Stack trace from the terraform-provider-instana_v2.4.1 plugin:

panic: interface conversion: interface {} is nil, not string

goroutine 99 [running]:
github.com/gessnerfl/terraform-provider-instana/instana/restapi.(*customPayloadFieldsUnmarshallerAdapter[...]).mapCustomPayloadField(...)
        github.com/gessnerfl/terraform-provider-instana/instana/restapi/custom-payload-fields-unmarshaller-adapter.go:58
github.com/gessnerfl/terraform-provider-instana/instana/restapi.
...etc

I believe this is due to restrictions on the returned types of the key field, which returns null in the case of dynamic values.

gessnerfl commented 7 months ago

@scottcurtis2605 I had a look into the issue and indeed it is a bug in the mapping of dynamic custom payload fields. I will work on a bug fix. I already have a working solution but still need to improve some things.

gessnerfl commented 7 months ago

@scottcurtis2605 The issue was fixed with version 2.4.2. Please reopen the ticket in case the issue still persists.

scottcurtis2605 commented 7 months ago

Great, thanks! @gessnerfl