-
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 addons (#1066)
[CCE] Add possibility to import addons Summary of the Pull Request Add possibility to import resource/opentelekomcloud_cce_addon_v3 PR Checklist Refers to: #1056 Tests added/passed. Documentation updated. Schema updated. Acceptance Steps Performed Import === RUN TestAccCCEAddonV3ImportBasic --- PASS: TestAccCCEAddonV3ImportBasic (403.78s) PASS Process finished with the exit code 0 Basic === RUN TestAccCCEAddonV3Basic --- PASS: TestAccCCEAddonV3Basic (353.78s) === RUN TestAccCCEAddonV3ForceNewCCE --- PASS: TestAccCCEAddonV3ForceNewCCE (683.28s) PASS Process finished with the exit code 0 Reviewed-by: None <None> Reviewed-by: Anton Kachurin <katchuring@gmail.com> Reviewed-by: Rodion Gyrbu <fpsoff@outlook.com>
- Loading branch information
Showing
6 changed files
with
133 additions
and
50 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
52 changes: 52 additions & 0 deletions
52
opentelekomcloud/acceptance/cce/import_opentelekomcloud_cce_addon_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,52 @@ | ||
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 TestAccCCEAddonV3ImportBasic(t *testing.T) { | ||
resourceName := "opentelekomcloud_cce_addon_v3.autoscaler" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { common.TestAccPreCheck(t) }, | ||
Providers: common.TestAccProviders, | ||
CheckDestroy: testAccCheckCCEAddonV3Destroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCCEAddonV3Basic, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateIdFunc: testAccCCEAddonV3ImportStateIdFunc(), | ||
ImportStateVerifyIgnore: []string{ | ||
"values", | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCCEAddonV3ImportStateIdFunc() resource.ImportStateIdFunc { | ||
return func(s *terraform.State) (string, error) { | ||
var clusterID string | ||
var addonID string | ||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type == "opentelekomcloud_cce_cluster_v3" { | ||
clusterID = rs.Primary.ID | ||
} else if rs.Type == "opentelekomcloud_cce_addon_v3" { | ||
addonID = rs.Primary.ID | ||
} | ||
} | ||
if clusterID == "" || addonID == "" { | ||
return "", fmt.Errorf("resource not found: %s/%s", clusterID, addonID) | ||
} | ||
return fmt.Sprintf("%s/%s", clusterID, addonID), 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
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
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
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