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. (GoogleCloudPlatform#7913)
  • Loading branch information
SarahFrench authored and ericayyliu committed Jul 26, 2023
1 parent 4cc7766 commit 930d5ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,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 Expand Up @@ -390,7 +392,6 @@ func TestAccCloudFunctionsFunction_buildworkerpool(t *testing.T) {
zipFilePath := createZIPArchiveForCloudFunctionSource(t, testHTTPTriggerPath)
proj := acctest.GetTestProjectFromEnv()


defer os.Remove(zipFilePath) // clean up

VcrTest(t, resource.TestCase{
Expand Down Expand Up @@ -438,9 +439,9 @@ func TestAccCloudFunctionsFunction_pubsub(t *testing.T) {
Config: testAccCloudFunctionsFunction_pubsub(functionName, bucketName,
topicName, zipFilePath),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(funcResourceName,
"max_instances", "3000"),
),
resource.TestCheckResourceAttr(funcResourceName,
"max_instances", "3000"),
),
},
{
ResourceName: funcResourceName,
Expand Down

0 comments on commit 930d5ad

Please sign in to comment.