-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workspace/warehouse_app): add resource to manage warehouse app
- Loading branch information
1 parent
de71d65
commit abc5287
Showing
5 changed files
with
479 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,110 @@ | ||
--- | ||
subcategory: "Workspace" | ||
layout: "huaweicloud" | ||
page_title: "HuaweiCloud: huaweicloud_workspace_app_warehouse_app" | ||
description: |- | ||
Use this resource to add a application to Workspace APP warehouse within HuaweiCloud. | ||
--- | ||
|
||
# huaweicloud_workspace_app_warehouse_app | ||
|
||
Use this resource to add a application to Workspace APP warehouse within HuaweiCloud. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
var "application_name" {} | ||
var "version" {} | ||
var "version_name" {} | ||
var "file_store_obs_path" {} | ||
resource "huaweicloud_workspace_app_warehouse_app" "test" { | ||
name = var.application_name | ||
category = "OTHER" | ||
os_type = "Windows" | ||
version = var.version | ||
version_name = var.version_name | ||
file_store_path = var.file_store_obs_path | ||
} | ||
``` | ||
|
||
## 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. | ||
|
||
* `name` - (Required, String) The name of the application. | ||
The valid length is limited from `1` to `64`, only Chinese and English characters, digits, underscores (_) and | ||
hyphens (-) are allowed. | ||
|
||
* `category` - (Required, String) The category of the application. | ||
The vaild values are as follows: | ||
+ **GAME** | ||
+ **SECURE_STORAGE** | ||
+ **MULTIMEDIA_AND_CODING** | ||
+ **PROJECT_MANAGEMENT** | ||
+ **PRODUCTIVITY_AND_COLLABORATION** | ||
+ **GRAPHIC_DESIGN** | ||
+ **OTHER** | ||
|
||
* `os_type` - (Required, String) The operating system type of the application. | ||
The valid values are as follows: | ||
+ **Windows** | ||
+ **Linux** | ||
+ **Other** | ||
|
||
* `version` - (Required, String) The version of the application. | ||
The valid length is limited from `1` to `64` and cannot contain spaces. | ||
|
||
* `version_name` - (Required, String) The version name of the application. | ||
The valid length is limited from `1` to `64` and cannot contain spaces. | ||
|
||
* `file_store_path` - (Required, String, ForceNew) The storage path of the OBS bucket where the application is located. | ||
Changing this creates a new resource. | ||
|
||
-> 1.The OBS bucket name where the uploaded file is located must consist of `wks-app` and the project ID, connected by | ||
a hyphen (-). e.g. `wks-app-0970dd7a1300f5672ff2c003c60ae115`.<br>2.The path is the relative path of the file in the | ||
OBS bucket. For example, the relative path of the `https:/xxx.xxx.com/file/workspace_app.exe` file is | ||
`file/workspace_app.exe`.<br>3.Deleting the resource to which this `file_store_path` belongs, the file in the OBS | ||
storage path will also be deleted synchronously. | ||
|
||
* `description` - (Optional, String) The description of the application. | ||
|
||
* `icon` - (Optional, String) The icon of the application. | ||
The valid value ranges from `0` to `10,977`. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The resource ID, also application ID. | ||
|
||
## Import | ||
|
||
The resource can be imported using `id`, e.g. | ||
|
||
```bash | ||
$ terraform import huaweicloud_workspace_app_warehouse_app.test <id> | ||
``` | ||
|
||
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: `icon`. | ||
It is generally recommended running `terraform plan` after importing the resource. | ||
You can then decide if changes should be applied to the instance, or the resource definition should be updated to | ||
align with the instance. Also you can ignore changes as below. | ||
|
||
```hcl | ||
resource "huaweicloud_workspace_app_warehouse_app" "test" { | ||
... | ||
lifecycle { | ||
ignore_changes = [ | ||
icon, | ||
] | ||
} | ||
} | ||
``` |
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
107 changes: 107 additions & 0 deletions
107
...ud/services/acceptance/workspace/resource_huaweicloud_workspace_app_warehouse_app_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,107 @@ | ||
package workspace | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/config" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/workspace" | ||
) | ||
|
||
func getWarehouseApplicationFunc(conf *config.Config, state *terraform.ResourceState) (interface{}, error) { | ||
client, err := conf.NewServiceClient("appstream", acceptance.HW_REGION_NAME) | ||
if err != nil { | ||
return nil, fmt.Errorf("error creating Workspace APP client: %s", err) | ||
} | ||
return workspace.GetWarehouseApplicationById(client, state.Primary.ID) | ||
} | ||
|
||
func TestAccAppWarehouseApp_basic(t *testing.T) { | ||
var ( | ||
application interface{} | ||
resourceName = "huaweicloud_workspace_app_warehouse_app.test" | ||
name = acceptance.RandomAccResourceName() | ||
updateName = acceptance.RandomAccResourceName() | ||
rc = acceptance.InitResourceCheck( | ||
resourceName, | ||
&application, | ||
getWarehouseApplicationFunc, | ||
) | ||
) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acceptance.TestAccPreCheck(t) | ||
acceptance.TestAccPreCheckWorkspaceFileStorePath(t) | ||
}, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
CheckDestroy: rc.CheckResourceDestroy(), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccWarehouseApp_basic_step1(name), | ||
Check: resource.ComposeTestCheckFunc( | ||
rc.CheckResourceExists(), | ||
resource.TestCheckResourceAttr(resourceName, "name", name), | ||
resource.TestCheckResourceAttr(resourceName, "category", "OTHER"), | ||
resource.TestCheckResourceAttr(resourceName, "os_type", "Windows"), | ||
resource.TestCheckResourceAttr(resourceName, "version", "1.0"), | ||
resource.TestCheckResourceAttr(resourceName, "version_name", "terraform"), | ||
resource.TestCheckResourceAttr(resourceName, "file_store_path", acceptance.HW_WORKSPACE_APP_FILE_STRORE_OBS_PATH), | ||
resource.TestCheckResourceAttr(resourceName, "description", "Created by script"), | ||
), | ||
}, | ||
{ | ||
Config: testAccWarehouseApp_basic_step2(updateName), | ||
Check: resource.ComposeTestCheckFunc( | ||
rc.CheckResourceExists(), | ||
resource.TestCheckResourceAttr(resourceName, "name", updateName), | ||
resource.TestCheckResourceAttr(resourceName, "category", "PRODUCTIVITY_AND_COLLABORATION"), | ||
resource.TestCheckResourceAttr(resourceName, "os_type", "Linux"), | ||
resource.TestCheckResourceAttr(resourceName, "version", "2.0"), | ||
resource.TestCheckResourceAttr(resourceName, "version_name", "terraform_update"), | ||
resource.TestCheckResourceAttr(resourceName, "description", "Updated by script"), | ||
), | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{ | ||
"icon", | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccWarehouseApp_basic_step1(name string) string { | ||
return fmt.Sprintf(` | ||
resource "huaweicloud_workspace_app_warehouse_app" "test" { | ||
name = "%[1]s" | ||
category = "OTHER" | ||
os_type = "Windows" | ||
version = "1.0" | ||
version_name = "terraform" | ||
file_store_path = "%[2]s" | ||
description = "Created by script" | ||
} | ||
`, name, acceptance.HW_WORKSPACE_APP_FILE_STRORE_OBS_PATH) | ||
} | ||
|
||
func testAccWarehouseApp_basic_step2(name string) string { | ||
return fmt.Sprintf(` | ||
resource "huaweicloud_workspace_app_warehouse_app" "test" { | ||
name = "%[1]s" | ||
category = "PRODUCTIVITY_AND_COLLABORATION" | ||
os_type = "Linux" | ||
version = "2.0" | ||
version_name = "terraform_update" | ||
file_store_path = "%[2]s" | ||
description = "Updated by script" | ||
} | ||
`, name, acceptance.HW_WORKSPACE_APP_FILE_STRORE_OBS_PATH) | ||
} |
Oops, something went wrong.