Skip to content

Commit

Permalink
Support Managed Load Balancer as Resources
Browse files Browse the repository at this point in the history
  • Loading branch information
hico-horiuchi committed May 15, 2024
1 parent e3f6040 commit 066db09
Show file tree
Hide file tree
Showing 77 changed files with 8,365 additions and 164 deletions.
44 changes: 44 additions & 0 deletions ecl/import_ecl_mlb_certificate_v1_mock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package ecl

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"

"github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
)

func TestMockedAccMLBV1CertificateImport(t *testing.T) {
mc := mock.NewMockController()
defer mc.TerminateMockControllerSafety()

postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)

mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "certificates", "/v1.0/certificates", testMockMLBV1CertificatesCreate)
mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08/files", testMockMLBV1CertificatesUploadFileCaCert)
mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08/files", testMockMLBV1CertificatesUploadFileSslCert)
mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08/files", testMockMLBV1CertificatesUploadFileSslKey)
mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesShowAfterCreate)
mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesDelete)
mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesShowAfterDelete)

mc.StartServer(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccMLBV1Certificate,
},
{
ResourceName: "ecl_mlb_certificate_v1.certificate",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"ca_cert", "ssl_cert", "ssl_key"},
},
},
})
}
40 changes: 40 additions & 0 deletions ecl/import_ecl_mlb_health_monitor_v1_mock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ecl

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"

"github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
)

func TestMockedAccMLBV1HealthMonitorImport(t *testing.T) {
mc := mock.NewMockController()
defer mc.TerminateMockControllerSafety()

postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)

mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsCreate)
mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowAfterCreate)
mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsDelete)
mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowAfterDelete)

mc.StartServer(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccMLBV1HealthMonitor,
},
{
ResourceName: "ecl_mlb_health_monitor_v1.health_monitor",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
40 changes: 40 additions & 0 deletions ecl/import_ecl_mlb_listener_v1_mock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ecl

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"

"github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
)

func TestMockedAccMLBV1ListenerImport(t *testing.T) {
mc := mock.NewMockController()
defer mc.TerminateMockControllerSafety()

postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)

mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersCreate)
mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowAfterCreate)
mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersDelete)
mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowAfterDelete)

mc.StartServer(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccMLBV1Listener,
},
{
ResourceName: "ecl_mlb_listener_v1.listener",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
40 changes: 40 additions & 0 deletions ecl/import_ecl_mlb_load_balancer_v1_mock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ecl

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"

"github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
)

func TestMockedAccMLBV1LoadBalancerImport(t *testing.T) {
mc := mock.NewMockController()
defer mc.TerminateMockControllerSafety()

postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)

mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersCreate)
mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterCreate)
mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersDelete)
mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterDelete)

mc.StartServer(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccMLBV1LoadBalancer,
},
{
ResourceName: "ecl_mlb_load_balancer_v1.load_balancer",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
40 changes: 40 additions & 0 deletions ecl/import_ecl_mlb_policy_v1_mock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ecl

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"

"github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
)

func TestMockedAccMLBV1PolicyImport(t *testing.T) {
mc := mock.NewMockController()
defer mc.TerminateMockControllerSafety()

postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)

mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesCreate)
mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowAfterCreate)
mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesDelete)
mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowAfterDelete)

mc.StartServer(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccMLBV1Policy,
},
{
ResourceName: "ecl_mlb_policy_v1.policy",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
40 changes: 40 additions & 0 deletions ecl/import_ecl_mlb_route_v1_mock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ecl

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"

"github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
)

func TestMockedAccMLBV1RouteImport(t *testing.T) {
mc := mock.NewMockController()
defer mc.TerminateMockControllerSafety()

postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)

mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesCreate)
mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowAfterCreate)
mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesDelete)
mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowAfterDelete)

mc.StartServer(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccMLBV1Route,
},
{
ResourceName: "ecl_mlb_route_v1.route",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
40 changes: 40 additions & 0 deletions ecl/import_ecl_mlb_rule_v1_mock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ecl

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"

"github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
)

func TestMockedAccMLBV1RuleImport(t *testing.T) {
mc := mock.NewMockController()
defer mc.TerminateMockControllerSafety()

postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)

mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesCreate)
mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowAfterCreate)
mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesDelete)
mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowAfterDelete)

mc.StartServer(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccMLBV1Rule,
},
{
ResourceName: "ecl_mlb_rule_v1.rule",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
40 changes: 40 additions & 0 deletions ecl/import_ecl_mlb_target_group_v1_mock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ecl

import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/resource"

"github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
)

func TestMockedAccMLBV1TargetGroupImport(t *testing.T) {
mc := mock.NewMockController()
defer mc.TerminateMockControllerSafety()

postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)

mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsCreate)
mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowAfterCreate)
mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsDelete)
mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowAfterDelete)

mc.StartServer(t)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccMLBV1TargetGroup,
},
{
ResourceName: "ecl_mlb_target_group_v1.target_group",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
9 changes: 9 additions & 0 deletions ecl/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ func Provider() terraform.ResourceProvider {
"ecl_imagestorages_image_v2": resourceImageStoragesImageV2(),
"ecl_imagestorages_member_accepter_v2": resourceImageStoragesMemberAccepterV2(),
"ecl_imagestorages_member_v2": resourceImageStoragesMemberV2(),
"ecl_mlb_certificate_v1": resourceMLBCertificateV1(),
"ecl_mlb_health_monitor_v1": resourceMLBHealthMonitorV1(),
"ecl_mlb_listener_v1": resourceMLBListenerV1(),
"ecl_mlb_load_balancer_v1": resourceMLBLoadBalancerV1(),
"ecl_mlb_load_balancer_action_v1": resourceMLBLoadBalancerActionV1(),
"ecl_mlb_policy_v1": resourceMLBPolicyV1(),
"ecl_mlb_route_v1": resourceMLBRouteV1(),
"ecl_mlb_rule_v1": resourceMLBRuleV1(),
"ecl_mlb_target_group_v1": resourceMLBTargetGroupV1(),
"ecl_network_common_function_gateway_v2": resourceNetworkCommonFunctionGatewayV2(),
"ecl_network_gateway_interface_v2": resourceNetworkGatewayInterfaceV2(),
"ecl_network_internet_gateway_v2": resourceNetworkInternetGatewayV2(),
Expand Down
Loading

0 comments on commit 066db09

Please sign in to comment.