Skip to content

Commit

Permalink
Merge branch 'main' into variadic_skip_field
Browse files Browse the repository at this point in the history
  • Loading branch information
vaerh authored Mar 22, 2024
2 parents a67b772 + f6281b9 commit 6f9db82
Show file tree
Hide file tree
Showing 35 changed files with 632 additions and 59 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
## [1.37.2](https://github.com/terraform-routeros/terraform-provider-routeros/compare/v1.37.1...v1.37.2) (2024-03-18)


### Bug Fixes

* **dhcp-server:** Add a missing DHCP server option attribute ([c375754](https://github.com/terraform-routeros/terraform-provider-routeros/commit/c375754f0651196cbdb3ec986149d60f16fa6847)), closes [#376](https://github.com/terraform-routeros/terraform-provider-routeros/issues/376)

## [1.37.1](https://github.com/terraform-routeros/terraform-provider-routeros/compare/v1.37.0...v1.37.1) (2024-03-18)


### Bug Fixes

* Enable importing ethernet interfaces ([#379](https://github.com/terraform-routeros/terraform-provider-routeros/issues/379)) ([3676f3f](https://github.com/terraform-routeros/terraform-provider-routeros/commit/3676f3f210acaa51e6f0632369d8ba5f35f56b5e))

## [1.37.0](https://github.com/terraform-routeros/terraform-provider-routeros/compare/v1.36.1...v1.37.0) (2024-03-18)


### Features

* Add `routeros_wifi` resource to manage WiFi interfaces ([5f234c4](https://github.com/terraform-routeros/terraform-provider-routeros/commit/5f234c456ca8c790e214d5b3e2dd8a8b1ab69b88))


### Bug Fixes

* Add reusable L2MTU property ([93a7495](https://github.com/terraform-routeros/terraform-provider-routeros/commit/93a749559aaf7df3235c8d9512cc7c5a1e417cea))
* Fix the `routeros_wifi_configuration` resource to suppress pristine inline parameters ([77d807c](https://github.com/terraform-routeros/terraform-provider-routeros/commit/77d807c2fd1e8bfe8d67de011c2b3b4851477d41))
* Refactor `AlwaysPresentNotUserProvided` helper to self-contain empty value check ([669fd68](https://github.com/terraform-routeros/terraform-provider-routeros/commit/669fd689008aba4673205fcfca1252c5b1a7f795))
* Refactor `AlwaysPresentNotUserProvided` helper to support map type ([038fe7c](https://github.com/terraform-routeros/terraform-provider-routeros/commit/038fe7c192ba87c46f1ed13334183f33d1cc6717))

## [1.36.1](https://github.com/terraform-routeros/terraform-provider-routeros/compare/v1.36.0...v1.36.1) (2024-03-18)


### Bug Fixes

* stop using Int32MaxValue as upper bound for validation ([fcae1bd](https://github.com/terraform-routeros/terraform-provider-routeros/commit/fcae1bdfb8ef0b3622133eab4b04822b122ed405))

## [1.36.0](https://github.com/terraform-routeros/terraform-provider-routeros/compare/v1.35.1...v1.36.0) (2024-03-17)


Expand Down
20 changes: 18 additions & 2 deletions docs/resources/container.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# routeros_container (Resource)



## Example Usage
```terraform
resource "routeros_container" "busybox" {
remote_image = "library/busybox:1.35.0"
cmd = "/bin/httpd -f -p 8080"
interface = routeros_interface_veth.busybox.name
logging = true
root_dir = "/usb1-part1/containers/busybox/root"
start_on_boot = true
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down Expand Up @@ -47,4 +57,10 @@ Optional:
- `create` (String)
- `delete` (String)


## Import
Import is supported using the following syntax:
```shell
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/container get [print show-ids]]
terraform import routeros_container.busybox "*1"
```
16 changes: 14 additions & 2 deletions docs/resources/container_config.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# routeros_container_config (Resource)



## Example Usage
```terraform
resource "routeros_container_config" "config" {
registry_url = "https://registry-1.docker.io"
ram_high = "0"
tmpdir = "/usb1-part1/containers/tmp"
layer_dir = "/usb1-part1/containers/layers"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -19,4 +27,8 @@

- `id` (String) The ID of this resource.


## Import
Import is supported using the following syntax:
```shell
terraform import routeros_container_config.config .
```
17 changes: 15 additions & 2 deletions docs/resources/container_envs.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# routeros_container_envs (Resource)



## Example Usage
```terraform
resource "routeros_container_envs" "test_envs" {
name = "test_envs"
key = "TZ"
value = "UTC"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -19,4 +26,10 @@

- `id` (String) The ID of this resource.


## Import
Import is supported using the following syntax:
```shell
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/container/envs get [print show-ids]]
terraform import routeros_container_envs.test_envs "*1"
```
17 changes: 15 additions & 2 deletions docs/resources/container_mounts.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# routeros_container_mounts (Resource)



## Example Usage
```terraform
resource "routeros_container_mounts" "caddyfile" {
name = "Caddyfile"
src = "/usb1-part1/containers/caddy/Caddyfile"
dst = "/etc/caddy/Caddyfile"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand All @@ -19,4 +26,10 @@

- `id` (String) The ID of this resource.


## Import
Import is supported using the following syntax:
```shell
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/container/mounts get [print show-ids]]
terraform import routeros_container_mounts.caddyfile "*1"
```
1 change: 1 addition & 0 deletions docs/resources/ip_dhcp_server_option.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ resource "routeros_ip_dhcp_server_option" "tftp_option" {

### Optional

- `force` (Boolean) Force the DHCP option from the server-side even if the DHCP-client does not request such parameter.

### Read-Only

Expand Down
19 changes: 17 additions & 2 deletions docs/resources/system_script.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# routeros_system_script (Resource)



## Example Usage
```terraform
resource "routeros_system_script" "script" {
name = "my_script"
source = <<EOF
:log info "This is a test script created by Terraform."
EOF
policy = ["read", "write", "test", "policy"]
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down Expand Up @@ -35,4 +44,10 @@ policy = ["ftp", "read", "write"]
- `owner` (String)
- `run_count` (String) This counter is incremented each time the script is executed.


## Import
Import is supported using the following syntax:
```shell
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/system/script get [print show-ids]]
terraform import routeros_system_script.script "*0"
```
60 changes: 60 additions & 0 deletions docs/resources/wifi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# routeros_wifi (Resource)
*<span style="color:red">This resource requires a minimum version of RouterOS 7.13.</span>*

## Example Usage
```terraform
resource "routeros_wifi" "wifi1" {
configuration = {
manager = "capsman"
}
name = "wifi1"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Name of the interface.

### Optional

- `aaa` (Map of String) AAA inline settings.
- `arp` (String) Address Resolution Protocol mode:
* disabled - the interface will not use ARP
* enabled - the interface will use ARP
* local-proxy-arp - the router performs proxy ARP on the interface and sends replies to the same interface
* proxy-arp - the router performs proxy ARP on the interface and sends replies to other interfaces
* reply-only - the interface will only reply to requests originated from matching IP address/MAC address combinations which are entered as static entries in the ARP table. No dynamic entries will be automatically stored in the ARP table. Therefore for communications to be successful, a valid static entry must already exist.
- `arp_timeout` (String) ARP timeout is time how long ARP record is kept in ARP table after no packets are received from IP. Value auto equals to the value of arp-timeout in IP/Settings, default is 30s. Can use postfix ms, s, M, h, d for milliseconds, seconds, minutes, hours or days. If no postfix is set then seconds (s) is used.
- `channel` (Map of String) Channel inline settings.
- `configuration` (Map of String) Configuration inline settings.
- `datapath` (Map of String) Datapath inline settings.
- `disable_running_check` (Boolean) An option to set the running property to true if it is not disabled.
- `disabled` (Boolean)
- `interworking` (Map of String) Interworking inline settings.
- `l2mtu` (Number) Layer2 Maximum transmission unit. [See](https://wiki.mikrotik.com/wiki/Maximum_Transmission_Unit_on_RouterBoards).
- `mac_address` (String) MAC address (BSSID) to use for the interface.
- `master_interface` (String) The corresponding master interface of the virtual one.
- `mtu` (Number) Layer3 maximum transmission unit
- `security` (Map of String) Security inline settings.
- `steering` (Map of String) Steering inline settings.

### Read-Only

- `bound` (Boolean) A flag whether the interface is currently available for the WiFi manager.
- `default_name` (String) The interface's default name.
- `id` (String) The ID of this resource.
- `inactive` (Boolean) A flag whether the interface is currently inactive.
- `master` (Boolean) A flag whether the interface is not a virtual one.
- `radio_mac` (String) The MAC address of the associated radio.
- `running` (Boolean) A flag whether the interface has established a link to another device.

## Import
Import is supported using the following syntax:
```shell
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/interface/wifi get [print show-ids]]
terraform import routeros_wifi.wifi1 '*1'
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions examples/resources/routeros_interface_macvlan/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/interface/macvlan get [print show-ids]]
terraform import routeros_interface_macvlan.test "*0"
5 changes: 5 additions & 0 deletions examples/resources/routeros_interface_macvlan/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "routeros_interface_macvlan" "test" {
interface = "ether1"
name = "macvlan1"
disabled = false
}
3 changes: 3 additions & 0 deletions examples/resources/routeros_system_script/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/system/script get [print show-ids]]
terraform import routeros_system_script.script "*0"
7 changes: 7 additions & 0 deletions examples/resources/routeros_system_script/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "routeros_system_script" "script" {
name = "my_script"
source = <<EOF
:log info "This is a test script created by Terraform."
EOF
policy = ["read", "write", "test", "policy"]
}
3 changes: 3 additions & 0 deletions examples/resources/routeros_wifi/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#The ID can be found via API or the terminal
#The command for the terminal is -> :put [/interface/wifi get [print show-ids]]
terraform import routeros_wifi.wifi1 '*1'
6 changes: 6 additions & 0 deletions examples/resources/routeros_wifi/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "routeros_wifi" "wifi1" {
configuration = {
manager = "capsman"
}
name = "wifi1"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "terraform-provider-routeros",
"version": "1.36.0",
"version": "1.37.2",
"repository": {
"type": "git",
"url": "https://github.com/terraform-routeros/terraform-provider-routeros"
Expand Down
2 changes: 2 additions & 0 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func Provider() *schema.Provider {
"routeros_interface_ethernet_switch_vlan": ResourceInterfaceEthernetSwitchVlan(),
"routeros_interface_ethernet_switch_rule": ResourceInterfaceEthernetSwitchRule(),
"routeros_interface_gre": ResourceInterfaceGre(),
"routeros_interface_macvlan": ResourceInterfaceMacVlan(),
"routeros_interface_ipip": ResourceInterfaceIPIP(),
"routeros_interface_vlan": ResourceInterfaceVlan(),
"routeros_interface_vrrp": ResourceInterfaceVrrp(),
Expand Down Expand Up @@ -241,6 +242,7 @@ func Provider() *schema.Provider {
"routeros_user_manager_user_profile": ResourceUserManagerUserProfile(),

// WiFi
"routeros_wifi": ResourceWifi(),
"routeros_wifi_aaa": ResourceWifiAaa(),
"routeros_wifi_access_list": ResourceWifiAccessList(),
"routeros_wifi_cap": ResourceWifiCap(),
Expand Down
36 changes: 33 additions & 3 deletions routeros/provider_schema_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ var (
Description: "Layer2 Maximum transmission unit. " +
"[See](https://wiki.mikrotik.com/wiki/Maximum_Transmission_Unit_on_RouterBoards).",
}
PropL2MtuRw = &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Description: "Layer2 Maximum transmission unit. " +
"[See](https://wiki.mikrotik.com/wiki/Maximum_Transmission_Unit_on_RouterBoards).",
ValidateFunc: validation.IntBetween(1, 65535),
DiffSuppressFunc: AlwaysPresentNotUserProvided,
}
PropLocalAddressRw = &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -616,13 +624,35 @@ var (
// Prevents the need of hardcode values for default values, as those are harder to track over time/versions of
// routeros
AlwaysPresentNotUserProvided = func(k, old, new string, d *schema.ResourceData) bool {
if old == "" {
return false
}

value := d.GetRawConfig()

// For lists and sets, the key will look like `something.12345` or `something.#`.
// But in the raw config it will be just `something`.
k = strings.Split(k, ".")[0]
loop:
for _, key := range strings.Split(k, ".") {
if key == "#" || key == "%" {
break
}

if old != "" && d.GetRawConfig().GetAttr(k).IsNull() {
return true
switch {
case value.Type().IsObjectType():
value = value.GetAttr(key)
case value.Type().IsMapType():
value = value.Index(cty.StringVal(key))
// Lists and sets should not be walked down as they are always updated as a whole.
default:
break loop
}

if value.IsNull() {
return true
}
}

return false
}

Expand Down
1 change: 1 addition & 0 deletions routeros/resource_interface_bridge_vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func ResourceInterfaceBridgeVlan() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/interface/bridge/vlan"),
MetaId: PropId(Id),
MetaSkipFields: PropSkipFields(`"debug_info"`),

"bridge": {
Type: schema.TypeString,
Expand Down
Loading

0 comments on commit 6f9db82

Please sign in to comment.