Skip to content

Commit db59fd3

Browse files
authored
Add capability related fields to the folder schema (#14601)
1 parent f1d3510 commit db59fd3

5 files changed

Lines changed: 42 additions & 0 deletions

File tree

mmv1/third_party/terraform/services/resourcemanager/data_source_google_folder.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ func DataSourceGoogleFolder() *schema.Resource {
5454
Type: schema.TypeBool,
5555
Computed: true,
5656
},
57+
"configured_capabilities": {
58+
Type: schema.TypeList,
59+
Computed: true,
60+
Elem: &schema.Schema{Type: schema.TypeString},
61+
},
62+
"management_project": {
63+
Type: schema.TypeString,
64+
Computed: true,
65+
},
5766
},
5867
}
5968
}

mmv1/third_party/terraform/services/resourcemanager/resource_google_folder.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ func ResourceGoogleFolder() *schema.Resource {
7878
Elem: &schema.Schema{Type: schema.TypeString},
7979
Description: `A map of resource manager tags. Resource manager tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456. The field is ignored when empty. This field is only set at create time and modifying this field after creation will trigger recreation. To apply tags to an existing resource, see the google_tags_tag_value resource.`,
8080
},
81+
"configured_capabilities": {
82+
Type: schema.TypeList,
83+
Computed: true,
84+
Elem: &schema.Schema{Type: schema.TypeString},
85+
Description: `A list of capabilities that are configured for this folder.`,
86+
},
87+
"management_project": {
88+
Type: schema.TypeString,
89+
Computed: true,
90+
Description: `The Management Project associated with the folder's configured capabilities.`,
91+
},
8192
},
8293
UseJSONNumber: true,
8394
}
@@ -179,6 +190,12 @@ func resourceGoogleFolderRead(d *schema.ResourceData, meta interface{}) error {
179190
if err := d.Set("create_time", folder.CreateTime); err != nil {
180191
return fmt.Errorf("Error setting create_time: %s", err)
181192
}
193+
if err := d.Set("configured_capabilities", folder.ConfiguredCapabilities); err != nil {
194+
return fmt.Errorf("Error setting configured_capabilities: %s", err)
195+
}
196+
if err := d.Set("management_project", folder.ManagementProject); err != nil {
197+
return fmt.Errorf("Error setting management_project: %s", err)
198+
}
182199

183200
return nil
184201
}

mmv1/third_party/terraform/services/resourcemanager3/resource_resource_manager_capability_test.go.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package resourcemanager3_test
33

44
import (
55
"testing"
6+
"regexp"
67

78
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
89

@@ -17,6 +18,7 @@ func TestAccResourceManagerCapability_resourceManagerCapabilityExample_basic(t *
1718
"org_id": envvar.GetTestOrgFromEnv(t),
1819
"random_suffix": acctest.RandString(t, 10),
1920
}
21+
folderTFResourceName := "google_folder.folder"
2022

2123
acctest.VcrTest(t, resource.TestCase{
2224
PreCheck: func() { acctest.AccTestPreCheck(t) },
@@ -28,6 +30,16 @@ func TestAccResourceManagerCapability_resourceManagerCapabilityExample_basic(t *
2830
{
2931
Config: testAccResourceManagerCapability_resourceManagerCapabilityExample_basic(context),
3032
},
33+
{
34+
ResourceName: folderTFResourceName,
35+
ImportState: true,
36+
ImportStateVerify: false,
37+
Check: resource.ComposeTestCheckFunc(
38+
// Checks are now performed on the state *after* the import/refresh.
39+
resource.TestCheckResourceAttr(folderTFResourceName, "configured_capabilities.#", "1"),
40+
resource.TestMatchResourceAttr(folderTFResourceName, "management_project", regexp.MustCompile(".+")),
41+
),
42+
},
3143
{
3244
ResourceName: "google_resource_manager_capability.capability",
3345
ImportState: true,

mmv1/third_party/terraform/website/docs/d/folder.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ The following attributes are exported:
4747
* `create_time` - Timestamp when the Organization was created. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
4848
* `lifecycle_state` - The Folder's current lifecycle state.
4949
* `organization` - If `lookup_organization` is enable, the resource name of the Organization that the folder belongs.
50+
* `configured_capabilities` - Optional capabilities configured for this folder.
51+
* `management_project` - Management Project associated with this folder (if capability is enabled).

mmv1/third_party/terraform/website/docs/r/google_folder.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ exported:
6969
* `lifecycle_state` - The lifecycle state of the folder such as `ACTIVE` or `DELETE_REQUESTED`.
7070
* `create_time` - Timestamp when the Folder was created. Assigned by the server.
7171
A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".
72+
* `configured_capabilities` - Optional capabilities configured for this folder.
73+
* `management_project` - Management Project associated with this folder (if capability is enabled).
7274

7375
## Import
7476

0 commit comments

Comments
 (0)