Skip to content

Commit

Permalink
Expose version_id on google_cloudfunctions_function (#9969) (#6968)
Browse files Browse the repository at this point in the history
[upstream:781b533bfe7e9f0bff3cf31eaff212fe7f3c4575]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Feb 14, 2024
1 parent 32a52d0 commit 0cfd1de
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/9969.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Expose version_id on google_cloudfunctions_function
```
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@ func ResourceCloudFunctionsFunction() *schema.Resource {
Computed: true,
Description: `Describes the current stage of a deployment.`,
},
"version_id": {
Type: schema.TypeString,
Computed: true,
Description: `The version identifier of the Cloud Function. Each deployment attempt results in a new version of a function being created.`,
},
},
UseJSONNumber: true,
}
Expand Down Expand Up @@ -788,6 +793,9 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error
if err := d.Set("project", cloudFuncId.Project); err != nil {
return fmt.Errorf("Error setting project: %s", err)
}
if err := d.Set("version_id", strconv.FormatInt(function.VersionId, 10)); err != nil {
return fmt.Errorf("Error setting version_id: %s", err)
}

return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func TestAccCloudFunctionsFunction_basic(t *testing.T) {
"entry_point", "helloGET"),
resource.TestCheckResourceAttr(funcResourceName,
"trigger_http", "true"),
resource.TestCheckResourceAttr(funcResourceName,
"version_id", "1"),
testAccCloudFunctionsFunctionHasLabel("my-label", "my-label-value", &function),
testAccCloudFunctionsFunctionHasEnvironmentVariable("TEST_ENV_VARIABLE",
"test-env-variable-value", &function),
Expand Down Expand Up @@ -111,6 +113,8 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) {
t, funcResourceName, &function),
resource.TestCheckResourceAttr(funcResourceName,
"available_memory_mb", "128"),
resource.TestCheckResourceAttr(funcResourceName,
"version_id", "1"),
testAccCloudFunctionsFunctionHasLabel("my-label", "my-label-value", &function),
),
},
Expand Down Expand Up @@ -139,6 +143,8 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) {
"min_instances", "5"),
resource.TestCheckResourceAttr(funcResourceName,
"ingress_settings", "ALLOW_ALL"),
resource.TestCheckResourceAttr(funcResourceName,
"version_id", "2"),
testAccCloudFunctionsFunctionHasLabel("my-label", "my-updated-label-value", &function),
testAccCloudFunctionsFunctionHasLabel("a-new-label", "a-new-label-value", &function),
testAccCloudFunctionsFunctionHasEnvironmentVariable("TEST_ENV_VARIABLE",
Expand Down

0 comments on commit 0cfd1de

Please sign in to comment.