mories76 / terraform-provider-ardoq

Terraform provider for Ardoq

Home Page:https://registry.terraform.io/providers/mories76/ardoq/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error data: returns all workspaces

dilbertside opened this issue · comments

Hello,

I am testing your provider V0.1.0 and using an example provided and I met the following error

 Error: workspaces.31.fields.ardoq-persistent: '' expected type 'string', got unconvertible type 'map[string]interface {}', value: 'map[use-case:Strategic Planning & Execution]'
│ 
│   with data.ardoq_workspaces.all,
│   on ardoq.tf line 3, in data "ardoq_workspaces" "all":
│    3: data "ardoq_workspaces" "all" {

Thank you for sharing this provider.
I am not familiar with go, but if I could help debug this provider, I could give a try.

Hi,

Thank you very much for this issue, that means someone actually found my provider ;-)

I am not going to blame Ardoq for this, but I think there is some behaviour from the Ardoq API which is not clear to me yet.
It seems that the API is return a field which I haven't mapped in my API client.
https://github.com/mories76/ardoq-client-go/blob/main/pkg/workspace_types.go
I have seen the field in the response for the Models endpoint.
https://github.com/mories76/ardoq-client-go/blob/main/pkg/model_types.go

All fields for which there is no specific field in the struct will be provided under the "fields" field. And unfortunately there is a type conversion issue.

What I will do is the following:

  • I will add the "ardoq-persistent" field to the structure for workspaces.
  • I have to think about testing, I might just release often on the Terraform registry, or I might release only on github.
    I'll get back to you on this one.

Just a question, are familiar with API's JSON and a tool like Talend API Test or Postman ?
Some pure json might help. Maybe I should provide the option to log the JSON response.
Just some thoughts, thanks you very much for your time.

I was in a hurry this morning, forgot to press comment...
But I have release a small release v0.1.1 this version added the ardoq-persistent field to the internal model.
I think this might fix this issue.

Yes, after reporting the issue, I went to the ardoq-client-go and try to read the go code.
And I got an idea of what maybe wrong.

I just retried with version 0..1.1 and I have another error

Error: components.0.fields.data_object_s: '' expected type 'string', got unconvertible type '[]interface {}', value: '[Finance]'
│ 
│   with data.ardoq_components.all,
│   on ardoq.tf line 31, in data "ardoq_components" "all":
│   31: data "ardoq_components" "all" {
│ 
╵

To give a bit of background: we have more than 20 workspaces in our organisation and we created meta-model specific for our clients.
Those non-standard meta-models might be the dance breaker. My 2 cents.
If that the case we should have a model introspector to build a model on the fly or make a json string and store it in a field for later use, maybe!.

Yes I am familiar with Postman and curl, so if with a switch in ardoq-client-go you could log the curl query we could use it as-is in whatever tools to analyse the data return by the Ardoq API.

About the unmapped field, having a look at he project https://github.com/ardoq/ardoq-java-client.git (which worked last time I used it) could help to find out the discrepancy, As I am more familiar with Java, I could have a look if you want.

When I run the following, I have no errors:

# OK
# returns all models in workspace
data "ardoq_models" "all" {
}

# output all models
# terraform output -json ardoq_all_models | jq "." > logs/ardoq_all_models.json
output "ardoq_all_models" {
  value = data.ardoq_models.all
}

As a side note, thank you to draft this provider, it is many months I think terraform is the best place to inform an EA repo, IaC to EA might be the best place to inject/sync infrastructure elements in a DevOps operating model. I don't have the time to initiate it, I may have some time to debug it.

Actually, comments were messed up in my terraform config, and if you notice the error reported it is no more data.ardoq_workspaces.all but data.ardoq_components.all.
So we can consider this issue fixed with 0.1.1, and I open a new issue for components.