Skip to content

Commit

Permalink
Fix devops instance
Browse files Browse the repository at this point in the history
  • Loading branch information
SogoKato committed Jul 19, 2024
1 parent 2415138 commit 876b6af
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 57 deletions.
10 changes: 10 additions & 0 deletions nifcloud/acc/devops_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func TestAcc_DevOpsInstance(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "disk_size", "100"),
resource.TestCheckResourceAttr(resourceName, "availability_zone", "east-14"),
resource.TestCheckResourceAttr(resourceName, "description", "tfacc-memo"),
resource.TestCheckResourceAttr(resourceName, "to", "[email protected]"),
resource.TestCheckResourceAttr(resourceName, "gitlab_url", "https://"+randName+".jp-east-1.gitlab.devops.nifcloud.com"),
resource.TestCheckResourceAttr(resourceName, "registry_url", "https://registry-"+randName+".jp-east-1.gitlab.devops.nifcloud.com"),
),
Expand All @@ -65,6 +66,7 @@ func TestAcc_DevOpsInstance(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "disk_size", "300"),
resource.TestCheckResourceAttr(resourceName, "availability_zone", "east-14"),
resource.TestCheckResourceAttr(resourceName, "description", "tfacc-memo-upd"),
resource.TestCheckResourceAttr(resourceName, "to", "[email protected]"),
resource.TestCheckResourceAttr(resourceName, "gitlab_url", "https://"+randName+".jp-east-1.gitlab.devops.nifcloud.com"),
resource.TestCheckResourceAttr(resourceName, "registry_url", "https://registry-"+randName+".jp-east-1.gitlab.devops.nifcloud.com"),
),
Expand Down Expand Up @@ -152,6 +154,10 @@ func testAccCheckDevOpsInstanceValues(instance *types.Instance, rName string) re
return fmt.Errorf("bad description state, expected \"tfacc-memo\", got: %#v", nifcloud.ToString(instance.Description))
}

if nifcloud.ToString(instance.To) != "[email protected]" {
return fmt.Errorf("bad to state, expected \"[email protected]\", got: %#v", nifcloud.ToString(instance.To))
}

if nifcloud.ToString(instance.GitlabUrl) != "https://"+rName+".jp-east-1.gitlab.devops.nifcloud.com" {
return fmt.Errorf("bad gitlab_url state, expected \"https://%s.jp-east-1.gitlab.devops.nifcloud.com\", got: %#v", rName, nifcloud.ToString(instance.GitlabUrl))
}
Expand Down Expand Up @@ -194,6 +200,10 @@ func testAccCheckDevOpsInstanceValuesUpdated(instance *types.Instance, rName str
return fmt.Errorf("bad description state, expected \"tfacc-memo-upd\", got: %#v", nifcloud.ToString(instance.Description))
}

if nifcloud.ToString(instance.To) != "[email protected]" {
return fmt.Errorf("bad to state, expected \"[email protected]\", got: %#v", nifcloud.ToString(instance.To))
}

if nifcloud.ToString(instance.GitlabUrl) != "https://"+rName+".jp-east-1.gitlab.devops.nifcloud.com" {
return fmt.Errorf("bad gitlab_url state, expected \"https://%s.jp-east-1.gitlab.devops.nifcloud.com\", got: %#v", rName, nifcloud.ToString(instance.GitlabUrl))
}
Expand Down
2 changes: 1 addition & 1 deletion nifcloud/acc/testdata/devops_instance_update.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "nifcloud_devops_instance" "basic" {
availability_zone = "east-14"
description = "tfacc-memo-upd"
initial_root_password = "initialroo00ootpassword"
to = "[email protected]"
to = "email-upd@example.com"
}

resource "nifcloud_devops_firewall_group" "basic" {
Expand Down
74 changes: 37 additions & 37 deletions nifcloud/resources/devops/devopsinstance/expander_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ func TestExpandCreateInstanceInput(t *testing.T) {
rd := schema.TestResourceDataRaw(t, newSchema(), map[string]interface{}{
"instance_id": "test_id",
"instance_type": "c-large",
"firewall_group_name": "test_name",
"parameter_group_name": "test_name",
"firewall_group_name": "test_name_fg",
"parameter_group_name": "test_name_pg",
"disk_size": 100,
"availability_zone": "east-11",
"description": "test_description",
"initial_root_password": "test_password",
"network_id": "test_id",
"network_id": "test_id_nw",
"private_address": "192.168.1.1/24",
"object_storage_account": "test_account",
"object_storage_region": "test_region",
"lfs_bucket_name": "test_name",
"packages_bucket_name": "test_name",
"container_registry_bucket_name": "test_name",
"lfs_bucket_name": "test_name_lfs",
"packages_bucket_name": "test_name_pkg",
"container_registry_bucket_name": "test_name_cr",
"to": "[email protected]",
})

Expand All @@ -41,23 +41,23 @@ func TestExpandCreateInstanceInput(t *testing.T) {
want: &devops.CreateInstanceInput{
InstanceId: nifcloud.String("test_id"),
InstanceType: types.InstanceTypeOfCreateInstanceRequest("c-large"),
FirewallGroupName: nifcloud.String("test_name"),
ParameterGroupName: nifcloud.String("test_name"),
FirewallGroupName: nifcloud.String("test_name_fg"),
ParameterGroupName: nifcloud.String("test_name_pg"),
DiskSize: nifcloud.Int32(int32(100)),
AvailabilityZone: types.AvailabilityZoneOfCreateInstanceRequest("east-11"),
Description: nifcloud.String("test_description"),
InitialRootPassword: nifcloud.String("test_password"),
NetworkConfig: &types.RequestNetworkConfig{
NetworkId: nifcloud.String("test_id"),
NetworkId: nifcloud.String("test_id_nw"),
PrivateAddress: nifcloud.String("192.168.1.1/24"),
},
ObjectStorageConfig: &types.RequestObjectStorageConfig{
Account: nifcloud.String("test_account"),
Region: types.RegionOfobjectStorageConfigForCreateInstance("test_region"),
RequestBucketUseObjects: &types.RequestBucketUseObjects{
Lfs: nifcloud.String("test_name"),
Packages: nifcloud.String("test_name"),
ContainerRegistry: nifcloud.String("test_name"),
Lfs: nifcloud.String("test_name_lfs"),
Packages: nifcloud.String("test_name_pkg"),
ContainerRegistry: nifcloud.String("test_name_cr"),
},
},
},
Expand All @@ -76,19 +76,19 @@ func TestExpandUpdateInstanceInput(t *testing.T) {
rd := schema.TestResourceDataRaw(t, newSchema(), map[string]interface{}{
"instance_id": "test_id",
"instance_type": "c-large",
"firewall_group_name": "test_name",
"parameter_group_name": "test_name",
"firewall_group_name": "test_name_fg",
"parameter_group_name": "test_name_pg",
"disk_size": 100,
"availability_zone": "east-11",
"description": "test_description",
"initial_root_password": "test_password",
"network_id": "test_id",
"network_id": "test_id_nw",
"private_address": "192.168.1.1/24",
"object_storage_account": "test_account",
"object_storage_region": "test_region",
"lfs_bucket_name": "test_name",
"packages_bucket_name": "test_name",
"container_registry_bucket_name": "test_name",
"lfs_bucket_name": "test_name_lfs",
"packages_bucket_name": "test_name_pkg",
"container_registry_bucket_name": "test_name_cr",
"to": "[email protected]",
})
rd.SetId("test_id")
Expand All @@ -104,7 +104,7 @@ func TestExpandUpdateInstanceInput(t *testing.T) {
want: &devops.UpdateInstanceInput{
InstanceId: nifcloud.String("test_id"),
InstanceType: types.InstanceTypeOfUpdateInstanceRequest("c-large"),
FirewallGroupName: nifcloud.String("test_name"),
FirewallGroupName: nifcloud.String("test_name_fg"),
Description: nifcloud.String("test_description"),
},
},
Expand Down Expand Up @@ -200,19 +200,19 @@ func TestExpandSetupAlertInput(t *testing.T) {
rd := schema.TestResourceDataRaw(t, newSchema(), map[string]interface{}{
"instance_id": "test_id",
"instance_type": "c-large",
"firewall_group_name": "test_name",
"parameter_group_name": "test_name",
"firewall_group_name": "test_name_fg",
"parameter_group_name": "test_name_pg",
"disk_size": 100,
"availability_zone": "east-11",
"description": "test_description",
"initial_root_password": "test_password",
"network_id": "test_id",
"network_id": "test_id_nw",
"private_address": "192.168.1.1/24",
"object_storage_account": "test_account",
"object_storage_region": "test_region",
"lfs_bucket_name": "test_name",
"packages_bucket_name": "test_name",
"container_registry_bucket_name": "test_name",
"lfs_bucket_name": "test_name_lfs",
"packages_bucket_name": "test_name_pkg",
"container_registry_bucket_name": "test_name_cr",
"to": "[email protected]",
})
rd.SetId("test_id")
Expand Down Expand Up @@ -244,37 +244,37 @@ func TestExpandUpdateNetworkInterfaceInput(t *testing.T) {
rd := schema.TestResourceDataRaw(t, newSchema(), map[string]interface{}{
"instance_id": "test_id",
"instance_type": "c-large",
"firewall_group_name": "test_name",
"parameter_group_name": "test_name",
"firewall_group_name": "test_name_fg",
"parameter_group_name": "test_name_pg",
"disk_size": 100,
"availability_zone": "east-11",
"description": "test_description",
"initial_root_password": "test_password",
"network_id": "test_id",
"network_id": "test_id_nw",
"private_address": "192.168.1.1/24",
"object_storage_account": "test_account",
"object_storage_region": "test_region",
"lfs_bucket_name": "test_name",
"packages_bucket_name": "test_name",
"container_registry_bucket_name": "test_name",
"lfs_bucket_name": "test_name_lfs",
"packages_bucket_name": "test_name_pkg",
"container_registry_bucket_name": "test_name_cr",
"to": "[email protected]",
})
rd.SetId("test_id")

noNetworkConfigRd := schema.TestResourceDataRaw(t, newSchema(), map[string]interface{}{
"instance_id": "test_id",
"instance_type": "c-large",
"firewall_group_name": "test_name",
"parameter_group_name": "test_name",
"firewall_group_name": "test_name_fg",
"parameter_group_name": "test_name_pg",
"disk_size": 100,
"availability_zone": "east-11",
"description": "test_description",
"initial_root_password": "test_password",
"object_storage_account": "test_account",
"object_storage_region": "test_region",
"lfs_bucket_name": "test_name",
"packages_bucket_name": "test_name",
"container_registry_bucket_name": "test_name",
"lfs_bucket_name": "test_name_lfs",
"packages_bucket_name": "test_name_pkg",
"container_registry_bucket_name": "test_name_cr",
"to": "[email protected]",
})
noNetworkConfigRd.SetId("test_id")
Expand All @@ -290,7 +290,7 @@ func TestExpandUpdateNetworkInterfaceInput(t *testing.T) {
want: &devops.UpdateNetworkInterfaceInput{
InstanceId: nifcloud.String("test_id"),
NetworkConfig: &types.RequestNetworkConfig{
NetworkId: nifcloud.String("test_id"),
NetworkId: nifcloud.String("test_id_nw"),
PrivateAddress: nifcloud.String("192.168.1.1/24"),
},
},
Expand Down
32 changes: 16 additions & 16 deletions nifcloud/resources/devops/devopsinstance/flattener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ func TestFlatten(t *testing.T) {
wantRd := schema.TestResourceDataRaw(t, newSchema(), map[string]interface{}{
"instance_id": "test_id",
"instance_type": "c-large",
"firewall_group_name": "test_name",
"parameter_group_name": "test_name",
"firewall_group_name": "test_name_fg",
"parameter_group_name": "test_name_pg",
"disk_size": 100,
"availability_zone": "east-11",
"description": "test_description",
"network_id": "test_id",
"network_id": "test_id_nw",
"private_address": "192.168.1.1/24",
"gitlab_url": "test_url",
"registry_url": "test_url",
"gitlab_url": "test_url_gl",
"registry_url": "test_url_cr",
"public_ip_address": "198.51.100.1",
"object_storage_account": "test_account",
"object_storage_region": "test_region",
"lfs_bucket_name": "test_name",
"packages_bucket_name": "test_name",
"container_registry_bucket_name": "test_name",
"lfs_bucket_name": "test_name_lfs",
"packages_bucket_name": "test_name_pkg",
"container_registry_bucket_name": "test_name_cr",
"to": "[email protected]",
})
wantRd.SetId("test_id")
Expand All @@ -55,27 +55,27 @@ func TestFlatten(t *testing.T) {
Instance: &types.Instance{
InstanceId: nifcloud.String("test_id"),
InstanceType: nifcloud.String("c-large"),
FirewallGroupName: nifcloud.String("test_name"),
ParameterGroupName: nifcloud.String("test_name"),
FirewallGroupName: nifcloud.String("test_name_fg"),
ParameterGroupName: nifcloud.String("test_name_pg"),
DiskSize: nifcloud.Int32(int32(100)),
AvailabilityZone: nifcloud.String("east-11"),
Description: nifcloud.String("test_description"),
NetworkConfig: &types.NetworkConfig{
NetworkId: nifcloud.String("test_id"),
NetworkId: nifcloud.String("test_id_nw"),
PrivateAddress: nifcloud.String("192.168.1.1/24"),
},
ObjectStorageConfig: &types.ObjectStorageConfig{
Account: nifcloud.String("test_account"),
Region: nifcloud.String("test_region"),
BucketUseObjects: &types.BucketUseObjects{
Lfs: nifcloud.String("test_name"),
Packages: nifcloud.String("test_name"),
ContainerRegistry: nifcloud.String("test_name"),
Lfs: nifcloud.String("test_name_lfs"),
Packages: nifcloud.String("test_name_pkg"),
ContainerRegistry: nifcloud.String("test_name_cr"),
},
},
To: nifcloud.String("[email protected]"),
GitlabUrl: nifcloud.String("test_url"),
RegistryUrl: nifcloud.String("test_url"),
GitlabUrl: nifcloud.String("test_url_gl"),
RegistryUrl: nifcloud.String("test_url_cr"),
PublicIpAddress: nifcloud.String("198.51.100.1"),
},
},
Expand Down
6 changes: 3 additions & 3 deletions nifcloud/resources/devops/devopsinstance/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func New() *schema.Resource {
},
Timeouts: &schema.ResourceTimeout{
Default: schema.DefaultTimeout(5 * time.Minute),
Create: schema.DefaultTimeout(120 * time.Minute),
Update: schema.DefaultTimeout(120 * time.Minute),
Delete: schema.DefaultTimeout(60 * time.Minute),
Create: schema.DefaultTimeout(80 * time.Minute),
Update: schema.DefaultTimeout(80 * time.Minute),
Delete: schema.DefaultTimeout(30 * time.Minute),
},
CustomizeDiff: customdiff.ValidateChange(
"disk_size",
Expand Down

0 comments on commit 876b6af

Please sign in to comment.