Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: diff being detected for source_repo_repository even when there are no changes #3786

Merged
Merged
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: 2 additions & 0 deletions products/sourcerepo/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides
A Cloud Pub/Sub topic in this repo's project. Values are of the form
`projects/<project>/topics/<topic>` or `<topic>` (where the topic will
be inferred).
set_hash_func: 'resourceSourceRepoRepositoryPubSubConfigsHash'
pubsubConfigs.serviceAccountEmail: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
constants: templates/terraform/constants/source_repo_repository.go.erb
update_encoder: templates/terraform/update_encoder/source_repo_repository.erb
post_create: templates/terraform/post_create/source_repo_repository_update.go.erb
# This is for copying files over
Expand Down
30 changes: 30 additions & 0 deletions templates/terraform/constants/source_repo_repository.go.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<%- # the license inside this block applies to this file
# Copyright 2019 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 resourceSourceRepoRepositoryPubSubConfigsHash(v interface{}) int {
if v == nil {
return 0
}

var buf bytes.Buffer
m := v.(map[string]interface{})

buf.WriteString(fmt.Sprintf("%s-", GetResourceNameFromSelfLink(m["topic"].(string))))
buf.WriteString(fmt.Sprintf("%s-", m["message_format"].(string)))
if v, ok := m["service_account_email"]; ok {
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
}

return hashcode.String(buf.String())
}