-
Notifications
You must be signed in to change notification settings - Fork 52
feat(ECS): import ECS resource, unit test and document. #1037
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
Merged
ShiChangkuo
merged 1 commit into
FlexibleEngineCloud:master
from
Zippo-Wang:migrate_ECS-compute_servergroups
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,46 @@ | ||
--- | ||
subcategory: "Elastic Cloud Server (ECS)" | ||
--- | ||
|
||
# flexibleengine_compute_servergroups | ||
|
||
Use this data source to get the list of the compute server groups. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "name" {} | ||
|
||
data "flexibleengine_compute_servergroups" "test" { | ||
name = var.name | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String) Specifies the region in which to obtain the server groups. | ||
If omitted, the provider-level region will be used. | ||
|
||
* `name` - (Optional, String) Specifies the server group name. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The data source ID. | ||
|
||
* `servergroups` - List of ECS server groups details. The [servergroups](#ecs_servergroups) object structure is | ||
documented below. | ||
|
||
<a name="ecs_servergroups"></a> | ||
The `servergroups` block supports: | ||
|
||
* `id` - The server group ID in UUID format. | ||
|
||
* `name` - The server group name. | ||
|
||
* `policies` - The set of policies for the server group. | ||
|
||
* `members` - An array of one or more instance ID attached to the server group. |
46 changes: 46 additions & 0 deletions
46
flexibleengine/acceptance/data_source_flexibleengine_compute_servergroups_test.go
This file contains hidden or 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,46 @@ | ||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
) | ||
|
||
func TestAccComputeServerGroupsDataSource_basic(t *testing.T) { | ||
rName := acceptance.RandomAccResourceNameWithDash() | ||
dataSourceName := "data.flexibleengine_compute_servergroups.test" | ||
dc := acceptance.InitDataSourceCheck(dataSourceName) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccComputeServerGroupsDataSource_basic(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
dc.CheckResourceExists(), | ||
resource.TestCheckResourceAttr(dataSourceName, "name", rName), | ||
resource.TestCheckResourceAttr(dataSourceName, "servergroups.#", "1"), | ||
resource.TestCheckResourceAttrSet(dataSourceName, "servergroups.0.id"), | ||
resource.TestCheckResourceAttrSet(dataSourceName, "servergroups.0.name"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccComputeServerGroupsDataSource_basic(rName string) string { | ||
return fmt.Sprintf(` | ||
resource "flexibleengine_compute_servergroup_v2" "test" { | ||
name = "%s" | ||
policies = ["anti-affinity"] | ||
} | ||
|
||
data "flexibleengine_compute_servergroups" "test" { | ||
name = flexibleengine_compute_servergroup_v2.test.name | ||
} | ||
`, rName) | ||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.