Skip to content

Commit

Permalink
feat: Add system user settings resource
Browse files Browse the repository at this point in the history
  • Loading branch information
dokmic authored and vaerh committed Jan 5, 2024
1 parent c7cc658 commit f889b7b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/resources/routeros_system_user_settings/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import routeros_system_user_settings.settings .
4 changes: 4 additions & 0 deletions examples/resources/routeros_system_user_settings/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "routeros_system_user_settings" "settings" {
minimum_categories = 2
minimum_password_length = 8
}
17 changes: 9 additions & 8 deletions routeros/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ func Provider() *schema.Provider {
"routeros_wireguard_peer": ResourceInterfaceWireguardPeer(),

// System Objects
"routeros_ip_cloud": ResourceIpCloud(),
"routeros_system_certificate": ResourceSystemCertificate(),
"routeros_system_identity": ResourceSystemIdentity(),
"routeros_system_logging": ResourceSystemLogging(),
"routeros_system_ntp_server": ResourceSystemNtpServer(),
"routeros_system_scheduler": ResourceSystemScheduler(),
"routeros_system_user": ResourceUser(),
"routeros_system_user_group": ResourceUserGroup(),
"routeros_ip_cloud": ResourceIpCloud(),
"routeros_system_certificate": ResourceSystemCertificate(),
"routeros_system_identity": ResourceSystemIdentity(),
"routeros_system_logging": ResourceSystemLogging(),
"routeros_system_ntp_server": ResourceSystemNtpServer(),
"routeros_system_scheduler": ResourceSystemScheduler(),
"routeros_system_user": ResourceUser(),
"routeros_system_user_group": ResourceUserGroup(),
"routeros_system_user_settings": ResourceSystemUserSettings(),

// Aliases for system objects to retain compatibility between original and fork
"routeros_identity": ResourceSystemIdentity(),
Expand Down
49 changes: 49 additions & 0 deletions routeros/resource_system_user_settings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package routeros

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

/*
{
"minimum-categories": "0",
"minimum-password-length": "0"
}
*/

// https://help.mikrotik.com/docs/display/ROS/User#User-UserSettings
func ResourceSystemUserSettings() *schema.Resource {
resSchema := map[string]*schema.Schema{
MetaResourcePath: PropResourcePath("/user/settings"),
MetaId: PropId(Id),

"minimum_categories": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
Description: "An option specifies the complexity requirements of the password, with categories being uppercase, lowercase, digit, and symbol.",
ValidateFunc: validation.IntBetween(0, 4),
},
"minimum_password_length": {
Type: schema.TypeInt,
Optional: true,
Default: 0,
Description: "An option specifies the minimum length of the password.",
ValidateFunc: validation.IntAtLeast(0),
},
}

return &schema.Resource{
CreateContext: DefaultSystemCreate(resSchema),
ReadContext: DefaultSystemRead(resSchema),
UpdateContext: DefaultSystemUpdate(resSchema),
DeleteContext: DefaultSystemDelete(resSchema),

Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},

Schema: resSchema,
}
}

0 comments on commit f889b7b

Please sign in to comment.