Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Map[string]string #80

Open
2 tasks done
dikhan opened this issue Dec 9, 2018 · 3 comments
Open
2 tasks done

Support for Map[string]string #80

dikhan opened this issue Dec 9, 2018 · 3 comments

Comments

@dikhan
Copy link
Owner

dikhan commented Dec 9, 2018

Is your feature request related to a problem?

Currently, the provider only supports complex object data structures (with nested properties etc) but it's not possible to have properties that are Map[string]string.

Describe the solution you'd like

As per swagger spec HashMaps of key/value strings can be described as follows:

definitions:
  HashMapExample:
    type: object
    additionalProperties:
      type: string # this defines the values of the map being strings

And the expectation would be to have that property translated to the following terraform schema which effectively is a Map[string]string:

 &schema.Schema{
		Type: schema.TypeMap,
		Elem: &schema.Schema{Type: schema.TypeString},
	}

Acceptance criteria

What's required to consider this feature request complete?

  • User should be able to defined hash maps as described above and be able to define that property accordingly in the terraform configuration file.

Checklist

Don't forget to go through the checklist to make sure the issue is created properly:

  • I have added a corresponding label (feature request/bug/etc) to the issue (right side menu)
  • I have added this issue to the 'API Terraform Provider' GitHub project (right side menu)
@fredericosilva
Copy link

Hi @dikhan do you have any work done on this subject or any ideas how to approach it?

@dikhan
Copy link
Owner Author

dikhan commented Nov 24, 2019

Hey @fredericosilva ,

We are planning to work on this next after the #186 is done. Haven't put much thought on it besides the initial research when creating the issue, but the idea would be to have the provider understand properties that are\ defined as follows and expose their terraform schema as a Type: schema.TypeMap with Elem: &schema.Schema{Type: schema.TypeString}

  HashMapProperty:
    type: object
    additionalProperties:
      type: string # this defines the values of the map being strings

If you fancy taking a stub at it, the two places to look into would be:

I would start putting together a test in https://github.com/dikhan/terraform-provider-openapi/blob/master/tests/e2e/resources_test.go that has the map described and asserting on the provider schema containing the hashmap which would fail. That could serve as the basic to get going and start drilling into the code to understand better the different places that need updates.

Hope this helps!
Dani

@fredericosilva
Copy link

fredericosilva commented Nov 27, 2019

Thank you for pointing me in the right direction. I'll try to have a look on that later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants