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

Fix Snat Rule issue #291

Merged
merged 1 commit into from
Apr 2, 2020
Merged
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require (
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/terraform-plugin-sdk v1.0.0
github.com/huaweicloud/golangsdk v0.0.0-20200328014419-a05ff47ddef2
github.com/huaweicloud/golangsdk v0.0.0-20200401094148-31fa13f7c58c
github.com/jen20/awspolicyequivalence v0.0.0-20170831201602-3d48364a137a
github.com/mitchellh/go-homedir v1.1.0
github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKe
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huaweicloud/golangsdk v0.0.0-20200323070305-98b64a3f37ba h1:eTQZkCooySmxShTy8boiZ69ueUNNNRxBWjt9T35sp8c=
github.com/huaweicloud/golangsdk v0.0.0-20200323070305-98b64a3f37ba/go.mod h1:WQBcHRNX9shz3928lWEvstQJtAtYI7ks6XlgtRT9Tcw=
github.com/huaweicloud/golangsdk v0.0.0-20200328014419-a05ff47ddef2 h1:DYqiW7KEFU0tZlhn2/yQIPlXxjdf72bDM7xqdoFzFgE=
github.com/huaweicloud/golangsdk v0.0.0-20200328014419-a05ff47ddef2/go.mod h1:WQBcHRNX9shz3928lWEvstQJtAtYI7ks6XlgtRT9Tcw=
github.com/huaweicloud/golangsdk v0.0.0-20200401094148-31fa13f7c58c h1:bzJdiQ+UuJ2/91iSsv+cFfVrLdwETLkawm1ZxE9yYT4=
github.com/huaweicloud/golangsdk v0.0.0-20200401094148-31fa13f7c58c/go.mod h1:WQBcHRNX9shz3928lWEvstQJtAtYI7ks6XlgtRT9Tcw=
github.com/jen20/awspolicyequivalence v0.0.0-20170831201602-3d48364a137a h1:FyS/ubzBR5xJlnJGRTwe7GUHpJOR4ukYK3y+LFNffuA=
github.com/jen20/awspolicyequivalence v0.0.0-20170831201602-3d48364a137a/go.mod h1:uoIMjNxUfXi48Ci40IXkPRbghZ1vbti6v9LCbNqRgHY=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down
14 changes: 7 additions & 7 deletions huaweicloud/resource_huaweicloud_nat_snat_rule_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"

"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/snatrules"
"github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/hw_snatrules"
)

func resourceNatSnatRuleV2() *schema.Resource {
Expand Down Expand Up @@ -57,14 +57,14 @@ func resourceNatSnatRuleV2Create(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Error creating HuaweiCloud nat client: %s", err)
}

createOpts := &snatrules.CreateOpts{
createOpts := &hw_snatrules.CreateOpts{
NatGatewayID: d.Get("nat_gateway_id").(string),
NetworkID: d.Get("network_id").(string),
FloatingIPID: d.Get("floating_ip_id").(string),
}

log.Printf("[DEBUG] Create Options: %#v", createOpts)
snatRule, err := snatrules.Create(natV2Client, createOpts).Extract()
snatRule, err := hw_snatrules.Create(natV2Client, createOpts).Extract()
if err != nil {
return fmt.Errorf("Error creatting Snat Rule: %s", err)
}
Expand Down Expand Up @@ -96,7 +96,7 @@ func resourceNatSnatRuleV2Read(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error creating HuaweiCloud nat client: %s", err)
}

snatRule, err := snatrules.Get(natV2Client, d.Id()).Extract()
snatRule, err := hw_snatrules.Get(natV2Client, d.Id()).Extract()
if err != nil {
return CheckDeleted(d, err, "Snat Rule")
}
Expand Down Expand Up @@ -137,7 +137,7 @@ func resourceNatSnatRuleV2Delete(d *schema.ResourceData, meta interface{}) error

func waitForSnatRuleActive(natV2Client *golangsdk.ServiceClient, nId string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
n, err := snatrules.Get(natV2Client, nId).Extract()
n, err := hw_snatrules.Get(natV2Client, nId).Extract()
if err != nil {
return nil, "", err
}
Expand All @@ -155,7 +155,7 @@ func waitForSnatRuleDelete(natV2Client *golangsdk.ServiceClient, nId string) res
return func() (interface{}, string, error) {
log.Printf("[DEBUG] Attempting to delete HuaweiCloud Snat Rule %s.\n", nId)

n, err := snatrules.Get(natV2Client, nId).Extract()
n, err := hw_snatrules.Get(natV2Client, nId).Extract()
if err != nil {
if _, ok := err.(golangsdk.ErrDefault404); ok {
log.Printf("[DEBUG] Successfully deleted HuaweiCloud Snat Rule %s", nId)
Expand All @@ -164,7 +164,7 @@ func waitForSnatRuleDelete(natV2Client *golangsdk.ServiceClient, nId string) res
return n, "ACTIVE", err
}

err = snatrules.Delete(natV2Client, nId).ExtractErr()
err = hw_snatrules.Delete(natV2Client, nId).ExtractErr()
if err != nil {
if _, ok := err.(golangsdk.ErrDefault404); ok {
log.Printf("[DEBUG] Successfully deleted HuaweiCloud Snat Rule %s", nId)
Expand Down
6 changes: 3 additions & 3 deletions huaweicloud/resource_huaweicloud_nat_snat_rule_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"

"github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/hw_snatrules"
"github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/layer3/floatingips"
"github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/layer3/routers"
"github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/snatrules"
"github.com/huaweicloud/golangsdk/openstack/networking/v2/networks"
"github.com/huaweicloud/golangsdk/openstack/networking/v2/subnets"
)
Expand Down Expand Up @@ -53,7 +53,7 @@ func testAccCheckNatV2SnatRuleDestroy(s *terraform.State) error {
continue
}

_, err := snatrules.Get(natClient, rs.Primary.ID).Extract()
_, err := hw_snatrules.Get(natClient, rs.Primary.ID).Extract()
if err == nil {
return fmt.Errorf("Snat rule still exists")
}
Expand All @@ -79,7 +79,7 @@ func testAccCheckNatV2SnatRuleExists(n string) resource.TestCheckFunc {
return fmt.Errorf("Error creating HuaweiCloud nat client: %s", err)
}

found, err := snatrules.Get(natClient, rs.Primary.ID).Extract()
found, err := hw_snatrules.Get(natClient, rs.Primary.ID).Extract()
if err != nil {
return err
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ github.com/hashicorp/terraform-plugin-sdk/internal/svchost
github.com/hashicorp/terraform-plugin-sdk/internal/svchost/auth
# github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d
github.com/hashicorp/yamux
# github.com/huaweicloud/golangsdk v0.0.0-20200328014419-a05ff47ddef2
# github.com/huaweicloud/golangsdk v0.0.0-20200401094148-31fa13f7c58c
github.com/huaweicloud/golangsdk
github.com/huaweicloud/golangsdk/openstack
github.com/huaweicloud/golangsdk/openstack/antiddos/v1/antiddos
Expand Down Expand Up @@ -256,6 +256,7 @@ github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/fwaas_v2/fir
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/fwaas_v2/policies
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/fwaas_v2/routerinsertion
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/fwaas_v2/rules
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/hw_snatrules
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/layer3/floatingips
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/layer3/routers
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/lbaas_v2/certificates
Expand All @@ -269,7 +270,6 @@ github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/natgateways
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/provider
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/security/groups
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/security/rules
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/snatrules
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/vpnaas/endpointgroups
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/vpnaas/ikepolicies
github.com/huaweicloud/golangsdk/openstack/networking/v2/extensions/vpnaas/ipsecpolicies
Expand Down