Skip to content

Commit

Permalink
Add custom flattener for diagflowcx agent git integration settings fi…
Browse files Browse the repository at this point in the history
…eld (#9597)

* Add a custom flattener for the parent field

* Update mmv1/templates/terraform/custom_flatten/dialogflowcx_agent_git_integration_settings_github_settings.go.erb

Co-authored-by: Stephen Lewis (Burrows) <[email protected]>

---------

Co-authored-by: Stephen Lewis (Burrows) <[email protected]>
  • Loading branch information
trodge and melinath authored Dec 14, 2023
1 parent 617cca4 commit 0c03a04
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion mmv1/products/dialogflowcx/Agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ properties:
name: 'githubSettings'
description: |
Settings of integration with GitHub.
custom_flatten: 'templates/terraform/custom_flatten/dialogflowcx_agent_git_integration_settings_github_settings.go.erb' # accessToken comes from config, no response
properties:
- !ruby/object:Api::Type::String
name: 'displayName'
Expand All @@ -183,7 +184,6 @@ properties:
The access token used to authenticate the access to the GitHub repository.
sensitive: true
ignore_read: true
custom_flatten: 'templates/terraform/custom_flatten/dialogflowcx_agent_git_integration_settings_github_settings_access_token.go.erb'
- !ruby/object:Api::Type::Array
name: 'branches'
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<%# The license inside this block applies to this file.
# Copyright 2018 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-%>
func flattenDialogflowCXAgentGitIntegrationSettingsGithubSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return nil
}
original := v.(map[string]interface{})
// ignore access_token, which is always returned as REDACTED
delete(original, "access_token");
if len(original) == 0 {
return nil
}
transformed := make(map[string]interface{})
transformed["display_name"] = original["displayName"]
transformed["repository_uri"] = original["repositoryUri"]
transformed["tracking_branch"] = original["trackingBranch"]
transformed["access_token"] = d.Get("git_integration_settings.0.github_settings.0.access_token")
transformed["branches"] = original["branches"]
return []interface{}{transformed}
}

This file was deleted.

0 comments on commit 0c03a04

Please sign in to comment.