-
Notifications
You must be signed in to change notification settings - Fork 165
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 deploy app and get deployment records
- Loading branch information
Showing
11 changed files
with
861 additions
and
9 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
docs/data-sources/codearts_deploy_application_deployment_records.md
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,70 @@ | ||
--- | ||
subcategory: "CodeArts Deploy" | ||
layout: "huaweicloud" | ||
page_title: "HuaweiCloud: huaweicloud_codearts_deploy_application_deployment_records" | ||
description: |- | ||
Use this data source to get the list of CodeArts deploy application deployment records. | ||
--- | ||
|
||
# huaweicloud_codearts_deploy_application_deployment_records | ||
|
||
Use this data source to get the list of CodeArts deploy application deployment records. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "project_id" {} | ||
variable "task_id" {} | ||
variable "start_date" {} | ||
variable "end_date" {} | ||
data "huaweicloud_codearts_deploy_application_deployment_records" "test" { | ||
project_id = var.project_id | ||
task_id = var.task_id | ||
start_date = var.start_date | ||
end_date = var.end_date | ||
} | ||
``` | ||
|
||
## 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 for CodeArts service. | ||
|
||
* `task_id` - (Required, String) Specifies the deployment task ID. | ||
|
||
* `start_date` - (Required, String) Specifies the start time. The value format is **yyyy-mm-dd**. | ||
|
||
* `end_date` - (Required, String) Specifies the end time. The value format is **yyyy-mm-dd**. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The data source ID. | ||
|
||
* `records` - Indicates the record list. | ||
The [records](#attrblock--records) structure is documented below. | ||
|
||
<a name="attrblock--records"></a> | ||
The `records` block supports: | ||
|
||
* `id` - Indicates the record ID. | ||
|
||
* `duration` - Indicates the deployment duration. | ||
|
||
* `operator` - Indicates the operator user name. | ||
|
||
* `release_id` - Indicates the deployment record sequence number. | ||
|
||
* `state` - Indicates the application status. | ||
|
||
* `start_time` - Indicates the start time of application deployment. The value format is **yyyy-mm-dd hh:mm:ss**. | ||
|
||
* `end_time` - Indicates the end time of application deployment. The value format is **yyyy-mm-dd hh:mm:ss**. | ||
|
||
* `type` - Indicates the deployment type. |
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,94 @@ | ||
--- | ||
subcategory: "CodeArts Deploy" | ||
layout: "huaweicloud" | ||
page_title: "HuaweiCloud: huaweicloud_codearts_deploy_application_deploy" | ||
description: |- | ||
Manages a CodeArts deploy application deploy resource within HuaweiCloud. | ||
--- | ||
|
||
# huaweicloud_codearts_deploy_application_deploy | ||
|
||
Manages a CodeArts deploy application deploy resource within HuaweiCloud. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "task_id" {} | ||
resource "huaweicloud_codearts_deploy_application_deploy" "test" { | ||
task_id = var.task_id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String, ForceNew) Specifies the region in which to create the resource. | ||
If omitted, the provider-level region will be used. | ||
Changing this creates a new resource. | ||
|
||
* `task_id` - (Required, String, ForceNew) Specifies the deployment task ID. | ||
Changing this creates a new resource. | ||
|
||
* `params` - (Optional, List, ForceNew) Specifies the parameters transferred during application deployment. | ||
Changing this creates a new resource. | ||
The [params](#block--params) structure is documented below. | ||
|
||
* `record_id` - (Optional, String, ForceNew) Specifies the deployment record ID of an application. Specifies it to roll | ||
back the application to the previous deployment status. | ||
Changing this creates a new resource. | ||
|
||
* `trigger_source` - (Optional, String, ForceNew) Specifies the trigger source. | ||
Valid values are as follows: | ||
+ **0**: Deployment can be triggered through all requests. | ||
+ **1**: Deployment can be triggered only through pipeline. | ||
|
||
Changing this creates a new resource. | ||
|
||
<a name="block--params"></a> | ||
The `params` block supports: | ||
|
||
* `name` - (Optional, String, ForceNew) Specifies the parameter name transferred when deploying application. | ||
Changing this creates a new resource. | ||
|
||
* `type` - (Optional, String, ForceNew) Specifies the parameter type. If a dynamic parameter is set, the type is mandatory. | ||
Changing this creates a new resource. | ||
|
||
* `value` - (Optional, String, ForceNew) Specifies the parameter value transferred during application deployment. | ||
Changing this creates a new resource. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The resource ID. | ||
|
||
## Import | ||
|
||
The application deployment record can be imported using `task_id`, and `id`, separated by a slash, e.g. | ||
|
||
```bash | ||
$ terraform import huaweicloud_codearts_deploy_application_deploy.test <task_id>/<id> | ||
``` | ||
|
||
Please add the followings if some attributes are missing when importing the resource. | ||
|
||
Note that the imported state may not be identical to your resource definition, due to some attributes missing from the | ||
API response, security or some other reason. | ||
The missing attributes include: `params`, `record_id` and `trigger_source`. | ||
It is generally recommended running `terraform plan` after importing the resource. | ||
You can then decide if changes should be applied to the deployment record, or the resource definition should be updated to | ||
align with the deployment record. Also you can ignore changes as below. | ||
|
||
```hcl | ||
resource "huaweicloud_codearts_deploy_application_deploy" "test" { | ||
... | ||
lifecycle { | ||
ignore_changes = [ | ||
params, record_id, trigger_source, | ||
] | ||
} | ||
} | ||
``` |
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
58 changes: 58 additions & 0 deletions
58
...artsdeploy/data_source_huaweicloud_codearts_deploy_application_deployment_records_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,58 @@ | ||
package codeartsdeploy | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
) | ||
|
||
func TestAccDataSourceCodeartsDeployApplicationDeploymentRecords_basic(t *testing.T) { | ||
dataSource := "data.huaweicloud_codearts_deploy_application_deployment_records.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: testDataSourceCodeartsDeployApplicationDeploymentRecords_basic(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
dc.CheckResourceExists(), | ||
resource.TestCheckResourceAttr(dataSource, "records.#", "1"), | ||
resource.TestCheckResourceAttrSet(dataSource, "records.0.id"), | ||
resource.TestCheckResourceAttrSet(dataSource, "records.0.start_time"), | ||
resource.TestCheckResourceAttrSet(dataSource, "records.0.end_time"), | ||
resource.TestCheckResourceAttrSet(dataSource, "records.0.duration"), | ||
resource.TestCheckResourceAttrSet(dataSource, "records.0.state"), | ||
resource.TestCheckResourceAttrSet(dataSource, "records.0.operator"), | ||
resource.TestCheckResourceAttrSet(dataSource, "records.0.release_id"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testDataSourceCodeartsDeployApplicationDeploymentRecords_basic(name string) string { | ||
date := strings.Split(time.Now().Format("2006-01-02T15:04:05Z"), "T")[0] | ||
|
||
return fmt.Sprintf(` | ||
%[1]s | ||
data "huaweicloud_codearts_deploy_application_deployment_records" "test" { | ||
depends_on = [huaweicloud_codearts_deploy_application_deploy.test] | ||
project_id = huaweicloud_codearts_project.test.id | ||
task_id = huaweicloud_codearts_deploy_application.test.task_id | ||
start_date = "%[2]s" | ||
end_date = "%[2]s" | ||
} | ||
`, testAccDeployApplicationDeploy_basic(name), date) | ||
} |
Oops, something went wrong.