-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Subnet logconfig prepare for 3.0.0 #2572
Merged
modular-magician
merged 10 commits into
GoogleCloudPlatform:master
from
slevenick:subnet-logconfig
Nov 4, 2019
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
58678bf
Moving log config to GA, breaking changes
slevenick 61d892a
Fix subnet test id parsing
slevenick 149d4ba
Updating tests
slevenick 73bb708
Flow logs test works, custom flatten
slevenick b1b19e5
Add enable to subnetwork config
slevenick c1c390c
Respect enable_flow_logs, remove log_config.enable and assume it is t…
slevenick 9257d9b
Fix generated test to new format
slevenick 10f407b
Add back mistakenly deleted field from other resource. logConfig on s…
slevenick d1c46bd
Exclude subnetwork logConfig from ansible
slevenick e9e950d
Update tracked submodules -> HEAD on Mon Nov 4 17:40:24 UTC 2019
modular-magician File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule terraform
updated
from 392597 to b633d2
Submodule terraform-beta
updated
from 6419f5 to 32e18d
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
34 changes: 34 additions & 0 deletions
34
templates/terraform/custom_expand/subnetwork_log_config.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,34 @@ | ||
<%- # 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 expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { | ||
l := v.([]interface{}) | ||
if len(l) == 0 || l[0] == nil { | ||
return nil, nil | ||
} | ||
raw := l[0] | ||
original := raw.(map[string]interface{}) | ||
|
||
v, ok := d.GetOkExists("enable_flow_logs") | ||
|
||
transformed := make(map[string]interface{}) | ||
if !ok || v.(bool) { | ||
transformed["enable"] = true | ||
transformed["aggregationInterval"] = original["aggregation_interval"] | ||
transformed["flowSampling"] = original["flow_sampling"] | ||
transformed["metadata"] = original["metadata"] | ||
} | ||
|
||
return transformed, nil | ||
} |
34 changes: 34 additions & 0 deletions
34
templates/terraform/custom_flatten/subnetwork_log_config.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,34 @@ | ||
<%# 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 flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData) interface{} { | ||
if v == nil { | ||
return nil | ||
} | ||
original := v.(map[string]interface{}) | ||
if len(original) == 0 { | ||
return nil | ||
} | ||
|
||
v, ok := original["enable"] | ||
if ok && !v.(bool) { | ||
return nil | ||
} | ||
|
||
transformed := make(map[string]interface{}) | ||
transformed["flow_sampling"] = original["flowSampling"] | ||
transformed["aggregation_interval"] = original["aggregationInterval"] | ||
transformed["metadata"] = original["metadata"] | ||
return []interface{}{transformed} | ||
} |
12 changes: 2 additions & 10 deletions
12
...les/subnetwork_logging_config_beta.tf.erb → ...examples/subnetwork_logging_config.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 |
---|---|---|
@@ -1,25 +1,17 @@ | ||
resource "google_compute_subnetwork" "subnet-with-logging" { | ||
provider = "google-beta" | ||
name = "<%= ctx[:vars]['subnetwork_name'] %>" | ||
ip_cidr_range = "10.2.0.0/16" | ||
region = "us-central1" | ||
network = "${google_compute_network.custom-test.self_link}" | ||
|
||
enable_flow_logs = true | ||
log_config { | ||
aggregation_interval = "INTERVAL_10_MIN" | ||
flow_sampling = 0.5 | ||
metadata = "INCLUDE_ALL_METADATA" | ||
flow_sampling = 0.5 | ||
metadata = "INCLUDE_ALL_METADATA" | ||
} | ||
} | ||
|
||
resource "google_compute_network" "custom-test" { | ||
provider = "google-beta" | ||
name = "<%= ctx[:vars]['network_name'] %>" | ||
auto_create_subnetworks = false | ||
} | ||
|
||
provider "google-beta"{ | ||
region = "us-central1" | ||
zone = "us-central1-a" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we able to keep the field O+C? I'm a little hesitant to start catching drift out of the blue, especially on our last
2.X
release. However, it's beta-only so it's allowed imo.