Skip to content

Commit

Permalink
Add debug mode, fix validation of connection_state field of routeros_…
Browse files Browse the repository at this point in the history
…firewall_filter resource, add missing hw_offload field to routeros_firewall_filter resource
  • Loading branch information
Feliksas committed Oct 31, 2022
1 parent 77a41b7 commit b6f0895
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
18 changes: 16 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"context"
"flag"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"github.com/vaerh/terraform-provider-routeros/routeros"
)
Expand All @@ -9,6 +11,18 @@ import (
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: routeros.NewProvider})
var debug bool

flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse()

opts := &plugin.ServeOpts{
ProviderFunc: routeros.NewProvider,
}

if debug {
plugin.Debug(context.Background(), "vaerh/routeros", opts)
} else {
plugin.Serve(opts)
}
}
12 changes: 9 additions & 3 deletions routeros/resource_ip_firewall_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ func ResourceIPFirewallFilter() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Description: "Interprets the connection tracking analysis data for a particular packet.",
ValidateFunc: validation.StringInSlice([]string{
"estabilished", "invalid", "new", "related", "untracked",
}, false),
ValidateFunc: validation.StringMatch(regexp.MustCompile(
"^((established|invalid|new|related|untracked),?)+$"),
"Value must be any of established, invalid, new, related, untracked, or a comma-separated "+
"list of those"),
},
"connection_type": {
Type: schema.TypeString,
Expand Down Expand Up @@ -141,6 +142,11 @@ func ResourceIPFirewallFilter() *schema.Resource {
Description: "Matches packets received from HotSpot clients against various HotSpot matchers.",
ValidateFunc: validation.StringInSlice([]string{"auth", "from-client", "http", "local-dst", "to-client"}, false),
},
"hw_offload": {
Type: schema.TypeBool,
Computed: true,
Description: "Whether or not rule is hardware offloaded",
},
"icmp_options": {
Type: schema.TypeString,
Optional: true,
Expand Down

5 comments on commit b6f0895

@vaerh
Copy link

@vaerh vaerh commented on b6f0895 Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, can I get back the changes to the parent repository?

@Feliksas
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, didn't see Github notifications, sorry :) Yes, of course :)

@vaerh
Copy link

@vaerh vaerh commented on b6f0895 Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The original author and I recently merged the repositories. If you are using the provider at work, change it to https://registry.terraform.io/providers/GNewbury1/routeros/latest/docs

@Feliksas
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I do, but I'd rather stick to my own release for now, though, since connection state validation fix hasn't been adopted in upstream - this makes setting multiple connection states impossible.

@vaerh
Copy link

@vaerh vaerh commented on b6f0895 Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you talking about changes in the handling of firewall connection_state? They were introduced in a slightly different way:
vaerh@bf628b9

Please sign in to comment.