ddelnano / terraform-provider-mikrotik

MIT License
128 stars 28 forks source link

Parse inspected console item definition #212

Closed maksym-nazarenko closed 7 months ago

maksym-nazarenko commented 10 months ago

This PR allows to generate MikroTik resource with list of all fields, which are available in RouterOS. Detailed description is available in README.

Example of generated dhcp-server resource.

$ go run cmd/mikrotik-codegen/main.go mikrotik -commandBase /ip/dhcp-server -name DhcpServer -inspect-definition-file ./inspect_definition.txt

or fully automated way of querying remote system for the fields list:

$ go run cmd/mikrotik-codegen/main.go mikrotik -commandBase /ip/dhcp-server -name DhcpServer -query-definition
show output ```go type DhcpServer struct { Id string `mikrotik:".id"` AddArp string `mikrotik:"add-arp"` AddressPool string `mikrotik:"address-pool"` AllowDualStackQueue string `mikrotik:"allow-dual-stack-queue"` AlwaysBroadcast string `mikrotik:"always-broadcast"` Authoritative string `mikrotik:"authoritative"` BootpLeaseTime string `mikrotik:"bootp-lease-time"` BootpSupport string `mikrotik:"bootp-support"` ClientMacLimit string `mikrotik:"client-mac-limit"` Comment string `mikrotik:"comment"` ConflictDetection string `mikrotik:"conflict-detection"` CopyFrom string `mikrotik:"copy-from"` DelayThreshold string `mikrotik:"delay-threshold"` DhcpOptionSet string `mikrotik:"dhcp-option-set"` Disabled string `mikrotik:"disabled"` InsertQueueBefore string `mikrotik:"insert-queue-before"` Interface string `mikrotik:"interface"` LeaseScript string `mikrotik:"lease-script"` LeaseTime string `mikrotik:"lease-time"` Name string `mikrotik:"name"` ParentQueue string `mikrotik:"parent-queue"` Relay string `mikrotik:"relay"` ServerAddress string `mikrotik:"server-address"` UseFramedAsClassless string `mikrotik:"use-framed-as-classless"` UseRadius string `mikrotik:"use-radius"` } ```
ddelnano commented 7 months ago

Sorry for the extremely late review on this. Very exciting to see the code generation pieces coming together!