terraform-routeros / terraform-provider-routeros

Terraform Provider for Mikrotik RouterOS
Mozilla Public License 2.0
187 stars 53 forks source link

Generate the provider from OpenAPI? #556

Open jmuchovej opened 2 days ago

jmuchovej commented 2 days ago

Is your feature request related to a problem? Please describe. It seems like only part of the REST API is integrated in the provider (totally understandable!). If it's possible to support the full REST API, that would be amazing.

Describe the solution you'd like I've seen this work for other toolchains, though I've never taken a crack at this myself. However, it seems that with an OpenAPI spec, one could generate a Terraform Provider algorithmically (save, perhaps, for the aliasing).

To this end, I searched around for whether an OpenAPI spec exists and came across the following:

Documentation Based on the forum post, there's exactly 0 documentation on this, as its not published by MikroTik. 😢

Additional context Total novice at Go and Terraform Providers, but I'd be willing to take a crack at this, if this sounds like an interesting avenue to pursue for maintaining the provider.

vaerh commented 2 days ago

In my opinion this seemingly promising topic contains many problems. There was an attempt to implement adding data sources based on JSON output, but even with this not everything is simple. A few major problems that make it impossible to generate resources automatically based on restraml / JSON / CLI output: lack of built-in attribute description, lack of validation schemes, lack of uniformity of creation/update functions for all resources, impossibility of automatic decision making on suppression of reaction to attribute changes. To my great regret now adding new resources is like manually creating a watch from Seiko to Breguet. Somewhere very easy, and somewhere quite complicated and costly.

Well, and of course the famous unexpected behavior of some MT resources. It is not frequent, but still occurs.

jmuchovej commented 1 day ago

In my opinion this seemingly promising topic contains many problems.

Hehe, I think it's fair to upgrade this from an opinion to plain "facts". I looked more deeply into the RAML / JSON output from the link repo and much of what Terraform needs to work as intended, doesn't exist. (Like the validation schemas, among many others.)

Definitely saddened that there's no way to build the provider straight from the API. 😅 Feel free to close this if it helps with tracking things! 🙂

tofkamp commented 18 hours ago

The idea to make a provider from an API definition is great, but lacks a major component. The API is about which functions are available, and is not about objects and their state. With functions you can change the state of an object, but which function is for which object ? This is not (yet) defined in any common API specification.