Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(firewall): migrate firewall_rules resource to plugin framework #573

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/terraform-plugin-framework v1.7.0
github.com/hashicorp/terraform-plugin-framework v1.4.1
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-go v0.22.1
github.com/hashicorp/terraform-plugin-go v0.19.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.15.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/terraform-plugin-mux v0.12.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
github.com/minio/minio-go/v7 v7.0.10
github.com/stretchr/testify v1.7.2
gopkg.in/yaml.v3 v3.0.1
Expand Down
18 changes: 10 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,20 @@ github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8J
github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw=
github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U=
github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk=
github.com/hashicorp/terraform-plugin-framework v1.7.0 h1:wOULbVmfONnJo9iq7/q+iBOBJul5vRovaYJIu2cY/Pw=
github.com/hashicorp/terraform-plugin-framework v1.7.0/go.mod h1:jY9Id+3KbZ17OMpulgnWLSfwxNVYSoYBQFTgsx044CI=
github.com/hashicorp/terraform-plugin-framework v1.4.1 h1:ZC29MoB3Nbov6axHdgPbMz7799pT5H8kIrM8YAsaVrs=
github.com/hashicorp/terraform-plugin-framework v1.4.1/go.mod h1:XC0hPcQbBvlbxwmjxuV/8sn8SbZRg4XwGMs22f+kqV0=
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc=
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg=
github.com/hashicorp/terraform-plugin-go v0.22.1 h1:iTS7WHNVrn7uhe3cojtvWWn83cm2Z6ryIUDTRO0EV7w=
github.com/hashicorp/terraform-plugin-go v0.22.1/go.mod h1:qrjnqRghvQ6KnDbB12XeZ4FluclYwptntoWCr9QaXTI=
github.com/hashicorp/terraform-plugin-go v0.19.0 h1:BuZx/6Cp+lkmiG0cOBk6Zps0Cb2tmqQpDM3iAtnhDQU=
github.com/hashicorp/terraform-plugin-go v0.19.0/go.mod h1:EhRSkEPNoylLQntYsk5KrDHTZJh9HQoumZXbOGOXmec=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-plugin-mux v0.15.0 h1:+/+lDx0WUsIOpkAmdwBIoFU8UP9o2eZASoOnLsWbKME=
github.com/hashicorp/terraform-plugin-mux v0.15.0/go.mod h1:9ezplb1Dyq394zQ+ldB0nvy/qbNAz3mMoHHseMTMaKo=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A=
github.com/hashicorp/terraform-plugin-mux v0.11.2 h1:XMkAmWQN+6F+l4jwNeqdPom/8Vly6ZNDxHoKjiRHx5c=
github.com/hashicorp/terraform-plugin-mux v0.11.2/go.mod h1:qjoF/pI49rILSNQzKIuDtU+ZX9mpQD0B8YNE1GceLPc=
github.com/hashicorp/terraform-plugin-mux v0.12.0 h1:TJlmeslQ11WlQtIFAfth0vXx+gSNgvMEng2Rn9z3WZY=
github.com/hashicorp/terraform-plugin-mux v0.12.0/go.mod h1:8MR0AgmV+Q03DIjyrAKxXyYlq2EUnYBQP8gxAAA0zeM=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0 h1:X7vB6vn5tON2b49ILa4W7mFAsndeqJ7bZFOGbVO+0Cc=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0/go.mod h1:ydFcxbdj6klCqYEPkPvdvFKiNGKZLUs+896ODUXCyao=
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Expand Down
560 changes: 279 additions & 281 deletions internal/service/firewall/firewall.go

Large diffs are not rendered by default.

30 changes: 0 additions & 30 deletions internal/service/firewall/firewall_test.go

This file was deleted.

6 changes: 6 additions & 0 deletions internal/service/ip/floating_ip_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ func (r *floatingIPResource) Read(ctx context.Context, req resource.ReadRequest,
return
}

if data.ID.ValueString() == "" {
resp.State.RemoveResource(ctx)

return
}

ip, err := r.client.GetIPAddressDetails(ctx, &request.GetIPAddressDetailsRequest{
Address: data.ID.ValueString(),
})
Expand Down
6 changes: 6 additions & 0 deletions internal/service/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ func (r *networkResource) Read(ctx context.Context, req resource.ReadRequest, re
return
}

if data.ID.ValueString() == "" {
resp.State.RemoveResource(ctx)

return
}

network, err := r.client.GetNetworkDetails(ctx, &request.GetNetworkDetailsRequest{
UUID: data.ID.ValueString(),
})
Expand Down
6 changes: 6 additions & 0 deletions internal/service/networkpeering/networkpeering.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ func (r *networkPeeringResource) Read(ctx context.Context, req resource.ReadRequ
return
}

if data.ID.ValueString() == "" {
resp.State.RemoveResource(ctx)

return
}

peering, err := r.client.GetNetworkPeering(ctx, &request.GetNetworkPeeringRequest{
UUID: data.ID.ValueString(),
})
Expand Down
6 changes: 6 additions & 0 deletions internal/service/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ func (r *routerResource) Read(ctx context.Context, req resource.ReadRequest, res
return
}

if data.ID.ValueString() == "" {
resp.State.RemoveResource(ctx)

return
}

router, err := r.client.GetRouterDetails(ctx, &request.GetRouterDetailsRequest{
UUID: data.ID.ValueString(),
})
Expand Down
2 changes: 2 additions & 0 deletions upcloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/UpCloudLtd/terraform-provider-upcloud/internal/config"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/cloud"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/firewall"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/ip"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/kubernetes"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/managedobjectstorage"
Expand Down Expand Up @@ -143,6 +144,7 @@ func (p *upcloudProvider) Resources(_ context.Context) []func() resource.Resourc
network.NewNetworkResource,
networkpeering.NewNetworkPeeringResource,
router.NewRouterResource,
firewall.NewFirewallRulesResource,
}
}

Expand Down
2 changes: 0 additions & 2 deletions upcloud/sdkv2_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/config"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/cloud"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/database"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/firewall"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/gateway"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/ip"
"github.com/UpCloudLtd/terraform-provider-upcloud/internal/service/kubernetes"
Expand Down Expand Up @@ -76,7 +75,6 @@ func Provider() *schema.Provider {
"upcloud_server": server.ResourceServer(),
"upcloud_server_group": servergroup.ResourceServerGroup(),
"upcloud_storage": storage.ResourceStorage(),
"upcloud_firewall_rules": firewall.ResourceFirewallRules(),
"upcloud_tag": tag.ResourceTag(),
"upcloud_gateway": gateway.ResourceGateway(),
"upcloud_gateway_connection": gateway.ResourceConnection(),
Expand Down
Loading