-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pubsubConfigs to cloud source repository (#2769)
Merged PR #2769.
- Loading branch information
1 parent
6df2630
commit ba5780b
Showing
12 changed files
with
155 additions
and
8 deletions.
There are no files selected for viewing
Submodule ansible
updated
from 352731 to bf8746
Submodule inspec
updated
5 files
Submodule terraform
updated
from 734530 to aced67
Submodule terraform-beta
updated
from bcdb7d to 6e00ac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
templates/terraform/examples/sourcerepo_repository_full.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
resource "google_service_account" "test-account" { | ||
account_id = "<%= ctx[:vars]['account_id'] %>" | ||
display_name = "Test Service Account" | ||
} | ||
|
||
resource "google_pubsub_topic" "topic" { | ||
name = "<%= ctx[:vars]['topic_name'] %>" | ||
} | ||
|
||
resource "google_sourcerepo_repository" "<%= ctx[:primary_resource_id] %>" { | ||
name = "<%= ctx[:vars]['repository_name'] %>" | ||
pubsub_configs { | ||
topic = google_pubsub_topic.topic.id | ||
message_format = "JSON" | ||
service_account_email = google_service_account.test-account.email | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
templates/terraform/post_create/source_repo_repository_update.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if v, ok := d.GetOkExists("pubsub_configs"); !isEmptyValue(reflect.ValueOf(pubsubConfigsProp)) && (ok || !reflect.DeepEqual(v, pubsubConfigsProp)) { | ||
log.Printf("[DEBUG] Calling update after create to patch in pubsub_configs") | ||
// pubsub_configs cannot be added on create | ||
return resourceSourceRepoRepositoryUpdate(d, meta) | ||
} |
28 changes: 28 additions & 0 deletions
28
templates/terraform/update_encoder/source_repo_repository.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<%# 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. | ||
-%> | ||
// Add "topic" field using pubsubConfig map key | ||
pubsubConfigsVal := obj["pubsubConfigs"] | ||
if pubsubConfigsVal != nil { | ||
pubsubConfigs := pubsubConfigsVal.(map[string]interface{}) | ||
for key := range pubsubConfigs { | ||
config := pubsubConfigs[key].(map[string]interface{}) | ||
config["topic"] = key | ||
} | ||
} | ||
|
||
// Nest request body in "repo" field | ||
newObj := make(map[string]interface{}) | ||
newObj["repo"] = obj | ||
return newObj, nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters