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

Add support for network_firewall_policy and region_network_firewall_policy #6693

Merged
merged 23 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
80bef03
Adding new meta.yaml *Hide fields to better accomodate resources with…
Oct 13, 2022
29698b4
fix commented lines
Oct 13, 2022
145f8d4
adding network_firewall_policy* resources and regional variants
Oct 13, 2022
e6bff91
updating DCL dependency version
Oct 13, 2022
320ead8
Merge branch 'GoogleCloudPlatform:main' into dcl-nfp-promote
ghabian Oct 13, 2022
cd9206f
updating go.sum hashes
Oct 13, 2022
39232de
Merge branch 'dcl-nfp-promote' of https://github.com/ghabian/magic-mo…
Oct 13, 2022
06a2ebb
Updating TF DCL version
Oct 14, 2022
78c7ebc
Merge branch 'GoogleCloudPlatform:main' into dcl-nfp-promote
ghabian Oct 14, 2022
e54e1e6
bring beta nfp overrides to parity with ga
Oct 14, 2022
b0dc6f8
reduce scope of branch to only network_firewall_rule, fix regional ->…
Oct 15, 2022
e6e7d2c
Merge branch 'GoogleCloudPlatform:main' into dcl-nfp-promote
ghabian Oct 19, 2022
8b20cbc
Upgrading to DCL 1.26
Oct 19, 2022
c5676d5
Merge branch 'GoogleCloudPlatform:main' into dcl-nfp-promote
ghabian Nov 7, 2022
f1dc895
upgrade dcl to v1.26
alphanota Oct 19, 2022
e3a4a13
add clouddeploy test files
alphanota Oct 4, 2022
699b01d
add tags, and monitoring_config
alphanota Oct 20, 2022
d6ae66b
Add monitoringConfig to other files
alphanota Oct 20, 2022
e0c9220
Add a test for GKEHub servicemesh and exclude Eventarc trigger channe…
SirGitsalot Oct 22, 2022
5ea6e13
remove monitoring_config in handwritten tests and adding exclude for …
Nov 4, 2022
aa17bdd
Revert "add clouddeploy test files"
Nov 7, 2022
ce70d6b
Merge branch 'GoogleCloudPlatform:main' into dcl-nfp-promote
ghabian Nov 7, 2022
b96c861
adding update tests
Nov 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions tpgtools/overrides/compute/beta/network_firewall_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- type: CUSTOM_RESOURCE_NAME
details:
title: region_network_firewall_policy
location: region
- type: EXCLUDE
field: location
location: global
- type: EXCLUDE
field: region
- type: CUSTOM_NAME
details:
name: region
field: location
- type: CUSTOM_ID
details:
id: projects/{{project}}/regions/{{region}}/firewallPolicies/{{name}}
location: region
17 changes: 17 additions & 0 deletions tpgtools/overrides/compute/network_firewall_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- type: CUSTOM_RESOURCE_NAME
details:
title: region_network_firewall_policy
location: region
- type: EXCLUDE
field: location
location: global
- type: EXCLUDE
field: region
- type: CUSTOM_NAME
details:
name: region
field: location
- type: CUSTOM_ID
details:
id: projects/{{project}}/regions/{{region}}/firewallPolicies/{{name}}
location: region
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "google_compute_network_firewall_policy" "primary" {
name = "{{policy}}"
project = "{{project}}"
description = "Sample global network firewall policy"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
updates:
variables:
- name: policy
type: resource_name
- name: project
type: project
14 changes: 14 additions & 0 deletions tpgtools/overrides/compute/samples/networkfirewallpolicy/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# meta.yaml
# this is a shared config file that all the tests merge with
#
doc_hide_conditional:
- location: global
file_name: regional.tf.tmpl
- location: region
file_name: global.tf.tmpl

test_hide_conditional:
- location: global
file_name: regional.tf.tmpl
- location: region
file_name: global.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "google_compute_region_network_firewall_policy" "primary" {
name = "{{policy}}"
project = "{{project}}"
description = "Sample regional network firewall policy"
region = "{{region}}"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
updates:
variables:
- name: policy
type: resource_name
- name: project
type: project
- name: region
type: region
16 changes: 15 additions & 1 deletion tpgtools/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,22 @@ func (r Resource) getSamples(docs bool) []Sample {
var hideList []string
if docs {
hideList = r.Samples[0].DocHide
if len(r.Samples[0].DocHideConditional) > 0 {
for _, dochidec := range r.Samples[0].DocHideConditional {
if r.location == dochidec.Location {
hideList = append (hideList, dochidec.Name)
}
}
}
} else {
hideList = r.Samples[0].Testhide
if len(r.Samples[0].TestHideConditional) > 0 {
for _, testhidec := range r.Samples[0].TestHideConditional {
if r.location == testhidec.Location {
hideList = append (hideList, testhidec.Name)
}
}
}
}
for _, sample := range r.Samples {
shouldhide := false
Expand Down Expand Up @@ -806,7 +820,7 @@ func (r *Resource) loadDCLSamples() []Sample {
sampleAccessoryFolder := r.getSampleAccessoryFolder()
packagePath := r.productMetadata.PackagePath
version := r.versionMetadata.V
resourceType := r.DCLTitle()
resourceType := r.DCLTitle()
sampleFriendlyMetaPath := path.Join(string(sampleAccessoryFolder), "meta.yaml")
samples := []Sample{}

Expand Down
19 changes: 19 additions & 0 deletions tpgtools/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ type Sample struct {
// DocHide specifies a list of samples to hide from docs
DocHide []string `yaml:"doc_hide"`

// DocHideConditional specifies a list of samples to hide from docs when resource location matches
DocHideConditional []DocHideCondition `yaml:"doc_hide_conditional"`

// Testhide specifies a list of samples to hide from tests
Testhide []string `yaml:"test_hide"`

// TesthideConditional specifies a list of samples to hide from tests when resource location matches
TestHideConditional []TestHideCondition `yaml:"test_hide_conditional"`

// ExtraDependencies are the additional golang dependencies the injected code may require
ExtraDependencies []string `yaml:"extra_dependencies"`

Expand All @@ -87,6 +93,19 @@ type Variable struct {
DocsValue string `yaml:"docs_value"`
}

type DocHideCondition struct {
// Location is the location attribute to match, if matched, append Name to list of DocHide
Location string `yaml:"location"`
// Name specifies sample file name to add to DocHide if location matches.
Name string `yaml:"file_name"`
}

type TestHideCondition struct {
// Location is the location attribute to match, if matched, append Name to list of Testhide
Location string `yaml:"location"`
// Name specifies sample file name to add to Testhide if location matches.
Name string `yaml:"file_name"`
}
// Dependency contains data that describes a single resource in a sample
type Dependency struct {
// FileName is the name of the file as it appears in testcases.yaml
Expand Down