Add support for google_cloudfunctions_function runtime (#2340)

<!-- This change is generated by MagicModules. -->
/cc @rileykarson
This commit is contained in:
The Magician 2018-10-25 17:34:41 -07:00 committed by Nathan McKinley
parent fa7ef171a8
commit abf53cd91a
4 changed files with 27 additions and 0 deletions

View File

@ -170,6 +170,12 @@ func resourceCloudFunctionsFunction() *schema.Resource {
Optional: true,
},
"runtime": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"environment_variables": {
Type: schema.TypeMap,
Optional: true,
@ -316,6 +322,7 @@ func resourceCloudFunctionsCreate(d *schema.ResourceData, meta interface{}) erro
function := &cloudfunctions.CloudFunction{
Name: cloudFuncId.cloudFunctionId(),
Runtime: d.Get("runtime").(string),
ForceSendFields: []string{},
}
@ -426,6 +433,7 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error
}
d.Set("timeout", timeout)
d.Set("labels", function.Labels)
d.Set("runtime", function.Runtime)
d.Set("environment_variables", function.EnvironmentVariables)
if function.SourceArchiveUrl != "" {
// sourceArchiveUrl should always be a Google Cloud Storage URL (e.g. gs://bucket/object)
@ -519,6 +527,11 @@ func resourceCloudFunctionsUpdate(d *schema.ResourceData, meta interface{}) erro
updateMaskArr = append(updateMaskArr, "labels")
}
if d.HasChange("runtime") {
function.Runtime = d.Get("runtime").(string)
updateMaskArr = append(updateMaskArr, "runtime")
}
if d.HasChange("environment_variables") {
function.EnvironmentVariables = expandEnvironmentVariables(d)
updateMaskArr = append(updateMaskArr, "environment_variables")

View File

@ -108,6 +108,11 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) {
testAccCloudFunctionsFunctionHasLabel("my-label", "my-label-value", &function),
),
},
{
ResourceName: funcResourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccCloudFunctionsFunction_updated(functionName, bucketName, zipFileUpdatePath),
Check: resource.ComposeTestCheckFunc(
@ -127,6 +132,11 @@ func TestAccCloudFunctionsFunction_update(t *testing.T) {
"new-env-variable-value", &function),
),
},
{
ResourceName: funcResourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
@ -529,6 +539,7 @@ resource "google_cloudfunctions_function" "function" {
source_archive_bucket = "${google_storage_bucket.bucket.name}"
source_archive_object = "${google_storage_bucket_object.archive.name}"
trigger_http = true
runtime = "nodejs8"
timeout = 91
entry_point = "helloGET"
labels {

View File

@ -45,6 +45,7 @@ exported:
* `description` - Description of the function.
* `available_memory_mb` - Available memory (in MB) to the function.
* `timeout` - Function execution timeout (in seconds).
* `runtime` - The runtime in which the function is running.
* `entry_point` - Name of a JavaScript function that will be executed when the Google Cloud Function is triggered.
* `trigger_http` - If function is triggered by HTTP, this boolean is set.
* `event_trigger` - A source that fires events in response to a condition in another service. Structure is documented below.

View File

@ -76,6 +76,8 @@ Deprecated. Use `event_trigger` instead.
* `labels` - (Optional) A set of key/value label pairs to assign to the function.
* `runtime` - (Optional) The runtime in which the function is going to run. If empty, defaults to `"nodejs6"`.
* `environment_variables` - (Optional) A set of key/value environment variable pairs to assign to the function.
* `retry_on_failure` - (Optional) Whether the function should be retried on failure. This only applies to bucket and topic triggers, not HTTPS triggers.