这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mmv1/products/dialogflowcx/Playbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ update_mask: true
custom_code:
pre_create: 'templates/terraform/pre_create/dialogflow_set_location.go.tmpl'
pre_read: 'templates/terraform/pre_create/dialogflow_set_location.go.tmpl'
pre_update: 'templates/terraform/pre_create/dialogflow_set_location.go.tmpl'
pre_update: 'templates/terraform/pre_update/dialogflowcx_playbook_granular_update_mask.go.tmpl'
pre_delete: 'templates/terraform/pre_create/dialogflow_set_location.go.tmpl'
custom_import: 'templates/terraform/custom_import/dialogflowcx_playbook.go.tmpl'

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// extract location from the parent
location := ""

if parts := regexp.MustCompile(`locations\/([^\/]*)\/`).FindStringSubmatch(d.Get("parent").(string)); parts != nil {
location = parts[1]
} else {
return fmt.Errorf(
"Saw %s when the parent is expected to contains location %s",
d.Get("parent"),
"projects/{{"{{"}}project{{"}}"}}/locations/{{"{{"}}location{{"}}"}}/...",
)
}

// only insert location into url if the base_url in products/dialogflowcx/product.yaml is used
if strings.HasPrefix(url, "https://-dialogflow.googleapis.com/v3/") {
url = strings.Replace(url, "-dialogflow", fmt.Sprintf("%s-dialogflow", location), 1)
}

// The generated code sets the wrong masks for the following fields.
newUpdateMask := []string{}
if d.HasChange("instruction.0.steps") {
newUpdateMask = append(newUpdateMask, "instruction.steps")
}
if d.HasChange("instruction.0.guidelines") {
newUpdateMask = append(newUpdateMask, "instruction.guidelines")
}
// Pull out any other set fields from the generated mask.
for _, mask := range updateMask {
if mask == "instruction" {
continue
}
newUpdateMask = append(newUpdateMask, mask)
}
// Overwrite the previously set mask.
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(newUpdateMask, ",")})
if err != nil {
return err
}
Loading