Skip to content

Commit

Permalink
Add status output field to google_cloudfunctions_function, update t…
Browse files Browse the repository at this point in the history
…ests for resource and data source. (#7913) (#14574)

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored May 11, 2023
1 parent 45dcc18 commit 5c42d5a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/7913.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
cloudfunctions: added `status` attribute to the `google_cloudfunctions_function` resource and data source
```
2 changes: 2 additions & 0 deletions google/data_source_google_cloudfunctions_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func TestAccDataSourceGoogleCloudFunctionsFunction_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
acctest.CheckDataSourceStateMatchesResourceState(funcDataNameHttp,
"google_cloudfunctions_function.function_http"),
resource.TestCheckResourceAttr(funcDataNameHttp,
"status", "ACTIVE"),
),
},
},
Expand Down
9 changes: 9 additions & 0 deletions google/resource_cloudfunctions_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ func ResourceCloudFunctionsFunction() *schema.Resource {
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: `Describes the current stage of a deployment.`,
},
},
UseJSONNumber: true,
}
Expand Down Expand Up @@ -707,6 +712,10 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Error setting secret_volumes: %s", err)
}

if err := d.Set("status", function.Status); err != nil {
return fmt.Errorf("Error setting status: %s", err)
}

if function.HttpsTrigger != nil {
if err := d.Set("trigger_http", true); err != nil {
return fmt.Errorf("Error setting trigger_http: %s", err)
Expand Down
2 changes: 2 additions & 0 deletions google/resource_cloudfunctions_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ func TestAccCloudFunctionsFunction_basic(t *testing.T) {
"min_instances", "3"),
resource.TestCheckResourceAttr(funcResourceName,
"ingress_settings", "ALLOW_INTERNAL_ONLY"),
resource.TestCheckResourceAttr(funcResourceName,
"status", "ACTIVE"),
testAccCloudFunctionsFunctionSource(fmt.Sprintf("gs://%s/index.zip", bucketName), &function),
testAccCloudFunctionsFunctionTrigger(FUNCTION_TRIGGER_HTTP, &function),
resource.TestCheckResourceAttr(funcResourceName,
Expand Down

0 comments on commit 5c42d5a

Please sign in to comment.