-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(CodeArts/Deploy): support to get applications
- Loading branch information
Showing
4 changed files
with
517 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
--- | ||
subcategory: "CodeArts Deploy" | ||
layout: "huaweicloud" | ||
page_title: "HuaweiCloud: huaweicloud_codearts_deploy_applications" | ||
description: |- | ||
Use this data source to get the list of CodeArts deploy applications. | ||
--- | ||
|
||
# huaweicloud_codearts_deploy_applications | ||
|
||
Use this data source to get the list of CodeArts deploy applications. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "project_id" {} | ||
data "huaweicloud_codearts_deploy_applications" "test" { | ||
project_id = var.project_id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String) Specifies the region in which to query the resource. If omitted, the provider-level region will be used. | ||
|
||
* `project_id` - (Required, String) Specifies the project ID | ||
|
||
* `group_id` - (Optional, String) Specifies the application group ID. | ||
Enter **no_grouped** to query ungrouped applications. | ||
|
||
* `states` - (Optional, List) Specifies the application status list. | ||
Values can be as follows: | ||
+ **abort**: Deployment suspended. | ||
+ **failed**: Deployment failed. | ||
+ **not_started**: Execution canceled. | ||
+ **pending**: Queuing. | ||
+ **running**: Deployment in progress. | ||
+ **succeeded**: Deployment succeeded. | ||
+ **timeout**: Deployment times out. | ||
+ **not_executed**: Deployment not executed. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The data source ID. | ||
|
||
* `applications` - Indicates the application list | ||
The [applications](#attrblock--applications) structure is documented below. | ||
|
||
<a name="attrblock--applications"></a> | ||
The `applications` block supports: | ||
|
||
* `arrange_infos` - Indicates the deployment task information | ||
The [arrange_infos](#attrblock--applications--arrange_infos) structure is documented below. | ||
|
||
* `id` - Indicates the application ID. | ||
|
||
* `name` - Indicates the application name. | ||
|
||
* `can_copy` - Indicates whether user has permission to clone application. | ||
|
||
* `can_create_env` - Indicates whether user has permission to create environment in application. | ||
|
||
* `can_delete` - Indicates whether user has permission to delete application. | ||
|
||
* `can_disable` - Indicates whether the user has permission to disable application. | ||
|
||
* `can_execute` - Indicates whether user has permission to deploy. | ||
|
||
* `can_manage` - Indicates whether user has permission to modify application permission. | ||
|
||
* `can_modify` - Indicates whether user has permission to modify application. | ||
|
||
* `can_view` - Indicates whether user has permission to view application. | ||
|
||
* `create_tenant_id` - Indicates the created tenant ID. | ||
|
||
* `create_user_id` - Indicates the creator user ID. | ||
|
||
* `created_at` - Indicates the created time. | ||
|
||
* `deploy_system` - Indicates the deployment type. | ||
|
||
* `duration` - Indicates the deployment duration. | ||
|
||
* `end_time` - Indicates the deployment end time. | ||
|
||
* `execution_state` - Indicates the execution status. | ||
|
||
* `execution_time` - Indicates the latest execution time. | ||
|
||
* `executor_id` - Indicates the executor user ID. | ||
|
||
* `executor_nick_name` - Indicates the executor user name. | ||
|
||
* `is_care` - Indicates whether application is saved to favorites. | ||
|
||
* `is_disable` - Indicates whether the application is disabled. | ||
|
||
* `project_name` - Indicates the project name. | ||
|
||
* `release_id` - Indicates the release ID. | ||
|
||
* `updated_at` - Indicates the updated time. | ||
|
||
<a name="attrblock--applications--arrange_infos"></a> | ||
The `arrange_infos` block supports: | ||
|
||
* `deploy_system` - Indicates the deployment task type. | ||
|
||
* `id` - Indicates the task ID. | ||
|
||
* `state` - Indicates the deployment task status. |
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
85 changes: 85 additions & 0 deletions
85
...es/acceptance/codeartsdeploy/data_source_huaweicloud_codearts_deploy_applications_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,85 @@ | ||
package codeartsdeploy | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
) | ||
|
||
func TestAccDataSourceCodeartsDeployApplications_basic(t *testing.T) { | ||
dataSource := "data.huaweicloud_codearts_deploy_applications.test" | ||
rName := acceptance.RandomAccResourceName() | ||
dc := acceptance.InitDataSourceCheck(dataSource) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acceptance.TestAccPreCheck(t) | ||
}, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testDataSourceCodeartsDeployApplications_basic(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
dc.CheckResourceExists(), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.project_name"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.name"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.release_id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.can_modify"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.can_manage"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.can_create_env"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.can_execute"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.can_copy"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.can_delete"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.can_view"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.can_disable"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.is_care"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.is_disable"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.create_user_id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.create_tenant_id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.created_at"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.updated_at"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.arrange_infos.#"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.arrange_infos.0.id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.arrange_infos.0.state"), | ||
resource.TestCheckResourceAttrSet(dataSource, "applications.0.arrange_infos.0.deploy_system"), | ||
|
||
resource.TestCheckOutput("is_state_filter_useful", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testDataSourceCodeartsDeployApplications_basic(name string) string { | ||
return fmt.Sprintf(` | ||
%[1]s | ||
data "huaweicloud_codearts_deploy_applications" "test" { | ||
depends_on = [huaweicloud_codearts_deploy_application.test] | ||
project_id = huaweicloud_codearts_project.test.id | ||
} | ||
// filter by state | ||
data "huaweicloud_codearts_deploy_applications" "filter_by_state" { | ||
depends_on = [huaweicloud_codearts_deploy_application.test] | ||
project_id = huaweicloud_codearts_project.test.id | ||
states = ["not_executed"] | ||
} | ||
locals { | ||
filter_result_by_state = [for v in data.huaweicloud_codearts_deploy_applications.filter_by_state.applications[*].arrange_infos[0].state : | ||
v == "Draft"] | ||
} | ||
output "is_state_filter_useful" { | ||
value = length(local.filter_result_by_state) == 1 && alltrue(local.filter_result_by_state) | ||
} | ||
`, testDeployApplication_basic(name)) | ||
} |
Oops, something went wrong.