Skip to content

Commit 1296923

Browse files
committed
Update display_text to required for API compatibility and adjust documentation
1 parent ce5a4a3 commit 1296923

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

cloudstack/resource_cloudstack_project.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ func resourceCloudStackProject() *schema.Resource {
4747

4848
"display_text": {
4949
Type: schema.TypeString,
50-
Optional: true,
51-
Computed: true,
50+
Required: true, // Required for API version 4.18 and lower. TODO: Make this optional when support for API versions older than 4.18 is dropped.
5251
},
5352

5453
"domain": {
@@ -81,12 +80,12 @@ func resourceCloudStackProjectCreate(d *schema.ResourceData, meta interface{}) e
8180

8281
// Get the name and display_text
8382
name := d.Get("name").(string)
84-
displaytext := name
85-
if v, ok := d.GetOk("display_text"); ok {
86-
displaytext = v.(string)
87-
}
83+
displaytext := d.Get("display_text").(string)
8884

89-
// The CloudStack API expects displaytext as the first parameter and name as the second
85+
// The CloudStack API parameter order differs between versions:
86+
// - In API 4.18 and lower: displaytext is the first parameter and name is the second
87+
// - In API 4.19 and higher: name is the first parameter and displaytext is optional
88+
// The CloudStack Go SDK uses the API 4.18 parameter order
9089
p := cs.Project.NewCreateProjectParams(displaytext, name)
9190

9291
// Set the domain if provided
@@ -263,6 +262,9 @@ func resourceCloudStackProjectUpdate(d *schema.ResourceData, meta interface{}) e
263262
p := cs.Project.NewUpdateProjectParams(d.Id())
264263

265264
// Set the name and display_text if they have changed
265+
// Note: The 'name' parameter is only available in API 4.19 and higher
266+
// If you're using API 4.18 or lower, the SetName method might not work
267+
// In that case, you might need to update the display_text only
266268
if d.HasChange("name") {
267269
p.SetName(d.Get("name").(string))
268270
}

cloudstack/resource_cloudstack_project_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,4 +388,5 @@ resource "cloudstack_project" "qux" {
388388
const testAccCloudStackProject_emptyDisplayText = `
389389
resource "cloudstack_project" "empty" {
390390
name = "terraform-test-project-empty-display"
391+
display_text = "terraform-test-project-empty-display"
391392
}`

website/docs/r/project.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ resource "cloudstack_project" "myproject" {
3737
The following arguments are supported:
3838

3939
* `name` - (Required) The name of the project.
40-
* `display_text` - (Optional) The display text of the project. Defaults to `name` if not specified.
40+
* `display_text` - (Required) The display text of the project. Required for API version 4.18 and lower compatibility. This requirement will be removed when support for API versions older than 4.18 is dropped.
4141
* `domain` - (Optional) The domain where the project will be created. This cannot be changed after the project is created.
4242
* `account` - (Optional) The account who will be Admin for the project. Requires `domain` to be set. This can be updated after the project is created.
4343
* `accountid` - (Optional) The ID of the account owning the project. This can be updated after the project is created.

0 commit comments

Comments
 (0)