-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CCE] Add possibility to import nodepools (#1082)
[CCE] Add possibility to import nodepools Summary of the Pull Request Add possibility to import resource/opentelekomcloud_cce_node_pool_v3 Closes: #1040 PR Checklist Refers to: #1040 Tests added/passed. Documentation updated. Acceptance Steps Performed Basic === RUN TestAccCCENodePoolsV3_basic --- PASS: TestAccCCENodePoolsV3_basic (832.48s) === RUN TestAccCCENodePoolsV3_randomAZ --- PASS: TestAccCCENodePoolsV3_randomAZ (694.29s) PASS Process finished with the exit code 0 Import === RUN TestAccCCENodePoolV3ImportBasic --- PASS: TestAccCCENodePoolV3ImportBasic (696.66s) PASS Process finished with the exit code 0 Reviewed-by: None <None> Reviewed-by: Irina Pereiaslavskaia <None> Reviewed-by: Polina Gubina <None>
- Loading branch information
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
opentelekomcloud/acceptance/cce/import_opentelekomcloud_cce_node_pool_v3_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/terraform" | ||
"github.com/opentelekomcloud/terraform-provider-opentelekomcloud/opentelekomcloud/acceptance/common" | ||
) | ||
|
||
func TestAccCCENodePoolV3ImportBasic(t *testing.T) { | ||
resourceName := "opentelekomcloud_cce_node_pool_v3.node_pool" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { common.TestAccPreCheck(t) }, | ||
Providers: common.TestAccProviders, | ||
CheckDestroy: testAccCheckCCENodePoolV3Destroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCCENodePoolV3_basic, | ||
}, | ||
|
||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateIdFunc: testAccCCENodePoolV3ImportStateIdFunc(), | ||
ImportStateVerifyIgnore: []string{ | ||
"max_node_count", "min_node_count", "priority", "scale_down_cooldown_time", | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCCENodePoolV3ImportStateIdFunc() resource.ImportStateIdFunc { | ||
return func(s *terraform.State) (string, error) { | ||
var clusterID string | ||
var nodePoolID string | ||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type == "opentelekomcloud_cce_cluster_v3" { | ||
clusterID = rs.Primary.ID | ||
} else if rs.Type == "opentelekomcloud_cce_node_pool_v3" { | ||
nodePoolID = rs.Primary.ID | ||
} | ||
} | ||
if clusterID == "" || nodePoolID == "" { | ||
return "", fmt.Errorf("resource not found: %s/%s", clusterID, nodePoolID) | ||
} | ||
return fmt.Sprintf("%s/%s", clusterID, nodePoolID), nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters